chmod, the easy way

christopher j.
2 min readJan 31, 2017

If you think using chmod is arcane and confusing as hell, that’s about to change. Unlike pretty much every web tutorial that focuses on chmod octals, this one will focus on the far easier shorthand syntax.

Instead of using cryptic numbers: chmod 660 file

Learn to use the legible shorthand: chmod g=rw file

…hey, how is that easier?!

You’ll see.

Follow this short tutorial and become a chmod pro.

  1. A file, or directory, has three distinct users:
u = User
g = Group
o = Other (aka. ‘World’)
a = All of the above

2. A file, or directory, has four basic permissions:

  = (blank) None, no permissions
x = Execute
w = Write
r = Read

3. Permissions can be assigned using basic operators:

+ Add 
- Remove
= Equals

4. Almost done. The way it works:

Assign permissions:

u=r    // User can Read, only
g=rw // Group can Read and Write
o= // World has None (‘blank’ assignment)

Add or Remove permissions:

u+x    // Add Execute to User
g-w // Remove Write from Group
o+r // Add Read to World

Multiple assignments, use , :

u=rw,g+w,o=
// User can Read/Write; Add Write to Group; World None

5. Finally, putting it all together on the command line:

chmod u=rwx file
// User has full permissions for this file
chmod g-r file
// Remove Read from Group for this file

chmod u=rw,g+w,o= file
// User has Read/Write; Add Write to Group; World has None

That’s it. So, back to our original example. Give it a try:

chmod g=rw file

Answer: the g group, = has, r read and w write permissions, for this file.

…hey, easy!

Yep. Thanks for reading, and share to bring an end to chmod tyranny.

Bonus points:

Because it’s good to know the chmod octals anyway.

Octals permissions are set using numbers from 0 to 7.

Octal base permissions:

0 = None
1 = Execute
2 = Write
4 = Read

The rest are simply combinations of the base octals:

3 is 1 + 2       // Execute and Write
5 is 1 + 4 // Execute and Read
6 is 2 + 4 // Write and Read
7 is 1 + 2 + 4 // Execute, Write, Read
tip: if the number is odd, it includes Execute

Syntax:

chmod ugo file  //One octal is mapped to each user

Example:

chmod 640 file // ‘6’ User can Read/Write 
// ‘4’ Group can Read
// ‘0’ World has None

That’s it.

$ exit

--

--