The chmod command changes the mode bits of files and directories. Normally, only the file owner or a process with the necessary privilege can make this change. Inspect the current mode with ls -l before and after running chmod.
Permissions · Lesson 2
Modifying Permissions
Learn how to change Linux permission bits with symbolic and octal `chmod` modes.
Using Symbolic Mode
A symbolic mode states which permission class to change, how to change it, and which permissions are involved.
uselects the owner class.gselects the group class.oselects the other class.aselects all three classes.+adds permissions,-removes them, and=sets the selected class exactly.
For example, add execute permission for the owner:
$ chmod u+x myfile
Remove write permission from the group:
$ chmod g-w myfile
Add write permission for both the owner and group:
$ chmod ug+w myfile
Multiple clauses can be separated with commas. This command sets the owner to read and write, the group to read only, and other to no permissions:
$ chmod u=rw,g=r,o= myfile
If the class is omitted, as in chmod +x myfile, the process umask affects which classes are changed. Naming the class explicitly makes the intended result easier to review.
Which symbolic mode removes group write permission without changing the other group bits?
Using Octal Mode
An octal mode sets each basic permission triplet with a digit. Add these values within each class:
4for read2for write1for execute0for no permissions
The three rightmost digits represent owner, group, and other in that order. For example:
$ chmod 755 myfile
The mode 755 expands as follows:
- Owner
7is4 + 2 + 1, orrwx. - Group
5is4 + 1, orr-x. - Other
5is4 + 1, orr-x.
Unlike + or - symbolic operations, an octal mode supplies the complete ordinary permission set. A later lesson covers the optional leading digit used for special mode bits.
Which octal value represents read permission?
What ordinary permissions does chmod 640 report set?
Applying Changes Safely
Grant only the access that users and services require. Avoid using chmod 777 as a troubleshooting shortcut because it grants read, write, and execute to every class, often creating more risk without addressing ownership, directory traversal, ACLs, or service policy.
Recursive changes deserve extra care. Preview the target tree, account for symbolic links and mounted filesystems, and test on a small scope before using chmod -R. After a change, verify the resulting mode rather than assuming the command affected the intended objects.
Why is chmod 777 usually a poor general fix for an access problem?
For hands-on practice in an isolated environment, use the Linux User Group and File Permissions lab and inspect each mode before and after changing it.
Lesson complete
You finished Modifying Permissions
You can now change ordinary Linux mode bits with deliberate chmod expressions.
Use symbolic mode for targeted additions, removals, or assignments.
Build octal digits from read
4, write2, and execute1.Read octal classes in owner, group, and other order.
Verify changes and apply the least privilege needed.
Keep your learning progress
Create a free account to save this lesson and continue learning on any device.
Create a free account