Master Linux Permissions: From Basics to Advanced chmod Tricks
This guide explains Linux file permission concepts, including the numeric permission model, owner/group/other breakdown, how to combine permissions, use of the chmod command with examples, ownership symbols, testing permissions for users and directories, and default permission settings derived from umask.
Linux Permission Management
Permission refers to the rights a user has on a specific file; the root (super‑user) has all permissions.
1. Permission categories
Permissions are divided into three parts, each represented by a numeric value:
Read (r) : 4
Write (w) : 2
Execute (x) : 1
No permission (-) : 0
Executing a script == running a script2. Detailed permission information
Permission bits are split into three sections: owner, group, and others.
Example: drwxr-xr-x
d : file type
rwx : owner permissions
r-x : group permissions
r-x : others permissions3. Adding permissions by summing
Using drwxr-xr-x as an example:
Owner : read, write, execute
Group : read, execute
Others: read, execute
rwxr-xr-x is equivalent to 7554. Adding permissions (chmod command)
Command: chmod
Format: chmod [options] permission_expression target
Options:
-R : apply recursively (e.g., chmod -R 755 /path/to/dir)5. Ownership
Owner : u
Group : g
Others : o
Use cases: change only the group permission, e.g.,
chmod g‑r,g+w 1.txt6. Testing permissions for users
Regular users strictly follow the set permissions.
Root user overrides permission restrictions.
Changes take effect after re‑login (e.g., using su or su ‑).
7. Testing permissions for directories
To read a file, the directory must have execute (x) permission and the file must have read (r) permission.
To write a file, the directory needs execute (x) permission and the file needs write (w) permission.
To execute a file, the directory needs read (r) and execute (x) permissions, and the file itself must have execute (x) permission.
8. Default file permissions
Common defaults:
Files : 666 (adjusted by umask)
Directories : 777 (adjusted by umask)
File permission = 666 – umask (default 022) => 644
Directory permission = 777 – umask (default 022) => 755
Useful commands:
/usr/bin/id -un : show username
/usr/bin/id -gn : show group nameSigned-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
