All cheat sheets
Cheat Sheet

Chmod

Unix file permissions reference: octal values, symbolic notation, common chmod values, special bits (SUID, SGID, sticky), and useful commands.

Unix file permissions control who can read (r), write (w), and execute (x) a file or directory. Permissions are set for three groups: Owner, Group, and Others.

Permission Bits

SymbolOctalPermissionOn fileOn directory
r4ReadView file contentsList directory contents
w2WriteModify or delete fileCreate, delete, rename files inside
x1ExecuteRun as a programEnter (cd) the directory
-0NoneNo permissionNo permission

Common Octal Values

OctalSymbolicMeaningTypical use
777rwxrwxrwxEveryone has full accessAvoid — dangerous
755rwxr-xr-xOwner full, group/others read+executeExecutables, public dirs
750rwxr-x---Owner full, group read+executeRestricted executables
700rwx------Owner full, others nonePrivate scripts
644rw-r--r--Owner read+write, others read-onlyRegular files, configs
640rw-r-----Owner read+write, group read-onlySensitive configs
600rw-------Owner read+write onlySSH keys, secrets
400r--------Owner read-onlyRead-only credentials

Symbolic Notation (chmod)

chmod +x fileAdd execute for all
chmod -x fileRemove execute for all
chmod u+x fileAdd execute for owner only
chmod g-w fileRemove write from group
chmod o=r fileSet others to read-only exactly
chmod a=rx dirSet everyone to read + execute
chmod -R 755 dir/Recursive — apply to all files in dir

Who

u user (owner)

g group

o others

a all (u+g+o)

Operator

+ add permission

- remove permission

= set exactly

Permission

r read

w write

x execute

Reading ls -l Output

-rwxr-xr-x  1  alice  staff  4096  Jan 10  file.sh
drwxr-x---  2  alice  staff  128   Jan 10  mydir/
-rwxr-xr-xFile type (1 char) + permissions (9 chars: owner / group / others)
1Hard link count
aliceOwner user
staffOwner group
4096File size in bytes
Jan 10Last modification date

First character: - file · d directory · l symlink · b block device

Special Bits

4xxxSetUID (SUID)chmod u+s file

When set on an executable, it runs as the file owner, not the user running it. Shown as "s" in owner execute position. E.g. /usr/bin/passwd.

2xxxSetGID (SGID)chmod g+s dir

On a file: runs as the file group. On a directory: new files inherit the directory's group instead of the creator's.

1xxxSticky Bitchmod +t dir

On a directory, only the file owner (or root) can delete or rename files inside. Shown as "t". Used on /tmp.

Useful Commands

chmod 755 fileSet permissions by octal
chmod -R 644 dir/Recursive chmod
chown alice fileChange owner
chown alice:staff fileChange owner and group
chown -R alice:staff dir/Recursive chown
umask 022Set default permission mask (files get 644, dirs 755)
umaskShow current umask
stat fileShow full metadata including permissions in octal
find . -perm 777Find files with specific permissions
find . -perm /o+wFind world-writable files

Calculate permissions visually with our Chmod Calculator →

Click checkboxes and get the numeric and symbolic notation instantly.