Chmod & File Permissions Cheat Sheet

Linux file permissions control who can read, write, and execute a file or directory. Every file has three permission groups — owner, group, and others — and three permission types — read, write, execute. This reference covers how to read a permission string, octal and symbolic notation, special bits, and the most common chmod commands.

Quick format: -rwxr-xr-- breaks down as:

  • - — file type (- file, d directory, l symlink)
  • rwx — owner permissions
  • r-x — group permissions
  • r-- — others permissions

Permission Types

SymbolOctalMeaning on a FileMeaning on a Directory
r4Read the fileList directory contents
w2Write / modify the fileCreate, delete, rename files inside
x1Execute the fileEnter (cd into) the directory
-0Permission not setPermission not set

Octal Notation

Each permission group is the sum of its active bits.

OctalBinaryPermissions
0000--- none
1001--x execute only
2010-w- write only
3011-wx write + execute
4100r-- read only
5101r-x read + execute
6110rw- read + write
7111rwx read + write + execute

Reading a three-digit octal like 755:

DigitWhoPermissions
7Ownerrwx
5Groupr-x
5Othersr-x

Common Permission Values

The codes you'll use or encounter most often.

OctalSymbolicTypical Use
777rwxrwxrwxEveryone can do everything (avoid in production)
755rwxr-xr-xWeb directories, executables
750rwxr-x---Owner full, group read/execute, others none
700rwx------Private executable — only the owner
664rw-rw-r--Shared group file
644rw-r--r--Standard file — owner writes, all can read
640rw-r-----Config files with sensitive data
600rw-------SSH keys, private files
444r--r--r--Read-only for everyone
400r--------Read-only, owner only (e.g., PEM files)

Symbolic Notation

An alternative to octal — more readable for targeted changes.

PartOptionsMeaning
WhouUser (owner)
gGroup
oOthers
aAll (u + g + o)
Operator+Add permission
-Remove permission
=Set exactly (replace)
WhatrRead
wWrite
xExecute

Symbolic chmod examples

CommandWhat it does
chmod u+x fileAdd execute for the owner
chmod g-w fileRemove write from group
chmod o=r fileSet others to read-only
chmod a+r fileAdd read for everyone
chmod u+x,g-w fileMultiple changes at once
chmod a-x fileRemove execute from everyone
chmod ug=rw fileSet owner and group to read+write

Common chmod Commands

TaskCommand
Make a script executablechmod +x script.sh
Secure an SSH private keychmod 600 ~/.ssh/id_rsa
Standard web filechmod 644 index.html
Standard web directorychmod 755 /var/www/html
Private config filechmod 640 config.env
Restrict to owner onlychmod 700 ~/private
Apply recursivelychmod -R 755 /var/www
Read-only for allchmod 444 file.txt

Special Bits

Beyond the standard rwx, three extra bits control elevated behaviors.

BitOctalSymbolEffect
Setuid4 (prefix)s in owner executeFile runs as the file's owner, not the caller
Setgid2 (prefix)s in group executeFile runs as the group; on dirs, new files inherit the group
Sticky bit1 (prefix)t in others executeOn dirs, only the owner can delete their own files (e.g., /tmp)

Special bit examples

CommandMeaning
chmod 4755 fileSetuid + 755
chmod 2755 dirSetgid + 755
chmod 1777 /tmpSticky bit + 777
chmod u+s fileAdd setuid symbolically
chmod g+s dirAdd setgid symbolically
chmod +t dirAdd sticky bit symbolically

Viewing Permissions

TaskCommand
List files with permissionsls -l
List all including hiddenls -la
Show permissions as octalstat -c "%a %n" file
Show full stat infostat file
Find files with a permissionfind . -perm 644
Find world-writable filesfind . -perm -o+w

Ownership (chown & chgrp)

Permissions only make sense alongside ownership — who is the "owner" and which "group" does the file belong to.

TaskCommand
Change ownerchown user file
Change owner and groupchown user:group file
Change group onlychgrp group file
Recursive ownership changechown -R user:group /var/www
View current ownerls -l file

Golden Rules

  1. Never use 777 in production — it grants full access to everyone on the system, including potential attackers.
  2. SSH keys must be 600 — SSH will refuse to use a private key that is readable by others.
  3. Prefer symbolic for targeted changeschmod g+x is safer than octal when you only want to add one permission without touching the rest.
  4. Use -R with caution — recursive chmod changes every file and directory under the path; files and directories usually need different permissions.
  5. Sticky bit protects shared dirs — use 1777 on shared directories like /tmp so users can't delete each other's files.

Frequently Asked Questions

What does chmod 755 mean? The owner has full read, write, and execute permissions (7 = rwx), while the group and others can only read and execute (5 = r-x). This is the standard permission for web directories and executables.

What is the difference between chmod 644 and 755? 644 gives the owner read and write (rw-) and everyone else read-only (r--), making it right for files like HTML or config that need to be read but not executed. 755 adds execute, making it right for directories and scripts.

Why does SSH say "permissions are too open"? SSH requires private key files to be readable only by the owner. Fix it with chmod 600 ~/.ssh/id_rsa.

What is the sticky bit? The sticky bit on a directory means only a file's owner can delete or rename it, even if others have write access to the directory. It's commonly set on /tmp.

What is setuid? Setuid makes an executable run with the file owner's privileges rather than the caller's. It's how commands like passwd can write to /etc/shadow even when run by a regular user.

What is the difference between chown and chmod? chmod changes the permissions on a file (what actions are allowed). chown changes who owns the file (which user and group the permission bits apply to).

Last Updated on Jul 13, 2026