Linux File Permissions Cheat Sheet

Linux file permissions explained: chmod, chown, octal notation, symbolic notation, special permissions (SUID, SGID, sticky bit). Complete reference.

Permission Basics

SymbolDescription
r (read)Files: view contents. Directories: list files inside
w (write)Files: modify contents. Directories: create, delete, rename files inside
x (execute)Files: run as a program. Directories: enter the directory (cd)
-Permission not granted
u (user)The file owner
g (group)The file's group
o (other)Everyone else
a (all)All three: user, group, and other
-rwxrwxrwxFull permission string: [type][user rwx][group rwx][other rwx]
ls -lView permissions, owner, group, size, and date of files
stat filenameView detailed file status including permissions in both symbolic and octal

Octal (Numeric) Notation

Octal ValueDescription
0No permission ---
1Execute only --x
2Write only -w-
3Write and execute -wx
4Read only r--
5Read and execute r-x
6Read and write rw-
7Read, write, and execute rwx

chmod — Symbolic Notation

CommandDescription
chmod u+x fileAdd execute permission for the file owner
chmod u-w fileRemove write permission from the file owner
chmod g+r fileAdd read permission for the group
chmod g-x fileRemove execute permission from the group
chmod o+r fileAdd read permission for others
chmod o-rwx fileRemove all permissions for others
chmod a+r fileAdd read permission for everyone (user, group, other)
chmod u+x,g+r fileAdd execute for owner and read for group in one command
chmod u=rwx,g=rx,o=r fileSet exact permissions: owner rwx, group rx, other r
chmod +x fileAdd execute permission for all (equivalent to a+x)
chmod -R u+rw dir/Recursively add read and write for owner to entire directory tree

chmod — Octal Notation Examples

CommandDescription
chmod 755 filerwxr-xr-x — Owner full, group and others read/execute
chmod 644 filerw-r--r-- — Owner read/write, group and others read only
chmod 700 filerwx------ — Owner full, no access for anyone else
chmod 600 filerw------- — Owner read/write only, no one else
chmod 777 filerwxrwxrwx — Full access for everyone (use with caution)
chmod 666 filerw-rw-rw- — Read/write for everyone, no execute
chmod 444 filer--r--r-- — Read only for everyone
chmod 555 filer-xr-xr-x — Read and execute for everyone, no write
chmod 750 filerwxr-x--- — Owner full, group read/execute, others none
chmod 640 filerw-r----- — Owner read/write, group read, others none
chmod -R 755 dir/Recursively set 755 permissions on an entire directory tree

chown & chgrp

CommandDescription
chown user fileChange the owner of a file
chown user:group fileChange the owner and group of a file
chown :group fileChange only the group of a file
chown -R user:group dir/Recursively change owner and group for an entire directory
chown --reference=ref fileSet ownership of file to match ref
chgrp group fileChange the group of a file
chgrp -R group dir/Recursively change the group for an entire directory

Special Permissions

PermissionDescription
SUID (Set User ID)When set on an executable, it runs with the permissions of the file owner (e.g., /usr/bin/passwd)
chmod u+s fileSet the SUID bit on a file
chmod 4755 fileSet SUID with octal notation (leading 4): -rwsr-xr-x
SGID (Set Group ID)Executables run with group permissions. Directories: new files inherit the group
chmod g+s dir/Set the SGID bit on a directory
chmod 2755 dir/Set SGID with octal notation (leading 2): drwxr-sr-x
Sticky BitOn directories, only the file owner can delete their files (e.g., /tmp)
chmod +t dir/Set the sticky bit on a directory
chmod 1755 dir/Set sticky bit with octal notation (leading 1): drwxr-xr-t
-rwsr-xr-xThe s in owner execute position indicates SUID is set
drwxr-sr-xThe s in group execute position indicates SGID is set
drwxrwxrwtThe t in other execute position indicates sticky bit is set
-rwSr--r--Uppercase S means SUID is set but execute is not (often an error)

Common Permission Patterns

PatternDescription
644 (rw-r--r--)Standard for regular files — owner can edit, others can read
755 (rwxr-xr-x)Standard for directories and executables — owner full, others can read and execute
600 (rw-------)Private files (e.g., SSH keys, ~/.ssh/id_rsa)
700 (rwx------)Private directories (e.g., ~/.ssh)
444 (r--r--r--)Read-only for everyone — config files you don't want modified
777 (rwxrwxrwx)Full access for everyone — security risk, avoid in production
750 (rwxr-x---)Owner full, group can read/execute, others no access
640 (rw-r-----)Owner read/write, group read only, others no access
400 (r--------)Read-only for owner only (e.g., authorized_keys on some systems)

umask

CommandDescription
umaskDisplay the current umask value
umask -SDisplay the current umask in symbolic notation
umask 022Set umask to 022 — new files get 644, directories get 755
umask 077Set umask to 077 — new files get 600, directories get 700 (most restrictive)
umask 002Set umask to 002 — new files get 664, directories get 775 (group-friendly)
How umask worksThe umask is subtracted from 666 (files) or 777 (directories) to get default permissions
Default umask: 022Files: 666 - 022 = 644. Directories: 777 - 022 = 755
Set in ~/.bashrcAdd umask 027 to your profile for persistent umask settings