Usage: chmod [-R] MODE[,MODE]... FILE...
Change file access permissions for the specified FILE(s) (or directories). Each MODE is defined by combining the letters for WHO has access to the file, an OPERATOR for selecting how the permissions should be changed, and a PERMISSION for FILE(s) (or directories).
WHO may be chosen from
u User who owns the file g Users in the file's Group o Other users not in the file's group a All users |
OPERATOR may be chosen from
+ Add a permission - Remove a permission = Assign a permission |
PERMISSION may be chosen from
r Read w Write x Execute (or access for directories) s Set user (or group) ID bit t Sticky bit (for directories prevents removing files by non-owners) |
Alternately, permissions can be set numerically where the first three numbers are calculated by adding the octal values, such as
4 Read 2 Write 1 Execute |
An optional fourth digit can also be used to specify
4 Set user ID 2 Set group ID 1 Sticky bit |
Options:
-R Change files and directories recursively. |
Example:
$ ls -l /tmp/foo -rw-rw-r-- 1 root root 0 Apr 12 18:25 /tmp/foo $ chmod u+x /tmp/foo $ ls -l /tmp/foo -rwxrw-r-- 1 root root 0 Apr 12 18:25 /tmp/foo* $ chmod 444 /tmp/foo $ ls -l /tmp/foo -r--r--r-- 1 root root 0 Apr 12 18:25 /tmp/foo |