chmod [Command]
|Command chmod
chmod – command changes the permissions of one or more files.
Syntax
chmod [-cfvR] permissions files
Options
-c displays only files with changed permissions.
-f suppress error messages.
-v displays detailed information about changes of access rights.
-R recursively changes the permissions of files in all subdirectories.
Description
To effectively use chmod to know how to set permissions. One ways involves a concatenation of one letter from each of the following tables consecutively (Who / Action / Access):
Who | Action | Access |
---|---|---|
u user | + add | r read |
g group | – delete | w write |
o others | = assign | x execute |
a all | s set user ID |
To grant read access to all files in directory, type chmod a+r *. For permit the execution of the file to all users, type chmod + x filename.
Another way to specify permissions is to use sequence CONTRACT PERIOD three octal digits. In a detailed listing of the right to read, write and execute for user, group and others look like a sequence rwxrwxrwx (with a dash in place of letters for prohibited transactions). Row rwxrwxrwx can be regarded as a three-fold repetition of the line rwx. Now set the value r = 4, w = 2 and x = 1. To obtain the sequence rwx, add the values r, w and x. Thus, rwx = 7. Using this formula, you can assign three-digit value of any rights of access.
Note to self:X (capital x) means “execute/search only if the file is a directory or arleady has execute permission for some user”u=blah or u+blah has always been my preferred way of setting permissions. Since it avoids needing to work in octals (have enough trouble with decimal).