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
| Symbol | Octal | Permission | On file | On directory |
|---|---|---|---|---|
| r | 4 | Read | View file contents | List directory contents |
| w | 2 | Write | Modify or delete file | Create, delete, rename files inside |
| x | 1 | Execute | Run as a program | Enter (cd) the directory |
| - | 0 | None | No permission | No permission |
Common Octal Values
| Octal | Symbolic | Meaning | Typical use |
|---|---|---|---|
| 777 | rwxrwxrwx | Everyone has full access | Avoid — dangerous |
| 755 | rwxr-xr-x | Owner full, group/others read+execute | Executables, public dirs |
| 750 | rwxr-x--- | Owner full, group read+execute | Restricted executables |
| 700 | rwx------ | Owner full, others none | Private scripts |
| 644 | rw-r--r-- | Owner read+write, others read-only | Regular files, configs |
| 640 | rw-r----- | Owner read+write, group read-only | Sensitive configs |
| 600 | rw------- | Owner read+write only | SSH keys, secrets |
| 400 | r-------- | Owner read-only | Read-only credentials |
Symbolic Notation (chmod)
chmod +x fileAdd execute for allchmod -x fileRemove execute for allchmod u+x fileAdd execute for owner onlychmod g-w fileRemove write from groupchmod o=r fileSet others to read-only exactlychmod a=rx dirSet everyone to read + executechmod -R 755 dir/Recursive — apply to all files in dirWho
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 countaliceOwner userstaffOwner group4096File size in bytesJan 10Last modification dateFirst character: - file · d directory · l symlink · b block device
Special Bits
4xxxSetUID (SUID)chmod u+s fileWhen 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 dirOn 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 dirOn 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 octalchmod -R 644 dir/Recursive chmodchown alice fileChange ownerchown alice:staff fileChange owner and groupchown -R alice:staff dir/Recursive chownumask 022Set default permission mask (files get 644, dirs 755)umaskShow current umaskstat fileShow full metadata including permissions in octalfind . -perm 777Find files with specific permissionsfind . -perm /o+wFind world-writable filesCalculate permissions visually with our Chmod Calculator →
Click checkboxes and get the numeric and symbolic notation instantly.