Changing Permissions – Numeric Method
- Uses a three-digit mode number
- first digit specifies owner’s permissions
- second digit specifies group permissions
- third digit represents others’ permissions
- Permissions are calculated by adding:
- 4 (for read)
- 2 (for write)
- 1 (for execute)
- chmod 640 myfile
Numerical Mode Setting
To change all the permissions on a file at once, it is often easier and quicker to use the numeric method.
In this method, the first argument to the chmod command is a three-digit number representing the permissions that are set. In this method, the read permission has a value of four, the write permission has a value of two, and the execute permission has a value of one. Add together the permissions you wish to set for user, group, and others. Examples:
chmod 664 file: grants read/write to the owner and group, read-only to others.
chmod 660 file: grants read/write to the owner and group: no permissions for others
chmod 600 file: grants read/write to the owner; no permissions set for the group and others
chmod 444 file: grants read-only to all.
With directory permissions, when you set the read permission, you almost always want to set execute permission. Examples:
chmod 755 dir: grants full permissions to the owner, read and execute to group and other.
chmod 770 dir: grants full permissions to the owner and group, no permissions to others
chmod 700 dir: grants full permissions to the owner, no permissions to the group or others
chmod 555 dir: grants read and execute permission set to all.