Linux File Permissions and chmod Explained
Developer · Published October 7, 2026 · Updated October 24, 2026 · 4 min read
Written by Akinrinmade Michael
On Linux and macOS, every file and folder has permissions that decide who can read it, change it or run it. The chmod command changes them. The numbers look odd at first, but each digit follows one small rule, and once you've seen it you can work out any mode in your head.
Three people, three permissions
Permissions are set separately for three groups of people:
- the owner of the file,
- the group the file belongs to,
- others, meaning everyone else.
Each group can have any mix of three permissions: read (r), write (w) and execute (x). Run ls -l and you'll see them as a string such as -rwxr-xr--.
- rwx r-x r-- | | | +- others: read only | | +------ group: read and execute | +----------- owner: read, write, execute +--------------- file type (- file, d folder)
The octal numbers
Each permission has a value: read is 4, write is 2 and execute is 1. Add them up for each group to get one digit. So rwx is 4+2+1 = 7, r-x is 4+0+1 = 5 and r-- is 4. Three digits give the full set: -rwxr-xr-- is 754.
Here are all eight possible digits, so you never have to add them up from scratch:
| Digit | Permissions | Means |
|---|---|---|
| 0 | --- | Nothing |
| 1 | --x | Execute only |
| 2 | -w- | Write only |
| 3 | -wx | Write and execute |
| 4 | r-- | Read only |
| 5 | r-x | Read and execute |
| 6 | rw- | Read and write |
| 7 | rwx | Everything |
Permissions you'll use most
| Mode | Who can do what | Typical use |
|---|---|---|
644 | Owner reads and writes, everyone else reads | Ordinary files, web pages |
755 | Owner does everything, everyone else reads and runs | Programs, scripts, folders |
600 | Only the owner reads and writes | Private files, SSH keys |
700 | Only the owner can enter and use it | Private folders |
664 | Owner and group read and write, others read | Shared project files |
777 | Everyone can do everything | Almost never; avoid it |
777 is the one people reach for when something "won't work", and it usually hides the real problem. It lets anyone on the machine change the file, and on a web server that can mean anyone who breaks into one site can rewrite the others. Find out which user needs access and give just that user the permission.
Using chmod
chmod 755 script.sh # octal chmod u+x script.sh # symbolic: add execute for the owner chmod go-w file.txt # remove write from group and others chmod a+r notes.txt # everyone can read chmod -R 644 folder/ # apply to everything inside (use with care)
In the symbolic form, the letters before the sign say who (u owner, g group, o others, a all), the sign says what to do (+ add, - remove, = set exactly) and the letters after it say which permissions. Symbolic changes are safer for one-off tweaks because they leave the other bits alone.
Folders are different
On a folder, execute means "allowed to enter it". Without it you can't open the files inside, even if you can list them. That's why folders usually need 755 rather than 644. A common trap with chmod -R 644 is that it strips execute from every folder inside, locking you out of them. Use find to treat files and folders separately, or use the symbolic capital X, which adds execute only to folders and to files that already had it.
Who owns the file matters too
Permissions only make sense next to ownership. A file with mode 600 is private to its owner, but if the wrong user owns it, the right one still can't open it. The chown command changes the owner and group. When a web server can't read a file you uploaded, check the owner before you change the mode.
Special bits
A fourth leading digit sets rarely used special bits: setuid (4) and setgid (2) make a program run with its owner's or group's rights, and the sticky bit (1) on a shared folder like /tmp stops people deleting each other's files. A mode of 1777 is the sticky shared folder, and you'll see a t at the end of its listing.
Errors you'll meet
- Permission denied when running a script: the file is missing execute. Run
chmod u+x script.sh. - SSH refuses your key: private keys must be private. Set the key to 600 and the
.sshfolder to 700. See the guide to SSH keys. - A website returns 403: the web server's user can't read the file or can't enter a parent folder.
Tick the boxes in the Chmod Calculator to get the octal number, symbolic form and the exact command. The number base converter shows how octal digits map to binary.