Numeric chmod modes
Set owner read/write, group read, others none
chmod 640 config.env
Example:
chmod 600 ~/.ssh/id_rsa
Make script executable
chmod 755 deploy.sh
Example:
chmod 700 ./scripts
Symbolic chmod modes
Add execute permission for owner
chmod u+x backup.sh
Example:
chmod g-w report.txt
Apply multiple symbolic rules
chmod u=rw,g=r,o= file.txt
Example:
chmod a+r docs.md
Recursive and directory-safe usage
Apply recursively to directory
chmod -R 755 public
Example:
chmod -R u+rwX,g+rX,o-rwx project
Check permission bits
ls -l
Example:
stat -c "%a %n" *
Common mistakes / Pitfalls
- Using chmod -R 777 is insecure and should be avoided on real systems.
- Numeric modes differ for files and directories; execute bit on dirs means traversal.
- Changing permissions without checking ownership can still leave access denied errors.
Last updated: February 2026