📖 Guide
Chmod — Complete Reference
Linux file permission commands and patterns for chmod.
47 commands across 7 categories
Numeric ModeSymbolic ModeCommon PermissionsDirectory PermissionsSpecial PermissionsRecursiveCommon Patterns
Numeric Mode
| Command | Description |
|---|---|
chmod 755 file | Owner rwx, group rx, others rx |
chmod 644 file | Owner rw, group r, others r |
chmod 700 file | Owner rwx, no access for others |
chmod 600 file | Owner rw only, no access for others |
chmod 777 file | Full permissions for everyone (use with caution) |
chmod 000 file | Remove all permissions |
chmod 750 file | Owner rwx, group rx, others none |
Symbolic Mode
| Command | Description |
|---|---|
chmod u+x file | Add execute permission for owner |
chmod g+w file | Add write permission for group |
chmod o-r file | Remove read permission for others |
chmod a+r file | Add read permission for all (user, group, others) |
chmod u=rwx,g=rx,o=r file | Set exact permissions for each class |
chmod ug+x file | Add execute for owner and group |
chmod u+x,g-w,o-rwx file | Multiple changes in one command |
Common Permissions
| Command | Description |
|---|---|
chmod 644 file.txt | Standard file: owner rw, others read-only |
chmod 755 script.sh | Executable script: owner rwx, others rx |
chmod 600 ~/.ssh/id_rsa | SSH private key: owner rw only |
chmod 644 ~/.ssh/id_rsa.pub | SSH public key: owner rw, others read |
chmod 400 secret.pem | Read-only for owner, no access for others |
chmod 664 shared.txt | Owner and group rw, others read-only |
Directory Permissions
| Command | Description |
|---|---|
chmod 755 dir/ | Standard directory: owner full, others can list and enter |
chmod 700 dir/ | Private directory: only owner can access |
chmod 750 dir/ | Group-accessible directory: owner full, group can list/enter |
chmod 1777 /tmp | World-writable with sticky bit (like /tmp) |
chmod 2775 dir/ | Setgid directory: new files inherit group ownership |
chmod o+x dir/ | Allow others to enter directory (requires r to list) |
Special Permissions
| Command | Description |
|---|---|
chmod u+s filee.g. chmod u+s /usr/bin/passwd | Set SUID — file executes as the file owner |
chmod g+s file | Set SGID — file executes with group privileges |
chmod g+s dir/ | Set SGID on directory — new files inherit group |
chmod +t dir/ | Set sticky bit — only owner can delete their files |
chmod 4755 filee.g. ls -l shows -rwsr-xr-x | Numeric SUID: 4xxx prefix |
chmod 2755 filee.g. ls -l shows -rwxr-sr-x | Numeric SGID: 2xxx prefix |
chmod 1755 dir/e.g. ls -l shows drwxr-xr-t | Numeric sticky bit: 1xxx prefix |
Recursive
| Command | Description |
|---|---|
chmod -R 755 dir/ | Apply permissions recursively to directory and contents |
chmod -R u+w dir/ | Add write permission recursively for owner |
find dir/ -type f -exec chmod 644 {} + | Set 644 on files only (not directories) |
find dir/ -type d -exec chmod 755 {} + | Set 755 on directories only (not files) |
chmod -R a-x,a+X dir/ | Remove execute from files, keep on directories |
chmod -R g=u dir/ | Make group permissions match owner recursively |
Common Patterns
| Command | Description |
|---|---|
chmod +x script.sh | Make a script executable |
chmod -R 755 /var/www/html | Web server document root permissions |
chmod 600 .env | Protect environment/config files |
chmod 700 ~/.ssh | Secure SSH directory |
chmod 644 ~/.ssh/authorized_keys | SSH authorized keys file |
stat -c '%a %n' file | View current numeric permissions of a file |
ls -la | List files with permissions in symbolic format |
umask 022 | Set default permissions for new files (results in 644/755) |
📖 Free, searchable command reference. Bookmark this page for quick access.