Skip to the content

chmod 777

Everyone can read, write and execute. It makes a permission error go away, and it is nearly always the wrong way to do that.

Read (4)Write (2)Execute (1)Digit
Owner7
Group7
Others7

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.

Everyone can read, write and execute.

Others can write: every user and every program on the machine can change this file, or add and remove files if it is a directory. That is rarely the right cure for a "permission denied" error. Giving the file the right owner or group is safer.

chmod 777 file
chmod u=rwx,g=rwx,o=rwx file

Common values

Share this tool:TwitterFacebookLinkedInWhatsAppEmail

What 777 allows

WhoDigitOn a fileOn a directory
Owner7 rwxread, change and runlist, enter, add and remove files
Group7 rwxread, change and runlist, enter, add and remove files
Others7 rwxread, change and runlist, enter, add and remove files

ls -l shows this mode as -rwxrwxrwx on a file and as drwxrwxrwx on a directory.

Every account on the machine, and every program running under any of them, can read the file, overwrite it and run it. On a directory it means that anyone can add, rename and delete files in it, including files that belong to somebody else.

Why it is nearly always the wrong fix

777 usually turns up as the answer to "Permission denied", and it works because it removes the question of who is allowed. The real problem is nearly always that the file belongs to the wrong user or group. A web server that runs as www-data can't write to a directory you own, for example. The fix that fits is to hand the directory to the account that needs it and to keep the mode tight:

chown -R www-data:www-data uploads
chmod 755 uploads

On a server the difference matters. With 777, any program that can be tricked into writing a file can put it wherever it likes, and the same mode lets that file be run.

The places where it is right

A directory that every user has to be able to write to, such as /tmp, has 777 together with the sticky bit: mode 1777, so that people can't delete each other's files. And symbolic links show as lrwxrwxrwx in ls -l, which means nothing: what counts are the permissions of the file they point to.

The chmod calculator explains how the digits are built, and what setuid, setgid and the sticky bit add to them.

See all 12