Code BeautifierDev Tools

Linux File Permissions & Chmod Guide

Octal permissions calculation, permission bits (rwx), sticky bits, and chown recipes

Permission Bits & Octal Values

Permissions are calculated by adding user, group, and other octal numbers

Read (r)Permission to open and read file contents or list directory
4 (Binary: 100)
Write (w)Permission to modify file or add/remove directory entries
2 (Binary: 010)
Execute (x)Permission to run script/binary or cd into directory
1 (Binary: 001)
No Permission (-)Access completely denied
0 (Binary: 000)

Standard Everyday Octal Combinations

777 (rwxrwxrwx)Full access to everyone (Security Risk — avoid in production)
chmod 777 file
755 (rwxr-xr-x)Owner full; group and others can read & execute (Standard for web/executables)
chmod 755 script.sh
644 (rw-r--r--)Owner read & write; group and others read-only (Standard for files)
chmod 644 index.html
600 (rw-------)Owner read & write only (Sensitive config files, database credentials)
chmod 600 config.json
400 (r--------)Owner read-only (Required for SSH private keys)
chmod 400 id_rsa

Practical Chmod & Chown Recipes

Make script executableAdds execute bit for all users
chmod +x deploy.sh
Fix web directory permissions recursivelySets 755 on folders and 644 on files
find . -type d -exec chmod 755 {} +
find . -type f -exec chmod 644 {} +
Change file owner and groupRecursively change user and group ownership
chown www-data:www-data -R /var/www/html
Set Sticky Bit on directoryUsers can only delete files they own
chmod +t /tmp/shared_dir