chmod 700: private folders and scripts that only the owner can use

Open this example in the tool

Try it in the tool

Chmod Calculator

Translate 755 ↔ rwxr-xr-x ↔ u=rwx,g=rx,o=rx instantly.

chmod 700 is rwx------: the owner can read, write and execute, and nobody else can do anything. It is the mode for private folders and for scripts that only you run.

Octal      700
Symbolic   rwx------   (ls -l: -rwx------)
Command    chmod 700 file

  owner   7  read  write  execute
  group   0
  others  0

Why folders need the x bit

For a directory, read means “list the names inside”, and execute (also called search) means “go in and reach the things inside”. To use ~/.ssh/id_ed25519 a process must have the execute bit on ~ and on ~/.ssh. That is why a private folder is 700 and not 600: with 600 even the owner could not enter it.

Where 700 belongs

  • ~/.ssh: holds your private keys. Use 700 for the folder and 600 for the files inside.
  • ~/.gnupg: gpg warns unsafe permissions on homedir if others can reach it.
  • Private working folders: a ~/private for exports, notes or customer data on a shared machine.
  • Scripts and tools meant only for you: a deploy script that holds credentials.
  • Service data folders owned by a service account, such as a database’s data directory (PostgreSQL requires its data directory to be 700 or 750 and refuses to start otherwise).
  • A home directory, when other accounts on the machine should not look inside. Ubuntu creates homes as 750 since release 21.04, and many other systems use 755; 700 is the strictest choice.

Setting it, and checking the path

chmod 700 ~/.ssh
chmod 700 ~/private
ls -ld ~/.ssh ~/private

The mode of each folder along the way counts. A file at 600 inside a folder at 700 inside a home at 755 is private; the same file in a home that lost its execute bit is unreachable. namei -l ~/.ssh/id_ed25519 prints every step.

Mistakes

  • 700 on something a service must read. A web server running as www-data cannot enter a 700 folder owned by you. Give the service its own folder or use a group with 750.
  • Copying a 700 folder with a tool that resets modes (some zip programs, drives formatted for Windows). Check the result with ls -ld.
  • Believing 700 stops the administrator. Root ignores permissions, so 700 is about other ordinary users only.

Neighbouring modes

For read access to a group, use 750 (rwxr-x---). For a public folder, use 755. If a web page that should be public answers 403 Forbidden, a folder that is 700 on the way is a likely cause. You can enter any mode, such as rwx------ or 750, in the chmod calculator.

Frequently asked questions

What does chmod 700 mean?

The owner can read, write and execute (rwx), the group and everyone else have no access (---). For a folder that means only the owner can list it, enter it and change it.

Should ~/.ssh be 700 or 755?

700. OpenSSH may refuse to use your keys when the folder can be written by others, and there is no reason to let other users list it. The files inside should be 600.

What is the difference between 700 and 600?

The execute bit. For a file that decides whether it can be run; for a folder, whether it can be entered. A private folder must be 700, because 600 would lock out even the owner from reaching the files inside.

What does gpg mean by 'unsafe permissions on homedir'?

The folder ~/.gnupg is open to others. Run chmod 700 ~/.gnupg so that only you can reach your keyring.

More in this reference