How to change Permissions in Linux – Symbolic Method

This blog post explains how to Change Permissions in Linux using the symbolic method. It includes examples of how to add, remove, and modify permissions for the owner, group, and others.

Change Permissions – Symbolic Method

  • To change access modes:
    • chmod [-OPTION]…. mode[,mode] file|directory ….
  • mode includes:
    • u,g or o for user, group and other
    • +- or = for grant, deny or set
    • r, w or x for read, write and execute
  • Options include:
    • -R Recursive
    • -v Verbose
    • –reference Reference another file for its mode
  • Examples:
    • chmod ugo+r file: Grant read access to all for file
    • chmod o-wx dir: Deny write and execute to others for dir
    • chmod --reference file 1 file2: Get the mode from file1 and place it on file2

chmod Syntax

The chmod command changes access mode for files and directories. The chmod command takes a permission instruction followed by a list of files or directories to change. The permission instruction can be issued either symbolically (the symbolic method) or numerically (the numeric method).

Using the symbolic method, the permission expression contains three fields: an indicator of who has access to the file, an operator for selecting how the permissions could be changed, and a permission. If no who value is given, then the permission is added or removed for user, group and other. Multiple, comma separated operations can be given in a single command.

Who may be operator may bepermissions may be
u User who owns the file+ Add a permissionr Read
g Users in the file’s Group Remove a permissionw Write
o Other users= Assign a permissionx Execute or cd
a All three categoriess Set user ID bit or group
t Sticky bit (for directories)

Examples: –

chmod u+w,go-w .bashrc grants write access to owner but denies it to group and other.

chmod u=rw .bashrc sets user permissions to read and write, with execute turned off, regardless of the current permissions

chmod +r .bashrc makes the file world-readable

A useful option to chmod is -R (recursive). This option tells chmod to traverse an entire directory tree to change the permissions of all its files and subdirectories. The s and t permissions will be discussed in a later unit.

1 thought on “How to change Permissions in Linux – Symbolic Method”

Leave a Comment