Permissions as Numbers: 644, 755 and 600

Each permission has a value

Admins usually write permissions as numbers. Each letter has a value and you add them up:

LetterValue
r4
w2
x1
-0

So rwx = 4+2+1 = 7, rw- = 4+2 = 6, r-x = 4+1 = 5 and r-- = 4. Three digits give the owner, the group and the others, in that order:

NumberLettersTypical use
644rw-r--r--Normal files: you edit, everyone reads
755rwxr-xr-xPrograms, scripts and directories
600rw-------Private files: passwords, SSH keys
700rwx------Private directories and scripts
640rw-r-----Your group may read, others nothing
777rwxrwxrwxEveryone may do everything: almost always a mistake

chmod with numbers

chmod 600 diary.txt
chmod 755 hello.sh
ls -l diary.txt hello.sh
stat -c '%a %A %n' diary.txt hello.sh

In the terminal

student@vulntech:~$ chmod 600 diary.txt
student@vulntech:~$ chmod 755 hello.sh
student@vulntech:~$ ls -l diary.txt hello.sh
-rw------- 1 student student 35 Oct 17 06:30 diary.txt
-rwxr-xr-x 1 student student 40 Oct 17 06:30 hello.sh
student@vulntech:~$ stat -c '%a %A %n' diary.txt hello.sh
600 -rw------- diary.txt
755 -rwxr-xr-x hello.sh

Numbers always set all the permissions at once. Letters are handier to change just one (chmod g+w).

Common mistake: Permission denied? Just chmod 777 it! That fixes the error by letting every user on the machine read, change and run the file. On a web server, a writable 777 script is an open door for attackers. Find out who needs access and give exactly that.

Tip: Security audits search for world-writable files: find /srv -perm -o+w lists everything others may write.

Remember: r = 4, w = 2, x = 1. Digits for owner, group, others. 644 files, 755 programs and folders, 600 secrets.

HOME LEARN COMMUNITY DASHBOARD
Practice terminal Starting…