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

  1. Change permissions numerically:
chmod 755 script.sh
  1. Change permissions symbolically:
chmod u+x script.sh
  1. Change owner:
chown user:group file.txt
  1. Recursively change:
chmod -R 755 /path/to/dir

Tips

  • Numeric: read=4, write=2, execute=1. Sum them for each class.
  • umask sets default permissions for new files.
  • Use ls -l to inspect current permissions.

Common issues

  • chmod -R 777 is insecure; prefer minimal necessary permissions.
  • Only root can change ownership to another user.