chmod 755: what rwxr-xr-x means and when to use it

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 755 sets the permissions rwxr-xr-x: the owner can do everything, and everyone else can read and run but not change. It is the usual mode for directories and for programs and scripts that other users must be able to run.

The chmod calculator shows it like this:

Octal      755
Symbolic   rwxr-xr-x   (ls -l: -rwxr-xr-x)
Command    chmod 755 file

  owner   7  read  write  execute
  group   5  read         execute
  others  5  read         execute

How to read the digits

Each digit is the sum of read (4), write (2) and execute (1), for the owner, the group and the others in that order. So 7 = 4 + 2 + 1 (all three), and 5 = 4 + 1 (read and execute, no write).

When 755 is right

  • Directories. Execute on a folder means “may enter it”. A folder at 755 lets everyone list and enter it, but only the owner can add or delete files in it. This is the default result of the common umask 022.
  • Scripts and binaries that several users run: /usr/local/bin/backup.sh, a compiled program, a CGI script.
  • The web root and its folders, so that the web server (a different user) can read them.

When it is wrong

  • Plain data files such as .html, .css, .jpg or .json: they need no execute bit. Use 644.
  • Anything private: a key, a password file, an .env. Use 600 or 700 so other users cannot even read it.
  • Folders that a team writes into. Group members need the write bit: see 775.

The recursive mistake

chmod -R 755 . applies the same mode to files and folders alike. Every data file becomes executable, which is untidy at best and a risk when uploads are served. Set the two kinds separately:

find . -type d -exec chmod 755 {} +
find . -type f -exec chmod 644 {} +

Another way is the capital X in symbolic mode: chmod -R u=rwX,go=rX . gives execute only to folders and to files that already had it.

Make a script executable

A new script usually starts as 644, so running it gives Permission denied. Add the execute bit for the owner with chmod u+x script.sh, or use chmod 755 script.sh when others must run it too. If the problem is the opposite, a web server answering 403 Forbidden, check that the folders on the path have the execute bit.

Other common modes: 644 for files, 777 for the one you should avoid, 700 for private folders.

Frequently asked questions

What does chmod 755 mean?

The owner can read, write and execute (7), the group can read and execute (5), and everyone else can read and execute (5). In ls -l it shows as rwxr-xr-x. Nobody except the owner can change the file.

Is 755 safe for a web server?

For directories and for programs that must run, yes: it is the standard. For ordinary files such as HTML, CSS and images, 644 is better, because they do not need to be executable.

Why does a folder need the x bit?

For a directory, execute means 'may enter and reach the things inside'. Without it nobody can open files in that folder even if the files themselves are readable. That is why folders are 755 and not 644.

What is the difference between chmod 755 and chmod u=rwx,go=rx?

None. They set the same bits. The numeric form is shorter, and the symbolic form says what you mean and is easier to read in a script.

More in this reference