chmod 700
Only the owner can read, write and execute, or in the case of a directory get in at all. The mode for ~/.ssh and other private directories.
| Read (4) | Write (2) | Execute (1) | Digit | |
|---|---|---|---|---|
| Owner | 7 | |||
| Group | 0 | |||
| Others | 0 |
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, write and execute. Group and others have no access.
chmod 700 filechmod u=rwx,g=,o= fileCommon values
What 700 allows
| Who | Digit | On a file | On a directory |
|---|---|---|---|
| Owner | 7 rwx | read, change and run | list, enter, add and remove files |
| Group | 0 --- | nothing | nothing |
| Others | 0 --- | nothing | nothing |
ls -l shows this mode as -rwx------ on a file and as drwx------ on a directory.
The owner can do everything and nobody else can do anything. On a directory that means others can't even see which files it holds.
Where it belongs
~/.ssh. The directory with your keys is normally 700. The SSH server can refuse to use theauthorized_keysfile in it when the directory can be written to by others.- A private directory. Whatever the modes of the files inside, other accounts can't reach them, because they can't get past the directory.
- Scripts with something to hide, such as a backup script that contains a password.
Next to 755 and 750
755 lets everyone in to read, 750 only the group, 700 nobody. Home directories show that the choice is a matter of taste: some Linux distributions create them as 755, others as 750 or 700.
A plain file that doesn't have to be executed is better off with 600.
The chmod calculator explains how the digits are built, and what setuid, setgid and the sticky bit add to them.