What is chmod?
chmod (change mode) is the command that sets a file’s permissions on Unix-like systems such as Linux and macOS. Every file has three sets of permissions: for its owner, for its group, and for everyone else (others). Each set says whether they may read it (r), write it (w) and execute it (x). On a directory, execute means search: getting to the files inside.
Source The Open Group · POSIX.1-2024, chmod: extended description (octal modes) ↗The Open Group · POSIX.1-2024, 4.7 File Access Permissions ↗
How to calculate chmod permissions
Each digit of the number is one set of permissions, added up from read = 4, write = 2 and execute = 1. The first digit is the owner, the second the group and the third everyone else. ls -l writes the same thing as letters, with - for a permission that isn’t given.
Here it is with your numbers:
- Owner rwx: 4 + 2 + 1 = 7.
- Group r-x: 4 + 0 + 1 = 5.
- Others r-x: 4 + 0 + 1 = 5.
It means 755 and rwxr-xr-x are the same permissions, and chmod 755 file sets them.
Source The Open Group · POSIX.1-2024, ls: standard output (the mode letters) ↗
Special permissions: setuid, setgid and sticky
A fourth digit in front adds three special bits: set-user-ID = 4, set-group-ID = 2 and sticky = 1. Set-user-ID and set-group-ID make a program run with the file owner’s user ID or the file’s group ID instead of yours. On a directory, the sticky bit means only a file’s owner, the directory’s owner or an administrator can delete or rename files in it. In the letters, they replace the x: s (or S without execute) for the owner and group, t (or T) for others. So 4755 is rwsr-xr-x and 1777 is rwxrwxrwt.
A 3-digit number such as 755 sets the fourth digit to 0, which clears set-user-ID and set-group-ID on regular files; whether it does so on directories is up to the system.
Source The Open Group · POSIX.1-2024, <sys/stat.h> file mode bits ↗The Open Group · POSIX.1-2024, exec: set-user-ID and set-group-ID on execution ↗The Open Group · POSIX.1-2024, 4.5 Directory Protection ↗
Chmod examples
Tap a number to see it worked out.
| Number | Letters | Who can do what |
|---|---|---|
| 777 | rwxrwxrwx | The owner, group and others read, write and execute. |
| 775 | rwxrwxr-x | The owner and group read, write and execute, and others read and execute. |
| 755 | rwxr-xr-x | The owner read, write and execute, and the group and others read and execute. |
| 750 | rwxr-x--- | The owner read, write and execute, the group read and execute, and others do nothing. |
| 700 | rwx------ | The owner read, write and execute, and the group and others do nothing. |
| 666 | rw-rw-rw- | The owner, group and others read and write. |
| 664 | rw-rw-r-- | The owner and group read and write, and others only read. |
| 644 | rw-r--r-- | The owner read and write, and the group and others only read. |
| 640 | rw-r----- | The owner read and write, the group only read, and others do nothing. |
| 600 | rw------- | The owner read and write, and the group and others do nothing. |
| 400 | r-------- | The owner only read, and the group and others do nothing. |
| 1777 | rwxrwxrwt | The owner, group and others read, write and execute. |
| 2775 | rwxrwsr-x | The owner and group read, write and execute, and others read and execute. |
| 4755 | rwsr-xr-x | The owner read, write and execute, and the group and others read and execute. |
FAQs
What is the difference between 777 and 755 permissions?
Write permission for the group and others. 777 (rwxrwxrwx) lets everyone read, write and execute the file; 755 (rwxr-xr-x) lets only the owner write, while the group and others can read and execute.
Source The Open Group · POSIX.1-2024, chmod: extended description (octal modes) ↗
What does 777 mean in chmod?
Read, write and execute for everyone: the owner, the file’s group and all other users. Each 7 is read (4) + write (2) + execute (1).
What does chmod 775 mean?
rwxrwxr-x: the owner and the group can read, write and execute; everyone else can read and execute but not write.
Source The Open Group · POSIX.1-2024, ls: standard output (the mode letters) ↗
What does chmod 644 mean in Linux?
rw-r--r--: the owner can read and write, and the group and everyone else can only read. Nobody can execute it.
What are 755 and 644 permissions?
755 is rwxr-xr-x and 644 is rw-r--r--. In both, only the owner can write. The difference is execute (x): 755 lets everyone run the file as a program, or, for a directory, search it to reach the files inside; 644 lets nobody.
Source The Open Group · POSIX.1-2024, 4.7 File Access Permissions ↗
What are chmod 700 permissions?
rwx------: the owner can read, write and execute, and the group and others get no access at all.
Source The Open Group · POSIX.1-2024, chmod: extended description (octal modes) ↗
Sources
- The Open Group: POSIX.1-2024, chmod: extended description (octal modes)
- The Open Group: POSIX.1-2024, ls: standard output (the mode letters)
- The Open Group: POSIX.1-2024, <sys/stat.h> file mode bits
- The Open Group: POSIX.1-2024, 4.7 File Access Permissions
- The Open Group: POSIX.1-2024, 4.5 Directory Protection
- The Open Group: POSIX.1-2024, exec: set-user-ID and set-group-ID on execution