Stop 03 · Linux & Windows FundamentalsTopics · 2/10

Linux File Permissions & Users

Part of the Cybersecurity Roadmap

In short

One wrong permission can let any user read password hashes or run a program as root. Reading permission strings quickly is something you'll do in every Linux investigation and pentest lab.

The read/write/execute permission model and user/group structure — misconfigured permissions are a common privilege escalation vector attackers exploit to gain more access than intended.

The blob in a hostel corridor holds up a gold, a silver and a plain key.

Think of it like this

Three keys to a hostel room

The room's owner has a gold key that does everything. Roommates share a silver key that opens the door but not the cupboard. Everyone else in the corridor gets the plain key, or none at all. Linux gives every file the same three sets: owner, group, others.

Watch it happen

Reading -rwxr-x--- line by line

-
0
rwx
1
r-x
2
---
3

1/5ls -l shows a 10-character string. The first character is the type: - for a file, d for a folder.

The big ideas

What you need to know

Users and groups

Every file has one owner and one group. Add people to groups instead of opening files to everyone.

Folders work differently

On a folder, x means you can enter it and r means you can list it. You often need both.

SUID is powerful

A file with the SUID bit runs as its owner. A SUID-root file with a bug can give anyone root.

Least privilege

Give the smallest rights that still work. Secrets like keys should usually be 600: owner only.

See it in code

Walk through the code

bash
1ls -l secret.txt                 # -rw-r--r-- 1 riya devs ... (world readable!)2chmod 640 secret.txt             # owner rw, group r, others nothing3sudo chown riya:devs secret.txt  # set owner and group4chmod 600 ~/.ssh/id_ed25519      # private keys must be owner-only5 6# Audit: list SUID files on your own system7find / -perm -4000 -type f 2>/dev/null

1/3The file was readable by everyone. chmod 640 removes access for others, and chown sets who owns it.

On your own machine, compare the SUID list against what a fresh install normally has. Anything unexpected deserves a closer look.

Save yourself the pain

Common mistakes

Oops

Running chmod 777 to make an error go away.

Do this instead

777 lets anyone change or run the file. Find which user needs access and give only that.

Oops

Leaving backup files like config.bak readable by everyone.

Do this instead

Backups often hold passwords. Give them the same tight permissions as the original.

Your mission

Permission puzzle

~25 min

Quick check

A file has permissions -rw-r--r--. Who can read it?

Go deeper

  1. 1Practice reading a permission string and using chmod/chown to change it.
  2. 2Learn what SUID/SGID bits are and why misconfigured ones are a classic privilege escalation vector.
  3. 3Practice finding files with overly permissive access on a practice VM.

More topics at this stop

Stuck on this topic? Ask an Insider

Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.

Download
InsideEdge