LEARN. PRACTICE. EXPLAIN.
Learning paths & interview practiceP
Linux & CLI troubleshooting foundations
LESSON 1 OF 4 · ABOUT 14 MINUTES + EXERCISE

How do directories, ls -la, and chmod permissions work?

THE IDEA

What it is

Unix-like systems organize everything into a single rooted directory tree (/). Every file and directory records an owner, a group, and three permission triads (owner, group, others) for read (r=4), write (w=2), and execute (x=1). Directories require execute permission (x) to traverse into them.

Why you need it

Overly permissive config files expose API secrets to unrelated system users, while missing execute bits prevent deploy scripts and binaries from starting.

How it works

  1. Check where you are with pwd and inspect entries, dotfiles, and permissions with ls -la.
  2. Read the 10-character mode column: file type (-/d) followed by owner, group, and other rwx bits.
  3. Use chmod 600 (or go-rwx) on private secrets and chmod +x (or 755) on scripts.
  4. Verify the updated mode before running or exiting.
Shell

Inspecting and tightening file modes

$ ls -la /etc/app
-rw-r--r-- 1 app app  218 secrets.env   # readable by everyone!
$ chmod 600 /etc/app/secrets.env
$ ls -la /etc/app/secrets.env
-rw------- 1 app app  218 secrets.env   # owner read/write only

$ chmod +x /opt/app/deploy.sh          # grant execute bit

Octal 600 sets rw------- (owner read+write, zero access for group or others). Using chmod 777 to "make a permission error go away" creates a security exposure.

Try the in-browser Linux CLI lab

Practice ls -la, chmod, grep | wc, df -h, df -i, du, lsof, and ss -tulnp against five live troubleshooting missions.

Open Linux CLI lab

Good practices and why

  • Use ls -la so hidden dotfiles (.env, .ssh) and exact permission bits are never overlooked.
  • Grant the narrowest permissions required: 600 for secret files, 644 for normal docs, 755 for shared scripts.

Common mistakes

  • Running chmod 777 when debugging permission denied errors.
  • Forgetting that removing execute (x) on a directory prevents entering it even with read (r).
GUIDED IMPLEMENTATION

Try it yourself

Open Mission 1 in the Linux CLI Lab: inspect /opt/app and /etc/app, make deploy.sh executable, lock secrets.env to 600, and read the README.

What a successful result looks like

ls -la shows -rwxr-xr-x on deploy.sh and -rw------- on secrets.env.

0 / 6000 characters · Saved on this device. Do not include passwords or private data.

Check your understanding

Which chmod setting makes a secret file readable and writable ONLY by its owner?

Answer the understanding check correctly to record exercise completion.

PUT THE IDEA UNDER PRESSURE

Related interview practice

These scenarios add constraints and follow-up questions to the concepts you just learned.

Further reading

Selected primary references · reviewed 2026-10-09. Examples are educational; use your framework’s documented integration guidance when building a deployed system.

AlifBay Prep