How to manage Linux file permissions
· Category: Linux
Short answer
Use chmod to change permissions and chown to change ownership of files and directories.
Steps
- Change permissions numerically:
chmod 755 script.sh
- Change permissions symbolically:
chmod u+x script.sh
- Change owner:
chown user:group file.txt
- Recursively change:
chmod -R 755 /path/to/dir
Tips
- Numeric: read=4, write=2, execute=1. Sum them for each class.
umasksets default permissions for new files.- Use
ls -lto inspect current permissions.
Common issues
chmod -R 777is insecure; prefer minimal necessary permissions.- Only root can change ownership to another user.