Understanding Linux Permissions
A clear guide to Linux file permissions, permission categories, numeric modes, and special bits like SUID, SGID, and the sticky bit.
Purpose
Understand how Linux permissions protect files and directories, how to read permission strings, and why special permissions matter for security and collaboration.
Key points
- ›Every file has owner, group, and others permission sets.
- ›Read, write, and execute map to values 4, 2, and 1.
- ›Permissions are shown symbolically (rwx) and numerically (octal).
- ›SUID, SGID, and the sticky bit change runtime behavior and directory deletion rules.
- ›Use ls -l and stat to verify permissions and file type accurately.
Notes
Note 1
Permission categories: user, group, others
Files and directories use three permission sets: user (u) is the file owner, group (g) is the file's associated group, and others (o) is everyone else. This is the basic access model in Linux.
$ ls -l example.txt$ stat -c '%A %a %U %G %n' example.txt
$ ls -l example.txt-rw-r--r-- 1 alice staff 0 Jun 24 14:05 example.txt$ stat -c '%A %a %U %G %n' example.txt-rw-r--r-- 644 alice staff example.txt
Note 2
Permission values: read, write, execute
Each category has three permissions: read (r=4), write (w=2), and execute (x=1). Add them to get the octal mode for each category, for example 7 (4+2+1) means full permissions.
$ chmod 644 example.txt$ ls -l example.txt
$ chmod 644 example.txt$ ls -l example.txt-rw-r--r-- 1 alice staff 0 Jun 24 14:05 example.txt
Note 3
Read symbolic permissions
The first character shows the file type: '-' is a regular file, 'd' is a directory, and 'l' is a symlink. The next nine characters are grouped as owner, group, and others permissions.
$ ls -l /tmp/example.txt$ ls -ld /tmp
$ ls -l example.txt-rw-r--r-- 1 alice staff 0 Jun 24 14:05 example.txtowner: rw- (read/write)group: r-- (read only)others: r-- (read only)
Note 4
Numeric permission examples
Use three digits to set permissions for owner, group, and others. Common modes are 644 for readable files, 755 for executable directories and scripts, and 700 for private files.
$ chmod 755 script.sh$ chmod 700 secret.txt$ stat -c '%a %A %n' script.sh secret.txt
$ chmod 755 script.sh$ chmod 700 secret.txt$ stat -c '%a %A %n' script.sh secret.txt755 -rwxr-xr-x script.sh700 -rwx------ secret.txt
Note 5
Special permissions: SUID, SGID, sticky bit
Special permissions add extra behavior beyond basic rwx. SUID runs an executable with the owner's privileges, SGID inherits a directory's group for new files, and the sticky bit on directories restricts deletion to file owners.
$ chmod u+s /usr/bin/passwd$ chmod g+s /shared/team$ chmod +t /tmp$ ls -ld /usr/bin/passwd /shared/team /tmp
$ ls -ld /usr/bin/passwd-rwsr-xr-x 1 root root 55536 Jun 24 14:05 /usr/bin/passwd$ ls -ld /shared/teamdrwxrwsr-x 2 alice developers 4096 Jun 24 14:05 /shared/team$ ls -ld /tmpdrwxrwxrwt 14 root root 4096 Jun 24 14:05 /tmp
Note 6
How special permission symbols appear
If execute is set and SUID or SGID is present, you'll see 's'. If execute is not set but the special bit is set, you'll see 'S'. The sticky bit appears as 't' when execute is set for others and 'T' when it is not.
$ ls -l /usr/bin/passwd$ ls -ld /tmp
$ ls -l /usr/bin/passwd-rwsr-xr-x 1 root root 55536 Jun 24 14:05 /usr/bin/passwd$ ls -ld /tmpdrwxrwxrwt 14 root root 4096 Jun 24 14:05 /tmp