Linux File Permissions and chmod Explained
Developer · October 7, 2026 · 2 min read
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.
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 will 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.
Permissions you will use most
644: owner can read and write, everyone else can read. The usual setting for files.755: owner can do everything, everyone else can read and run. For programs and folders.600: only the owner can read and write. For private files such as SSH keys.700: only the owner can enter and use the folder.777: everyone can do everything. Avoid it, because anyone on the system can change the file.
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 -R 644 folder/ # apply to everything inside (use with care)
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 is why folders usually need 755 rather than 644.
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.
Tick the boxes in the Chmod Calculator to get the octal number, symbolic form and the exact command.