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.

LetterNumberMeaning
r4Read
w2Write
x1Execute (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

NumberLettersTypical use
777rwxrwxrwxEveryone can do everything. Avoid it
755rwxr-xr-xPrograms and public folders
750rwxr-x---Owner and group only
700rwx------Private to the owner
644rw-r--r--Normal files, readable by everyone
640rw-r-----Owner writes, group reads
600rw-------Private files such as SSH keys
400r--------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.
↑ ↓ navigateEnter openEsc close