chmod 755

chmod 755 is rwxr-xr-x: why directories need it, commands for scripts and trees, and how it differs from 777.

loading chmod 755
About this tool

chmod 755: what it means

chmod 755 gives the owner everything (read, write, execute) and everyone else read and execute. It is the mode of programs, scripts and directories that anyone may use but only one account may change. On a directory the execute bit means "may enter it", which is why folders are almost always 755 rather than 644.

The calculator shows this mode as rwxr-xr-x, and ls -l prints a regular file as -rwxr-xr-x and a directory as drwxr-xr-x. Open the page on that mode and toggle a box to see the number change.

Digit by digit

WhoDigitBitsCan
Owner (u)7rwxread, write, execute
Group (g)5r-xread, execute
Others (o)5r-xread, execute

Each digit adds read = 4, write = 2 and execute = 1. For this mode the command is chmod 755 path, and the umask that produces it on a directory is 022.

Where it is used

  • Directories: the web root and its subfolders must be 755 for the web server to reach the files inside.
  • Executable files: shell scripts, binaries and CGI programs.
  • Folders such as /usr/local/bin, where everyone runs the programs and only root installs them.

Modes usually given to directories and programs

ModeSymbolicWhat it is for
700rwx------Private folder: only the owner enters (such as ~/.ssh).
750rwxr-x---Owner and group enter; others are kept out.
755rwxr-xr-xEveryone may enter or run it; only the owner changes it.
775rwxrwxr-xThe group may change it too: a shared team folder.
1777rwxrwxrwtEveryone writes, but only each file's owner deletes it: /tmp (sticky bit).

The umask that sets the starting mode

New files start from 666 and new directories from 777; the umask removes bits. Computed with the calculator:

umaskNew filesNew directories
022644755
002664775
027640750
077600700

Commands

Make a script executable, and set the mode of a whole tree

chmod 755 deploy.sh
./deploy.sh
find /var/www/site -type d -exec chmod 755 {} +
find /var/www/site -type f -exec chmod 644 {} +

The same with symbolic notation

chmod u=rwx,go=rx deploy.sh
chmod a+x deploy.sh      # adds execute for everyone, keeps the rest

Common mistakes

  • Giving 755 to every file of a site: data files do not need the execute bit, and 755 on uploaded content makes an accidental execution easier. Files are 644.
  • Forgetting that a directory needs x on every level: a 755 file inside a 700 folder is still unreachable for the web server.
  • Setting 755 on a script in a mounted Windows or network volume: those file systems may ignore the mode, so test where the script really runs.

Frequently asked questions

What does chmod 755 mean?

7 is read, write and execute (4+2+1) for the owner; each 5 is read and execute (4+1) for group and others. Written out: rwxr-xr-x.

What is the difference between chmod 755 and 777?

With 777 group and others can also write, so any account on the machine can change or replace the file. 755 keeps writing to the owner, which is almost always what you want.

Why do directories need the execute bit?

On a directory, x means permission to traverse it: to open files inside by name and to cd into it. Read lets you list the names; without x you cannot reach what is inside.

Report a problem