Linux · Lesson 9 of 14
Linux users & file permissions
Understand Linux users, groups and permissions: read rwx, convert to 755 and 644, and use chmod and sudo safely. Includes an interactive chmod calculator.
⏱ 17 min🎯 Beginner🧪 Hands-on practice🎬 Video
By the end, you’ll be able to…
- Read a permission string like -rwxr-x--- and say who can do what
- Convert between rwx letters and numbers (chmod 644, 755, 600)
- Explain sudo, root and the principle of least privilege
Key words
- User
- An account on the system. Each file has an owner user.
- Group
- A set of users who share access to files.
- rwx
- Read, write and execute permissions.
- chmod
- The command that changes a file’s permissions.
- sudo
- Run one command as an administrator, after proving it’s you.
- Least privilege
- Give each person or program only the access it needs, nothing more.
Why permissions exist
Linux was built for many people sharing one computer. Permissions stop one user reading another’s files, and stop normal programs from changing the system. In security, permission mistakes are one of the most common ways small problems become big ones.
Reading ls -l
$ ls -l
-rw-r--r-- 1 student student 220 Dec 3 10:02 notes.txt
-rwxr-x--- 1 student devs 812 Dec 3 10:05 deploy.sh
drwx------ 2 student student 4096 Dec 3 10:07 private
The first column is the important one. Split it into four parts:
- Type:
-is a file,dis a directory,lis a link. - r = read, w = write, x = execute (run it, or for folders, enter it). A dash means “not allowed”.
So deploy.sh can be read, written and run by student; read and run by anyone in the devs group; and nothing at all for everyone else.
Permissions as numbers
Each letter has a value: r = 4, w = 2, x = 1. Add them up for each group of three:
| Number | Letters | Typical use |
|---|---|---|
644 | rw-r--r-- | Normal files: you edit, everyone reads |
600 | rw------- | Private files, like SSH keys |
755 | rwxr-xr-x | Programs and folders others may use |
700 | rwx------ | Your private scripts and folders |
777 | rwxrwxrwx | Almost never right. Anyone can change it |
Changing permissions with chmod
chmod 600 secrets.txt # numbers: set exactly
chmod u+x backup.sh # letters: add execute for the owner
chmod go-w shared.txt # remove write from group and others
chmod -R 755 public_html/ # -R = apply to everything inside (careful!)
To change who owns a file, use chown (usually needs sudo): sudo chown student:devs deploy.sh.
root and sudo
root is the superuser and can do anything: read every file, delete the whole system. Daily work should never happen as root. Instead, sudo lets an approved user run one command as root:
$ sudo apt update
[sudo] password for student:
Treat every sudo as a moment to pause and ask: do I understand exactly what this does?
Least privilege
The principle of least privilege means giving every user and program only the access it needs. If a web server only needs to read its files, it shouldn’t be able to write them. Then if it’s ever compromised, the attacker inherits very little power. This one idea shows up everywhere in security, from Linux files to cloud accounts.
If you see advice to “just chmod 777 it” to fix an error, that’s a red flag. It makes the file writable by every user and program on the system. Find out who actually needs access instead.
🧪 Hands-on
Practice
Calculator: click the boxes or type a number and watch both forms update.
Missions: fix permissions on the practice machine.
🎬 Watch
Video: Introduction to Linux – Full Course for Beginners
Video by freeCodeCamp, hosted on YouTube. It loads only when you press play.
✅ Check yourself
Quick quiz
🔗 Go further
Trustworthy resources
- chmod manual page Every option, explained.
- Linux Journey: Permissions Look for the Permissions chapter.
- OverTheWire: Bandit Several levels test your permission skills.