Overview
Linux file permissions control who can read, write, and execute files and directories. They are fundamental to system security and daily administration.
The Permission Model
Every file and directory has three permission sets:
- Owner (user) — the user who owns the file
- Group — users in the file's group
- Others — everyone else
Each set has three permission bits:
r— read (4)w— write (2)x— execute (1)
Viewing Permissions
$ ls -l file.txt
-rw-r--r-- 1 yora yora 1024 Sep 27 10:00 file.txt
The first character indicates the file type (- for regular file, d for directory). The next nine characters are the permission bits: three for the owner, three for the group, three for others.
In this example: owner has read+write (rw-), group has read-only (r--), others have read-only (r--).
Numeric (Octal) Notation
Permissions can also be expressed as three octal digits:
r = 4
w = 2
x = 1
644 = rw- r-- r--
755 = rwx r-x r-x
600 = rw- --- ---
chmod — Change Permissions
Use chmod to change permissions:
# Symbolic mode
chmod u+x script.sh # add execute for owner
chmod go-w file.txt # remove write for group and others
chmod a+r file.txt # add read for everyone
# Octal mode
chmod 644 file.txt # rw-r--r--
chmod 755 script.sh # rwxr-xr-x
chmod 600 private.key # rw-------
chown — Change Ownership
Use chown to change the owner and group:
chown user file.txt # change owner
chown user:group file.txt # change owner and group
chown -R user:group directory/ # recursive
Why This Matters
Incorrect permissions are a common source of security issues. A world-writable file can be modified by any user. A script with unnecessary execute bits increases attack surface. Understanding permissions is the first step to securing a Linux system.
Practical Defaults
644for regular files755for directories and executable scripts600for private keys and sensitive configuration700for directories containing private data