Linux File Permissions

Understanding file permissions in Linux.

Published January 15, 2025 ET

There are two levels of permissions assigned to the files, directories, and processes in Linux.

The first one is permission groups, which is otherwise referred to as the ownership. The three types of user groups are owners, groups, and others.

The second one is permission types, which can be read, write, or execute.

  • read: r
  • write: w
  • execute: x

Example

ls -l

Response:

drwxr-xr-x   5 andre-jacquesdebeer  staff    160 Aug 15 17:49 k8s
 12345678910

Position meanings:

  • 1 = item type

    • d = directory
    • c = character
    • s = socket
    • p = pipe
    • D = D
    • l = symbolic link
  • 234 => owner

  • 567 => groups

  • 8910 => others

So rwxr-xr-x means the owner of the file (andre-jacquesdebeer) can read, write, and execute, group may read and execute (not write!) and others may read and execute (again, not write!)

Number form

  • 0: No permission
  • 1: Execute
  • 2: Write
  • 4: Read

Combinations:

  • rwx = 1+2+4 = 7
  • rw- = 2+4 = 6
  • r-x = 1+4 = 5
  • r-- = 4
  • -wx = 2+1 = 3
  • -w- = 2
  • --x = 1

Example:

sudo chmod 777 filename.txt