chmod Calculator
Tick the boxes, or type a number like 755 or a listing like rwxr-xr-x. You get the number, the command and what it allows.
| Who | Read | Write | Execute |
|---|---|---|---|
| Owner | |||
| Group | |||
| Others | |||
| Special |
chmod 755 file
chmod u=rwx,g=rx,o=rx file
The owner can read, write and execute. The group can read and execute. Everyone else can read and execute.
How the numbers work
Each of the three digits is for one group of people: the file's owner, then the file's group, then everyone else. Add 4 for read, 2 for write and 1 for execute. So 7 is all three, 5 is read and execute, and 4 is read only (GNU manual: numeric modes).
On a directory the letters mean something a little different: read lets you list what is in it, write lets you create and remove files in it, and execute lets you reach the files inside (GNU manual: file mode bits).
Common chmod numbers
| Command | Listing | What it allows |
|---|---|---|
chmod 400 | r-------- | Only the owner can read it |
chmod 600 | rw------- | Only the owner can read and change it |
chmod 640 | rw-r----- | Owner reads and writes; the group reads |
chmod 644 | rw-r--r-- | Owner reads and writes; everyone else reads |
chmod 664 | rw-rw-r-- | Owner and group read and write; others read |
chmod 700 | rwx------ | Only the owner can use it |
chmod 750 | rwxr-x--- | Owner does everything; the group reads and runs it |
chmod 755 | rwxr-xr-x | Owner does everything; everyone else reads and runs it |
chmod 775 | rwxrwxr-x | Owner and group do everything; others read and run it |
chmod 777 | rwxrwxrwx | Anyone can read, change and run it |
What chmod 755 means
755 is rwxr-xr-x: the owner can do everything, and everyone else can read and execute but not change it. You will often see it on programs, scripts and directories that others need to use but not edit.
What chmod 777 means, and why to avoid it
777 is rwxrwxrwx: every user on the machine can change the file and run it. On a directory, anyone can add and remove files in it. When something fails with "permission denied", 777 hides the cause and opens the file to everyone. Find out which user needs access, then give that user or its group only what it needs.
The special bits
A fourth digit in front holds three more: 4 is set-user-ID, 2 is set-group-ID and 1 is the sticky bit. A listing shows them where an x would be: s or t when execute is also on, S or T when it is not (GNU manual: what ls lists). On directories, GNU chmod treats the set-user-ID and set-group-ID bits as a special case with short numbers, so check the result with ls -l.
Try it on a real machine
The file permissions lab gives you a task on a real Linux machine in your browser and checks your work. Or open the free Linux terminal and try ls -l and chmod yourself.