Updated: 2026-01-04
Linux file permissions look confusing at first — but they follow a simple, predictable model.
This guide explains who can read, write, or run a file, and shows how to safely use chmod, chown, and sudo without breaking your system.
Copy/paste friendly and beginner-safe.
ls -l
Example:
-rwxr-xr-- 1 alice developers 4096 app.sh
Breakdown:
- rwx r-x r--
| | | |
| | | └─ others (read)
| | └──── group (read + execute)
| └──────── user (read + write + execute)
└────────── file type (- = file, d = directory)
| Permission | File | Directory | |-----------|------|-----------| | read (r) | View contents | List filenames | | write (w) | Modify contents | Create/delete files | | execute (x) | Run file | Enter directory |
A directory without x cannot be entered, even if it’s readable.
chmod u+x script.sh
chmod g-w config.txt
chmod o+r README.md
Meaning:
u = userg = groupo = others+ add, - removechmod 644 file.txt
chmod 755 script.sh
Number meaning:
4 = read2 = write1 = execute| Mode | Meaning | |-----|--------| | 644 | rw-r--r-- | | 755 | rwxr-xr-x | | 600 | rw------- |
Avoid chmod 777. It removes protection and is almost never needed.
chmod +x deploy.sh
./deploy.sh
If you see:
Permission deniedCheck:
ls -l deploy.sh
sudo chown alice file.txt
sudo chown alice:developers project/
sudo chown -R alice:developers project/
Recursive chown on system directories can break your OS.
sudo runs one command as another user (usually root).
sudo apt update
sudo systemctl restart nginx
It does not:
Check sudo access:
sudo -l
ls -ld .
sudo <command>
ls -l file.txt
sudo chown $USER file.txt
| Use case | Permissions |
|--------|-------------|
| Config file | 600 |
| Script | 755 |
| Private dir | 700 |
| Web files | 644 (files), 755 (dirs) |
/bin, /sbin, /lib, /usrchmod changes accesschown changes ownershipsudo grants temporary admin powerIf permissions feel confusing, always start with ls -l — it explains almost everything.