chmod 644
The owner can read and write, everyone else can only read. The usual mode for ordinary files such as documents, images and web pages.
| Read (4) | Write (2) | Execute (1) | Digit | |
|---|---|---|---|---|
| Owner | 6 | |||
| Group | 4 | |||
| Others | 4 |
A program runs with the rights of the file's owner.
A program runs with the file's group. In a directory, new files get the directory's group.
In a directory, users can't delete or rename each other's files.
Owner can read and write. Group and others can read.
chmod 644 filechmod u=rw,g=r,o=r fileCommon values
What 644 allows
| Who | Digit | On a file | On a directory |
|---|---|---|---|
| Owner | 6 rw- | read and change | see the names, nothing more |
| Group | 4 r-- | read | see the names, nothing more |
| Others | 4 r-- | read | see the names, nothing more |
ls -l shows this mode as -rw-r--r-- on a file and as drw-r--r-- on a directory.
The owner can edit the file, everyone else can read it, and nobody can execute it. A newly created file gets this mode under the common umask of 022.
Where it belongs
Documents, images, HTML and CSS, most configuration files: anything that is data and not a program. A web server only has to read the files it serves, so 644 is the usual mode for the files of a website, with 755 on the directories.
Where it is the wrong mode
- On a directory. Without the execute bit nobody can enter it, the owner included.
lsmay still show the names, and opening anything inside fails. Directories want 755. - On a script.
./script.shanswers "Permission denied" until the execute bit is set, withchmod +x script.shor 755. - On a secret. Everyone with an account on the machine can read a 644 file. Keys and passwords want 600.
The chmod calculator explains how the digits are built, and what setuid, setgid and the sticky bit add to them.