Correct permissions are the backbone of Linux security. Misconfigured bits can expose secrets, break deployments, or allow privilege escalation. This guide demystifies permission modes, shows how to set secure defaults, and offers checklists you can apply to servers, containers, and developer laptops.
Permissions protect confidentiality (who can read), integrity (who can modify), and availability (who can execute). A leaked .env, a world-writable script, or an executable log file can all turn into incidents.
u/g/o/a with +/-/= (e.g., chmod g-w)755: Directories and executable scripts; owner can write, everyone can execute/read.750: Private executables for team members in the group.644: Text files; owner writes, others read.600: Secrets like SSH keys or .env files.700: Private directories (e.g., ~/.ssh)./usr/bin/passwd). Use sparingly; audit regularly./tmp) prevents deleting others’ files.
Example: chmod 2775 shared/ keeps group ownership consistent.chown user:group file sets ownership; avoid running as root unnecessarily.2775 so files inherit the group.ls -l and stat to ensure ownership matches expectations.640 with service user ownership600, directory 700644, dirs 755; write access only to deploy user700 with least privilegesticky bit on shared locationsUSER app), set 700 for secrets, 755/644 for app code, and avoid world-writable paths.chown -R user:group path and tighten modes.chmod +x script.sh) and correct shebang.find to locate risky files: find . -perm -o=w -type f for world-writable files.find / -perm -4000 -type f.644755 (or 750 inside team dirs)6002775700Use the chmod-calculator to translate between numeric and symbolic modes, visualize permission bits, and avoid risky defaults when deploying code or sharing directories.
755 means: Owner can read/write/execute (7), Group can read/execute (5), Others can read/execute (5). This is the standard permission for directories and executable scripts where the owner needs write access but others only need read/execute.
Use 600 for secret files like SSH keys, .env files, or API keys. This gives only the owner read/write access—no group or others access. The directory containing secrets should be 700 (owner-only access).
The sticky bit (1xxx) on directories prevents users from deleting files they don't own, even if they have write permission to the directory. Common use: /tmp directory where users can create files but can't delete others' files.
/usr/bin/passwd runs as root to modify password files.Use chown user:group filename to change ownership. Example: chown www-data:www-data /var/www/html sets web files to the web server user. Use -R flag for recursive changes on directories.
Check that all parent directories have execute permission (x). To access a file, you need execute permission on every directory in the path. Also verify you're in the correct group if using group permissions.