What does chmod do?
On Linux, macOS and other Unix-like systems, every file and folder has permissions that say who can read it, change it and run it. The chmod command, short for change mode, sets those permissions. Getting them right matters for security: a file that is too open can be changed by the wrong person, and one that is too closed can break a website or a script.
Permissions are given to three groups of users: the owner of the file, the group the file belongs to, and everyone else (others). Each group can have read (r), write (w) and execute (x) permission.
How to use the chmod calculator
- Tick the read, write and execute boxes for the owner, the group and others.
- Read the octal number, such as 755, and the symbolic form, such as -rwxr-xr-x.
- Optionally set the setuid, setgid or sticky bit.
- Type your file name and copy the generated chmod command.
- Or work backwards: type an octal value and see which boxes it ticks.
How octal permissions work
Each permission has a number: read is 4, write is 2 and execute is 1. Add them up for each group. Read and write is 4 + 2 = 6. Read, write and execute is 4 + 2 + 1 = 7. Three digits describe owner, group and others, so 755 means the owner can read, write and execute (7), while the group and others can read and execute (5).
On a folder, execute means permission to enter the folder, and read means permission to list its contents. That is why folders are normally 755 and ordinary files 644.
Common permission settings
- 644: owner reads and writes, everyone else reads. A normal file on a web server.
- 755: owner has full access, everyone else can read and run. Normal for folders and scripts.
- 600: only the owner can read and write. Used for private keys and secrets.
- 700: only the owner has any access. Used for private folders.
- 777: everyone can do everything. Avoid it on servers, because any user or process can change the file.
Setuid, setgid and the sticky bit
A fourth digit in front of the three can add special bits. Setuid (4) makes a program run with the permissions of its owner, and setgid (2) does the same for the group or makes new files in a folder inherit its group. The sticky bit (1) on a shared folder, such as /tmp, means users can delete only their own files. A shared folder with the sticky bit is written 1777. These bits have security consequences, so use them carefully.
Example: fixing a web server permission error
If a website returns a 403 Forbidden error after you upload files, the web server user often cannot read them. Setting files to 644 and folders to 755 fixes most cases and keeps them safe, because only the owner can change them. Use find with -type f and -type d to set files and folders separately instead of running a single recursive chmod. Never fix a permission problem by setting everything to 777, because that lets any user on the server change your code.
Octal digits and what they mean
| Digit | Permissions | Meaning |
|---|---|---|
| 0 | --- | No access |
| 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 | Read, write and execute |
Frequently Asked Questions
What does chmod 755 mean?
The owner can read, write and execute. The group and others can read and execute.
What does chmod 644 mean?
The owner can read and write. The group and others can only read.
Is chmod 777 safe?
No. It gives everyone full access and is a common security mistake on servers.
How do I make a script executable?
Run chmod +x script.sh, or chmod 755 script.sh to set the full permissions.
How do I change permissions for a whole folder?
Use chmod -R with a value, but be careful, because files and folders usually need different permissions.
What is the difference between chmod and chown?
chmod changes who can do what with a file. chown changes who owns it.
Is anything uploaded?
No. The calculator works in your browser.