Thuta Learning
IntermediateDevOps & Toolsbeginner

Changing Permissions with chmod

Relax. We'll talk through this in plain words — no textbook voice.

What you'll walk away with

  • Get comfortable changing permissions with chmod — no need to fear it
  • Practice running the commands yourself in the terminal
  • See how these commands come in handy on a real server or project

Let's think about it this way for a second

You can write chmod (change mode) two ways — Symbolic (u/g/o + +/- + r/w/x) and Numeric (octal 0-7). The numeric method adds up r=4, w=2, x=1 — so 7 = rwx (4+2+1), 6 = rw- (4+2), 5 = r-x (4+1). chmod 755 file.sh means owner=7(rwx), group=5(r-x), others=5(r-x) — the standard pattern of 'I keep full control, everyone else just gets to read/run it' for a script file. With the symbolic method, chmod +x file.sh grants execute permission to owner/group/others all at once — simple and easy to remember.

Let's connect this to a real-world scenario

If you create a .sh script and try running ./script.sh only to get bash: Permission denied, type chmod +x script.sh, and then it'll run fine. If you want a config file readable by nobody but your own user (like a file containing a password), chmod 600 file (owner rw-, group/others get nothing) is the go-to — for SSH key files, if the permissions aren't set correctly, SSH itself will refuse to use them.

Let's try it together in the terminal

bash
echo 'echo hello' > script.sh
./script.sh          # Permission denied
chmod +x script.sh
./script.sh           # hello

chmod 600 secret.txt   # owner ပဲ ဖတ်/ရေးနိုင်
chmod 755 script.sh    # owner all, others read+run
You should see
After chmod +x, running ./script.sh will print hello.

5-Minute Try-It

Create a script.sh file (with an echo command in it). Try running it without chmod first and note the error. Then run chmod +x and try running it again.

A Quick Word of Caution

Don't take the shortcut of using chmod 777 as a 'fix' — it lets anyone read/write/run the file, so you should never do this on a production server.

Easy traps

  • Reaching for chmod 777 (full permissions for everyone) as a lazy 'fix' for errors — this is a major security risk
  • Confusing chmod with the command that changes file ownership (that's chown's job, coming up next chapter)

Now Try It Yourself

Create a script.sh file (with an echo command in it). Try running it without chmod first and note the error. Then run chmod +x and try running it again.

You'll know it worked when: After chmod +x, running ./script.sh will print hello.

Changing Permissions with chmod | Thuta Learning