Permissions · Lesson 2 of 8

Modifying Permissions

0 / 4 checkpoints answered

Full screen ↗

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.

Using Symbolic Mode

A symbolic mode states which permission class to change, how to change it, and which permissions are involved.

  • u selects the owner class.
  • g selects the group class.
  • o selects the other class.
  • a selects 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.

CheckWhich 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:

  • 4 for read
  • 2 for write
  • 1 for execute
  • 0 for 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 7 is 4 + 2 + 1, or rwx.
  • Group 5 is 4 + 1, or r-x.
  • Other 5 is 4 + 1, or r-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.

CheckWhich octal value represents read permission?

CheckWhat 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.

CheckWhy 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.

Summary

You can now change ordinary Linux mode bits with deliberate chmod expressions.

  1. Use symbolic mode for targeted additions, removals, or assignments.
  2. Build octal digits from read 4, write 2, and execute 1.
  3. Read octal classes in owner, group, and other order.
  4. Verify changes and apply the least privilege needed.