Linux file permissions and chmod explained
Understand read, write and execute bits, octal modes such as 755 and 644, directories, special bits and umask, with worked examples.
By the tools4free.dev team · Last reviewed 4 December 2026
Every file on a Linux or other POSIX system has three sets of permission bits: one for the owner, one for the owning group and one for everyone else. Each set can allow read, write and execute. chmod changes those bits, and you can write them as a three-digit octal number such as 755 or as symbolic text such as u+x.
Reading the output of ls -l
Run ls -l and the first column shows ten characters:
-rwxr-xr-- 1 alice devs 2048 Dec 4 09:30 deploy.sh
drwxr-x--- 2 alice devs 4096 Dec 4 09:12 reports
The first character is the file type: - for a regular file, d for a directory, l for a symbolic link. The next nine characters are three groups of three, in the order owner, group, others. In deploy.sh, the owner alice has rwx (read, write, execute), members of devs have r-x (read and execute), and everyone else has r-- (read only).
How the octal numbers work
Each permission has a value: read is 4, write is 2 and execute is 1. You add the values for each class to get one digit. Three classes give three digits.
| Digit | Binary | Symbols | Meaning |
|---|---|---|---|
| 0 | 000 | --- | No access |
| 1 | 001 | --x | Execute only |
| 2 | 010 | -w- | Write only |
| 3 | 011 | -wx | Write and execute |
| 4 | 100 | r-- | Read only |
| 5 | 101 | r-x | Read and execute |
| 6 | 110 | rw- | Read and write |
| 7 | 111 | rwx | Full access |
So 754 is owner 7 (4+2+1, rwx), group 5 (4+1, r-x) and others 4 (r--), which is exactly the -rwxr-xr-- shown above.
Worked example 1: making a script runnable
You have just copied a shell script onto a server and need to run it.
$ ls -l backup.sh
-rw-r--r-- 1 alice alice 312 Dec 4 10:00 backup.sh
$ ./backup.sh
bash: ./backup.sh: Permission denied
$ chmod u+x backup.sh
$ ls -l backup.sh
-rwxr--r-- 1 alice alice 312 Dec 4 10:00 backup.sh
$ chmod 755 backup.sh
$ ls -l backup.sh
-rwxr-xr-x 1 alice alice 312 Dec 4 10:00 backup.sh
The file started at 644 (rw-r--r--), which has no execute bit, so the shell refused. u+x added execute for the owner only. 755 then set the exact result in one step: owner rwx, group and others r-x. Use u+x when you want to change one thing and keep the rest; use the number when you want a known final state.
Symbolic mode
Symbolic mode has three parts: who (u owner, g group, o others, a all), an operator (+ add, - remove, = set exactly) and the permissions (r, w, x). You can combine clauses with commas.
chmod g+w notes.txt # let the group write
chmod o-rwx secrets.env # remove all access for others
chmod a+r readme.txt # everyone can read
chmod u=rwx,g=rx,o= tool # same as 750
chmod -R u+rwX,go+rX site/ # capital X: see below
The capital X means "set execute only if the item is a directory or already has execute for someone". It is the safe way to fix a whole tree, because it opens directories without making every data file executable.
Directories are different
The three bits mean something else on a directory:
- Read (
r) lets you list the names inside. - Write (
w) lets you create, rename and delete entries inside. This needs execute as well. - Execute (
x) lets you enter the directory and reach the files in it by name.
A directory with r-- and no x is a trap: you can see the file names but cannot open any file or read its details. That is why directories are normally 755 or 750, never 644. Deleting a file depends on the permissions of the directory that contains it, not on the file's own permissions.
Worked example 2: a shared project folder
A team in the group devs needs to share /srv/project. Everyone in the group should create and edit files, and other users should have no access. New files should belong to the group, not to whichever user created them.
sudo chgrp -R devs /srv/project
sudo chmod -R u+rwX,g+rwX,o-rwx /srv/project
sudo chmod g+s /srv/project
The last command sets the setgid bit on the directory. Files created inside then inherit the group devs. The directory shows as drwxrws---: the lowercase s in the group execute position means setgid is on and execute is also on. In octal that directory is 2770.
Special bits: setuid, setgid and sticky
A fourth, leading octal digit holds three special bits.
| Bit | Value | On a file | On a directory |
|---|---|---|---|
| setuid | 4000 | Runs with the file owner's user ID | Ignored on Linux |
| setgid | 2000 | Runs with the file's group ID | New files inherit the directory's group |
| sticky | 1000 | Historically ignored on files | Only a file's owner (or the directory owner or root) can delete or rename it |
The classic examples are /usr/bin/passwd, which is setuid root so ordinary users can update their password entry (-rwsr-xr-x, mode 4755), and /tmp, which is 1777 and shown as drwxrwxrwt. Everyone can create files in /tmp, but the sticky bit stops them deleting each other's files.
umask: the default permissions
New files start from 666 and new directories from 777, then the process's umask removes bits. With the common umask 022, a new file is 644 and a new directory is 755. With 027, a new file is 640 and a new directory is 750. With 077, new files are 600 and directories 700. Files are not created executable by default, which is why scripts need an explicit chmod.
Common mistakes
- Using
chmod 777to make an error go away. It lets every user on the system modify the file. Find out which user needs access and grant exactly that, usually through group ownership. - Running
chmod -R 755on a whole tree. It marks every data file executable. Usefindto treat files and directories separately:find . -type d -exec chmod 755 {} +andfind . -type f -exec chmod 644 {} +. - Making an SSH private key too open. OpenSSH refuses to use a private key that other users can read, with a warning about an unprotected private key file. Use
chmod 600 ~/.ssh/id_ed25519andchmod 700 ~/.ssh. - Confusing owner with permissions.
chmodchanges the mode.chownchanges who owns the file. A permission problem is often an ownership problem. - Forgetting the path. A file can be
644and still unreadable if a parent directory lacks execute for you. - Using a number with the wrong digits.
chmod 75 fileis read as075, which gives the owner nothing. Always write three digits, or four with a special bit.
Frequently asked questions
What does chmod 644 mean?
Owner can read and write (6), group can read (4) and others can read (4). It is the usual mode for ordinary files.
What is the difference between 755 and 775?
The only change is the group digit: 5 is read and execute, 7 adds write. Use 775 when a group needs to modify the contents of a directory.
Does root ignore permissions?
Mostly. Root can read and write any file regardless of the mode bits, but still needs at least one execute bit set to run a regular file as a program.
How do I see the octal value of a file?
Run stat -c '%a %n' file with GNU coreutils. On macOS or BSD use stat -f '%Lp %N' file.
Try it: tick boxes and see the octal and symbolic result in the chmod calculator.