Understanding chmod and Linux File Permissions

chmod changes file and directory permissions in Linux. It is useful when a script cannot execute, a file is too open, or a service needs access to a path.

Make a script executable

chmod u+x script.sh

This adds execute permission for the file owner only.

Common numeric permissions

chmod 644 file.txt
chmod 755 script.sh
  • 644: owner can read/write, others can read
  • 755: owner can read/write/execute, others can read/execute

Be careful with recursive changes

chmod -R 755 /path/to/directory

Use recursive permission changes carefully. Always confirm the path first, especially when working as root.

Leave a Comment