🎁 New User? Get 20% off your first purchase with code NEWUSER20 Register Now →
Menu

Categories

Linux File Permissions Deep Dive: Everything You Need to Know (2026)

Linux File Permissions Deep Dive: Everything You Need to Know (2026)

Quick Summary: Linux file permissions control who can read, write, and execute files and directories. Every file has three permission sets: owner, group, and others. Permissions are displayed as rwxr-xr-x (symbolic) or 755 (octal). Understanding permissions is critical for server security — misconfigured permissions are one of the most common causes of security breaches and application errors.

Linux file permissions concept

Permission Basics

PermissionSymbolOctalOn FilesOn Directories
Readr4View file contentsList directory contents
Writew2Modify file contentsCreate/delete files in directory
Executex1Run as programEnter (cd into) directory

Reading Permission Strings

The output of ls -la shows permissions like -rwxr-xr--:

  • Position 1: File type (- file, d directory, l symlink)
  • Positions 2-4: Owner permissions (rwx = read+write+execute)
  • Positions 5-7: Group permissions (r-x = read+execute)
  • Positions 8-10: Others permissions (r-- = read only)

Changing Permissions with chmod

Octal (Numeric) Method

OctalPermissionCommon Use
755rwxr-xr-xExecutable scripts, directories
644rw-r--r--Regular files, config files
600rw-------Private files (SSH keys, secrets)
700rwx------Private directories, .ssh/
775rwxrwxr-xShared group directories
666rw-rw-rw-World-writable (avoid on servers!)
777rwxrwxrwxWorld-writable+executable (never use!)

Symbolic Method

  • chmod u+x script.sh — Add execute for owner
  • chmod g-w file.txt — Remove write from group
  • chmod o-rwx private.key — Remove all permissions for others
  • chmod a+r file.txt — Add read for all (a = all)

Changing Ownership with chown

  • chown user file.txt — Change owner
  • chown user:group file.txt — Change owner and group
  • chown :group file.txt — Change group only
  • chown -R www-data:www-data /var/www/ — Recursive

Special Permissions

PermissionOctalSymbolPurpose
SUID4000s in owner executeRun as file owner (e.g., passwd runs as root)
SGID2000s in group executeRun as file group; new files inherit group
Sticky Bit1000t in others executeOnly owner can delete files (used on /tmp)

Access Control Lists (ACLs)

When standard permissions are too coarse, ACLs provide fine-grained control:

  • getfacl file.txt — View ACLs
  • setfacl -m u:username:rw file.txt — Grant read+write to specific user
  • setfacl -m g:developers:rx /var/www/ — Grant read+execute to specific group
  • setfacl -x u:username file.txt — Remove ACL for a user
  • setfacl -R -m g:developers:rx /var/www/ — Apply recursively

Security Best Practices

  • Never use 777 — World-writable executables are a critical security vulnerability
  • SSH keys must be 600 — SSH refuses to use keys with broader permissions
  • Web files: 644, directories: 755 — Standard web server permissions
  • Sensitive config: 600 or 640 — Database passwords, API keys
  • Use groups for team access instead of opening permissions to "others"
  • Audit SUID files regularly: find / -perm -4000 -type f

Frequently Asked Questions

What does "Permission denied" mean?

Your current user does not have the required permission (read, write, or execute) on the file or directory. Check permissions with ls -la, verify ownership with id, and use chmod or sudo as appropriate.

Why does SSH reject my key with "bad permissions"?

SSH requires strict permissions for security: ~/.ssh/ must be 700, ~/.ssh/authorized_keys must be 600, and private key files must be 600. SSH refuses to use files with broader permissions to prevent other users from reading your keys.

What is umask?

umask sets the default permissions for newly created files and directories. The default umask of 022 means new files get 644 and new directories get 755. A umask of 077 means only the owner can access new files (600/700). Check yours with umask, set with umask 027.

Related Resources

Share this article:
Dargslan Editorial Team (Dargslan)
About the Author

Dargslan Editorial Team (Dargslan)

Collective of Software Developers, System Administrators, DevOps Engineers, and IT Authors

Dargslan is an independent technology publishing collective formed by experienced software developers, system administrators, and IT specialists.

The Dargslan editorial team works collaboratively to create practical, hands-on technology books focused on real-world use cases. Each publication is developed, reviewed, and...

Programming Languages Linux Administration Web Development Cybersecurity Networking

Stay Updated

Subscribe to our newsletter for the latest tutorials, tips, and exclusive offers.