chmod 700 (rwx------)
Full access for the owner and none for anyone else. On a directory it puts everything inside out of reach of other accounts, whatever the modes of the files within.
This tool runs in your browser. We never send what you type or paste to a server.
What chmod 700 sets
| Who | Digit | Read | Write | Execute | Symbolic |
|---|---|---|---|---|---|
| Owner (u) | 7 | yes | yes | yes | rwx |
| Group (g) | 0 | no | no | no | --- |
| Others (o) | 0 | no | no | no | --- |
chmod 700 file # numeric
chmod u=rwx,go= file # the same, in symbolic form
ls -l shows this mode as -rwx------ on a file and drwx------ on a directory. On a file, execute means it can be run as a program. On a directory, read lists the names inside, write creates, renames and deletes entries, and execute (search) is what lets you enter it and reach the files inside.
A 700 directory protects everything in it
To open /home/ana/notes/todo.txt a process needs execute (search) permission on every directory along that path. Take it away at one level and nothing below can be reached by name, even files that are themselves 644 or worse.
That makes 700 on a directory the cheapest way to make a whole tree private: one chmod, no recursion. Remember that the protection belongs to the directory. A file moved out of it keeps its own, possibly looser, mode.
Where 700 is used
~/.ssh. The OpenSSH manual recommends read, write and execute for the user and no access for others.- Private working directories: backups, database dumps, key material, a home directory on a machine you share. Directories made with
mktemp -dare created this way. - Scripts for your eyes only, such as one with a token written into it. A file that is not run directly has no use for the execute bits and should be 600.
When 700 is too tight
Services that run as another user are shut out with everyone else. A web server cannot serve ~/public_html out of a 700 home directory, and a backup agent under its own account cannot read it.
- If outsiders need to pass through to something public further down, use 711: they can traverse the directory but not list it.
- If one service or team needs to read it, put them in the directory's group and use 750.
Commands
mkdir -m 700 ~/private # private from the moment it exists
chmod 700 ~/.ssh
chmod -R go= ~/private # also strip group and others from everything inside
umask 077 # this shell now creates files as 600, directories as 700
stat -c '%a %n' ~/.ssh # GNU/Linux
stat -f '%Lp %N' ~/.ssh # macOS and BSD
Avoid chmod -R 700. It works, but it marks every file in the tree as executable. chmod -R go= removes other people's access and leaves your own bits as they were.
700 compared with its neighbours
Questions
What permissions should ~/.ssh and the files in it have?
The directory 700. Private keys, authorized_keys and config 600. Public keys (.pub) can be 644. Your home directory must also not be writable by the group or by others, or sshd will ignore authorized_keys.
What is the difference between chmod 700 and 755?
With 755 everyone on the system can list the directory and read or run what is inside, subject to each file's own mode. With 700 only the owner can get in at all. Use 755 for things meant to be shared or served, 700 for things that are yours alone.
Can root or sudo users get into a 700 directory?
Yes. Root is not bound by these permission checks, so an administrator, or anyone who can use sudo to become root or the owner, can read everything inside. 700 keeps out the other ordinary accounts and services on the machine.