3 or 4 digits from 0 to 7.
Common sets
| Who | rread | wwrite | xexecute | Digit |
|---|---|---|---|---|
| Owner | 7 | |||
| Group | 5 | |||
| Others | 5 |
Who can do what
- Octal
- As in ls -l
- Command
- Command, symbolic
-R gives files and directories the same mode, so every file gets the execute right. Directories usually want 755 and files 644, set separately with find -type d and find -type f.
How to use it in three steps
Step by step, with this page's example.
- 01
Tick permissions or type a number, such as 755.
- 02
Read the rwx notation.
- 03
Copy the ready chmod command.
755 for the file script.sh
-rwxr-xr-x
chmod 755 script.sh
chmod u=rwx,g=rx,o=rx script.sh Questions
- What does chmod 755 mean?
- The owner can read, write and execute the file, while the group and others can only read and execute (rwxr-xr-x).
- What does chmod 777 mean and is it safe?
- 777 gives everyone the right to read, write and execute. It is not safe, because any user on the server can change the file, so set the owner properly and use 755 or 644 instead.
- What permissions should files and directories have on a web server?
- Usually 644 for files and 755 for directories. A directory needs the execute bit so that it can be entered, and an ordinary file does not need it.
- How is 755 different from 644?
- 755 lets everyone read and execute and only the owner write. 644 lets nobody execute, so it suits ordinary files.
- What are setuid and the sticky bit?
- Setuid makes a program run with the rights of its owner, setgid makes a directory pass its group on, and the sticky bit on a directory like /tmp lets only a file's owner delete it. They go in an optional leading fourth digit, for example 4755.