chmod Permissions Cheat Sheet
Every file has three sets of permissions: for the owner, the group and others. Each set is made of read, write and execute.
| Letter | Number | Meaning |
|---|---|---|
r | 4 | Read |
w | 2 | Write |
x | 1 | Execute (or enter, for a folder) |
Add the numbers for each set. rw- is 4 + 2 = 6, r-x is 4 + 1 = 5, and rwx is 7. So 755 means owner rwx, group r-x, others r-x.
Common values
| Number | Letters | Typical use |
|---|---|---|
| 777 | rwxrwxrwx | Everyone can do everything. Avoid it |
| 755 | rwxr-xr-x | Programs and public folders |
| 750 | rwxr-x--- | Owner and group only |
| 700 | rwx------ | Private to the owner |
| 644 | rw-r--r-- | Normal files, readable by everyone |
| 640 | rw-r----- | Owner writes, group reads |
| 600 | rw------- | Private files such as SSH keys |
| 400 | r-------- | Read-only for the owner |
Commands
chmod 644 file.txt # set by number
chmod +x script.sh # add execute for everyone
chmod u+w,g-w file.txt # owner gains write, group loses it
chmod -R 755 folder # apply to a folder and everything inside
In the letter form, u is the owner (user), g the group, o others and a all. + adds, - removes and = sets exactly.
Tips
- SSH refuses private keys that others can read, so use
chmod 600 ~/.ssh/id_ed25519. - Do not use 777 to “fix” an error. Find which user needs access and give only that.