Linux file permission controls who can read, write, or execute a file or directory. For a system administrator, permission is one of the most important security and troubleshooting concepts.
Simple explanation
Every file has an owner, a group, and permission bits. These bits decide whether the owner, group, and others can read, write, or execute it.
Why it matters
Wrong permissions can break websites, expose secrets, block services, or allow attackers to modify files.
Real VPS example
If WordPress cannot upload images or Nginx returns permission denied, the root cause is often file ownership or permission.
What breaks if you ignore it
You may use chmod 777 to fix a symptom and create a serious security hole.
System Administrator Operating Notes
Core principle, commands, verification, troubleshooting, rollback, and cloud/security connection.
Foundation
Skill Level
foundation
System Layer
security
Core Principle
File permission defines who can read, write, and execute files or directories. It protects the system while allowing services to work.
Mental Model
Think of files as locked rooms. Owner, group, and others are three visitor groups. Read, write, and execute are the allowed actions.
When To Use
Use this when fixing upload errors, permission denied errors, script execution errors, SSH key issues, web root access, or config protection.
Wrong Assumption
Beginners often think chmod 777 is a quick fix. It usually means they do not understand the actual owner, group, and service user.
Commands
Command Goal
Inspect permission, owner, group, and service user before changing anything.
Primary Command
ls -lah; stat filename; namei -l /path/to/file; chmod 644 file; chmod 755 directoryCommand Breakdown
ls shows permission and owner. stat gives detailed mode. namei checks every directory in a path. chmod changes permission bits.
Safe Check Command
whoami; id; ps aux | grep nginx; ls -lah /var/www; namei -l /var/www/halfbrain.netExpected Output
Files should usually be 644, directories 755, sensitive config files more restricted, and service users must have the minimum required access.
Verify Command
ls -lah PATH; stat PATH; sudo -u www-data test -r PATH; sudo -u www-data test -w PATHTroubleshooting
Common Failures
Permission denied, wrong owner, wrong group, missing execute bit on directory, over-open 777 permission, SSH key rejected, or config file exposed.
Log Files
/var/log/nginx/error.log; /var/log/syslog; journalctl -u nginxDebug Commands
namei -l PATH; stat PATH; getfacl PATH; ps aux | grep SERVICE; sudo -u USER test -r PATHRoot Cause Map
Trace the path from top directory to file, identify service user, compare required action, then change the smallest permission possible.
Fix Pattern
Fix owner first, then group, then permission. Avoid chmod 777. Verify using the same user that the service uses.
Risk & Recovery
Risk Level
high
Backup Before Change
Before changing permissions, record ls -lah, stat output, current owner, current group, and the exact path affected.
Rollback Plan
Restore the previous owner and mode using chown and chmod, then reload or restart only the affected service if needed.
Blast Radius
High. Wrong permissions can take down a website, expose secrets, or allow unauthorized writes.
Security Note
Never give public write permission to web roots or config files. Protect wp-config.php, SSH keys, database dumps, and environment files.
Strategic Value
Cloud Connection
Cloud images, containers, shared volumes, and managed disks all depend on correct permission and ownership models.
Automation Opportunity
Create a permission audit script that checks web roots, config files, SSH keys, and writable directories against a baseline.
Interview Value
Permission troubleshooting appears in Linux, WordPress, web server, and security interviews.
Related Concepts
chmod, chown, umask, ACL, www-data, SSH keys, Nginx permission denied, WordPress uploads