Linux File Permissions & chmod Command Cheat Sheet

Table of contents
- ๐ 1. Viewing File Permissions
- ๐ง 2. Understanding Permission Types
- โ๏ธ 3. Modifying Permissions with chmod
- ๐ข 4. Numeric (Octal) Permissions with chmod
- ๐งโ๐คโ๐ง 5. Changing Ownership with chown
- ๐ 6. Changing Group with chgrp
- ๐ 7. Apply Permissions Recursively
- ๐ Quick Reference: Symbolic vs Octal
- ๐Quick Reference: Symbolic chmod Commands (No Octal)
- ๐ฎ Extra: Checking Permissions of a File
- Conclusion

Linux file permissions are key to controlling access to files and directories. It allows you to set who can read, write, or execute a file or directory. This guide will help you understand how to view and change these permissions.
The system divides users into:
u
โ user (owner)g
โ groupo
โ others (everyone else)a
โ all (user + group + others)
๐ 1. Viewing File Permissions
ls -l
Sample Output:
-rwxr-xr-- 1 user group 1234 Jul 5 file.sh
Breakdown:
-
โ file (ord
for directory)rwx
โ owner can read, write, executer-x
โ group can read and executer--
โ others can only read
๐ง 2. Understanding Permission Types
Symbol | Meaning | Applies To |
r | Read | View file contents / list dir contents |
w | Write | Edit file / create, delete inside dir |
x | Execute | Run file / enter directory |
โ๏ธ 3. Modifying Permissions with chmod
โ Add Permission
chmod u+x file.sh # Add execute for user
chmod g+w file.txt # Add write for group
chmod o+r file.log # Add read for others
chmod +x file.sh # Add execute for everyone
โ Remove Permission
chmod u-x file.sh # Remove execute from user
chmod g-w file.txt # Remove write from group
chmod o-r file.log # Remove read from others
chmod -x file.sh # Remove execute from everyone
โก๏ธ Set Specific Permissions
chmod u=rwx file.sh # Set user permissions to read, write, execute
chmod go=rw file.txt # Set group and others to read, write only
chmod a=r file.txt # Everyone gets read-only
๐ข 4. Numeric (Octal) Permissions with chmod
Symbolic |
r = 4 |
w = 2 |
x = 1 |
Sum them up for each level:
User Type | rwx | Binary | Octal |
User | rwx | 111 | 7 |
Group | r-x | 101 | 5 |
Others | r-- | 100 | 4 |
๐ง Examples:
chmod 755 script.sh # rwx for user, rx for group and others
chmod 700 secret.txt # rwx only for user (private)
chmod 644 file.txt # rw for user, read-only for others
๐งโ๐คโ๐ง 5. Changing Ownership with chown
chown user file.txt # Change owner
chown user:group file.txt # Change owner and group
Example:
chown ec2-user:ec2-user app.py
๐ 6. Changing Group with chgrp
chgrp groupname file.txt
๐ 7. Apply Permissions Recursively
chmod -R 755 myfolder/ # Apply to all files & subfolders
chown -R user:group myfolder/
๐ Quick Reference: Symbolic vs Octal
Octal | Symbolic | Meaning | chmod Command |
777 | rwxrwxrwx | All permissions for user, group, and others | chmod 777 file |
755 | rwxr-xr-x | Full for user, read & execute for group & others | chmod 755 file |
700 | rwx------ | Full access for user only | chmod 700 file |
644 | rw-r--r-- | Read/write for user, read-only for group & others | chmod 644 file |
600 | rw------- | Read/write for user, no access for group & others | chmod 600 file |
444 | r--r--r-- | Read-only for everyone | chmod 444 file |
400 | r-------- | Read-only for user, no access for group or others | chmod 400 file |
000 | ---------- | No permissions for anyone | chmod 000 / |
๐Quick Reference: Symbolic chmod Commands (No Octal)
These donโt use numbers but letters to modify permissions.
Symbolic Command | Effect |
chmod +x file | Add execute permission for all (user, group, others) |
chmod u+x file | Add execute for user only |
chmod g-w file | Remove write permission from group |
chmod o=r file | Others get read-only access |
chmod a+x file | Add execute for all users (a = u+g+o ) |
chmod u=rwx file | Set user permission to full (read/write/execute) |
chmod go= file | Remove all group and others permissions |
chmod a=rw file | Everyone gets read/write, no execute |
๐ฎ Extra: Checking Permissions of a File
stat file.txt
Output includes:
Access rights in symbolic and numeric
Owner and group
Modification time
Conclusion
Mastering Linux file permissions is essential for effectively managing access to files and directories. By understanding and utilizing the chmod
, chown
, and chgrp
commands, you can control who can read, write, or execute files, ensuring both security and proper access management. Whether you prefer symbolic or numeric (octal) methods, this guide provides a comprehensive overview to help you confidently modify permissions. Proper permission settings are crucial for maintaining system integrity and protecting sensitive data.
Subscribe to my newsletter
Read articles from Jasai Hansda directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Jasai Hansda
Jasai Hansda
Software Engineer (2 years) | In-transition to DevOps. Passionate about building and deploying software efficiently. Eager to leverage my development background in the DevOps and cloud computing world. Open to new opportunities!