Master Linux File Permissions: Users, Groups, and chmod Commands Explained
This guide explains Linux user types, file ownership categories, symbolic and octal permission representations, and provides step‑by‑step commands (chmod, chown, chgrp) for modifying permissions, owners, and groups on files and directories.
Linux User Classification
Linux defines two main user types: the superuser ( root) who can perform any operation without restriction, and regular users who have limited capabilities. The superuser prompt is #, while a regular user prompt is $.
File Accessor Classification
Access rights depend on three categories of file attributes:
User (u) : the file’s owner.
Group (g) : the group associated with the file.
Other (o) : all remaining users.
File Types and Permission Basics
When listing files with ls -l, the first character indicates the file type (e.g., d for directory, - for regular file, l for symbolic link, b for block device, c for character device, p for pipe, s for socket).
Permissions are shown in three groups (owner, group, other) using the symbols r (read), w (write), and x (execute). A dash ( -) indicates the absence of a permission.
Symbolic Representation
r--: read‑only -w-: write‑only --x: execute‑only rw-: read and write r-x: read and execute -wx: write and execute rwx: read, write, and execute ---: no permissions
Octal Representation
Each permission set can be expressed as an octal digit (read = 4, write = 2, execute = 1). For example:
r-- 4 100
-w- 2 010
--x 1 001
rw- 6 110
r-x 5 101
-wx 3 011
rwx 7 111
--- 0 000Modifying Permissions and Ownership
1) Changing Permissions with chmod
Command format: chmod [options] mode file Options : -R for recursive changes.
Mode syntax can be symbolic (e.g., u+w) or octal (e.g., 664).
Symbolic examples:
chmod u+w /home/abc.txt # add write permission for owner
chmod o-x /home/abc.txt # remove execute permission for othersOctal examples:
chmod 664 /home/abc.txt # owner and group: read/write, others: read
chmod 640 /home/abc.txt # owner: read/write, group: read, others: none2) Changing Owner with chown
Command format:
chown [options] newowner file chown user1 f1 # change owner of f1 to user13) Changing Group with chgrp
Command format: chgrp [options] newgroup file These commands allow precise control over who can read, modify, or execute files and directories in a Linux environment.
Signed-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.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
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.
