Linux File Permissions

Master Unix/Linux permissions, ACLs, and access control security

Understanding Linux Permissions

Permission Model

Linux uses a discretionary access control (DAC) model with three permission types:

PermissionOctal ValueDescription
Read4View file contents, list directory contents
Write2Modify file data, add or remove entries in a directory
Execute1Run a file as a program, enter and traverse a directory
Permission Entities
EntitySymbolDescriptionExample Command
Owner (User)uThe file ownerchmod u+w file
GroupgGroup memberschmod g-x file
OthersoEveryone elsechmod o+r file
AllaAll three entitieschmod a+x file
Reading Permission Output
-rw-r--r-- 1 user group 1024 Dec 1 10:00 file.txt
  • - : File type (- = file, d = directory, l = link)
  • rw- : Owner permissions (read, write, no execute)
  • r-- : Group permissions (read only)
  • r-- : Others permissions (read only)
Directory vs. File Permissions
$ ls -ld projects scripts.sh drwxr-x--- 2 alice devs 4096 Jan 10 09:00 projects -rwxr-xr-- 1 alice devs 512 Jan 10 09:00 scripts.sh
  • projects is a directory: members of devs can enter and list the folder, everyone else denied.
  • scripts.sh is a file: owner and group can run it, others can only read.
Common Scenarios
Use CaseExample PathPermissionsMeaning
Team project config file/srv/app/config.yaml640Owner can change it, group can read, everyone else blocked.
Private notes directory~/notes700Only you can open the directory or list files.
Shared scripts folder/opt/tools755Everyone can run scripts, but only owner can modify.
Upload dropbox/srv/uploads733Owner has full control; others can enter and create files but not list contents.
Practice: Decode the Permissions

Review each string and decide who can read, write, or execute. Think about files versus directories and how the bits combine.

Permission StringInterpretation Prompt
-rw-r-----Who can modify this file? What does the group have?
drwxr-x---Can non-team members enter this directory?
-rwxr-xr--Is this safe to run as a shared script?

Common Permissions

OctalSymbolicUse Case
755rwxr-xr-xExecutable files, directories
750rwxr-x---Team scripts, private services
644rw-r--r--Regular files
640rw-r-----Configs readable by group
600rw-------Private files (SSH keys)
700rwx------Private directories
664rw-rw-r--Group-editable files
777rwxrwxrwxAvoid! Security risk
2775rwxrwsr-xShared project directories (SGID)
1777rwxrwxrwtTemp directories (sticky bit)

⚠️ Security Tips

  • Never use 777 permissions
  • SSH keys must be 600
  • Home directories: 700 or 750
  • Web files: not writable by web server
  • Review SUID/SGID files regularly