AI Hints
Home›Linux Tutorial›Changing Permissions
Linux · Lesson 65 of 120

chmod with Letters

U+x, g-w, o-r.

⏱ 2 min read▶ Video at 1:24:51🎓 Free
Watch this lesson in the Linux courseWatch on YouTube ↗Full Linux course

CH mod, short for change mode, changes a file's permissions. The friendliest way to use it is with letters, that read almost like a sentence.

chmod with Letters
From the video: chmod with Letters
  • chmod changes permissions
  • Use letters
  • Reads like a sentence

Who, plus or minus, what

ACH mod rule has three parts. Who it's for, U for the user, G for the group, O for others, or A for all. Then plus, to add, or minus, to remove. Then which permission, R, W, or X. So U plus X means, give the owner execute permission.

Whou, g, o, or a
+ or -add or remove
Whatr, w, or x
u+xowner may execute

Adding and removing

Our hello script can't be run yet. There's no X. CH mod U plus X adds execute for Sam. Now the first group shows RWX. Then CH mod O minus R removes read permission from others. The last group is all dashes now.

Terminal
ls -l projects/scripts/hello.sh
-rw-r--r-- 1 sam sam 40 Jan  5 09:00 projects/scripts/hello.sh
chmod u+x projects/scripts/hello.sh
ls -l projects/scripts/hello.sh
-rwxr--r-- 1 sam sam 40 Jan  5 09:00 projects/scripts/hello.sh
chmod o-r projects/scripts/hello.sh
ls -l projects/scripts/hello.sh
-rwxr----- 1 sam sam 40 Jan  5 09:00 projects/scripts/hello.sh

More examples

You can combine rules with commas, like U plus X comma G minus W. A plus R gives read to everyone. And dash R, for recursive, changes a whole folder and everything inside it. Be careful with that one.

keyvalue
u+x,g-wtwo rules at once
a+reveryone can read
go-rwxonly the owner
-Rthe whole folder

Summary

CH mod with letters says who, plus or minus, and what. U plus X makes a file runnable for you. Next, the number form, that you'll see everywhere online.

Key takeaways
  • chmod u+x
  • chmod o-r
  • chmod -R for folders
Next up: chmod with Numbers — 755, 644 and 600