Every file and directory has permissions defined for three categories of users:
| Category | Symbol | Description |
|---|---|---|
| Owner (User) | u |
The user who created the file |
| Group | g |
The group that owns the file (primary group of the creator) |
| Others | o |
Everyone else — not the owner and not in the owner group |
| All | a |
Shortcut meaning u + g + o together |
| Permission | Symbol | Octal | For Files | For Directories |
|---|---|---|---|---|
| Read | r |
4 | Can read the file content | Can list directory contents (ls) |
| Write | w |
2 | Can edit the file | Can add or remove files inside |
| Execute | x |
1 | Can run the file as a program | Can enter the directory (cd) and view permissions (ls -l) |
| No permission | - |
0 | Nothing allowed | Nothing allowed |
ls -ldrwxr-xr-- 2 aliaa aliaa 4096 Dec 14 Desktop
d rwx r-x r--
| | | |
| | | Others permissions
| | Group permissions
| Owner permissions
File type (d=directory, -=file, l=symlink, c=char device, b=block device)
Each of the three permission groups contains exactly 3 characters: r, w, x, or -.
When determining what a user can do, Linux checks in order:
Is the user the OWNER?
YES --> apply OWNER permissions
NO --> Is the user in the OWNER GROUP?
YES --> apply GROUP permissions
NO --> apply OTHERS permissions
-rw-r--r-- aliaa group1 file.txt
| User | Category matched | Permissions |
|---|---|---|
| aliaa | Owner | read, write |
| User in group1 | Group | read only |
| Any other user | Others | read only |
chmod