Modifying Permissions
100%

Permissions · Lesson 2

Modifying Permissions

Learn how to change Linux permission bits with symbolic and octal `chmod` modes.

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.

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:

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

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?

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, write 2, and execute 1.

  • 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
Next Lesson
Back to Permissions