Intermediate · 8 min · practise every command in the built-in terminal

Understanding File Permissions

Every file and directory in Linux has permissions controlling who can read, write, or execute it.

Reading permissions

ls -la
-rwxr-xr-- 1 student student 1234 Jan 15 10:00 script.sh

Permission structure

 -  rwx  r-x  r--
[1] [2]  [3]  [4]
  1. Type: - file, d directory, l symlink
  2. Owner permissions (rwx)
  3. Group permissions (r-x)
  4. Others permissions (r--)

Permission characters

CharMeaningValue
rRead4
wWrite2
xExecute1
-No permission0

Numeric (octal) notation

Permissions are often written as 3 digits:

755 = rwxr-xr-x
644 = rw-r--r--
600 = rw-------
777 = rwxrwxrwx

Calculate: add the values for each permission:

  • rwx = 4+2+1 = 7
  • r-x = 4+0+1 = 5
  • r-- = 4+0+0 = 4

Common permission sets

OctalSymbolicUse case
644rw-r--r--Regular files
755rwxr-xr-xExecutables, directories
600rw-------Private files
700rwx------Private directories

Practice tasks

  1. List files in your home directory with permissions visible
  2. Check detailed permission info for README.txt with stat
  3. List permissions of files in /etc

Commands in this lesson

Permissions