File permissions · modechmod 777rwxrwxrwx

What chmod 777 (rwxrwxrwx) means, who is allowed to do what, and when these permissions are used: do not use: full access for absolutely everyone.

Open in the calculator
Class by classfile or directory
7
Owner
Read the contents, change and save it, run it.
7
Group
Read the contents, change and save it, run it.
7
Others
Read the contents, change and save it, run it.
When and why

Any user on the system can change or replace the file. It gets set «to make it work» — and then it works for outsiders too; 755 or 644 is what is actually needed.

chmod 777 — full access for everyone
Any user on the system can read, change and run it. 755 or 644 is almost always enough — 777 is not the answer.
Mode
Octal777
Symbolicrwxrwxrwx
ls -l line-rwxrwxrwx
Command
chmod 777 file
01

What breaks

777 hides the cause instead of fixing it

Authentication refused: bad ownership or modes for directory /home/user/.ssh

It gets set «to finally make it work», and it usually does — because the real problem was the file's owner, not its mode. After that any user on the system can change the file, and sshd answers such permissions with a refusal. The right order is the opposite: chown to the correct user first, and only then 755 or 644.

02

Easily confused with

755rwxr-xr-x

what is almost always needed instead: the owner edits, everyone else reads and enters.

chmod 755
644rw-r--r--

the same for an ordinary file — without execution.

chmod 644
1777rwxrwxrwt

if shared writing really is needed: the sticky bit forbids deleting other people's files, as in /tmp.

chmod 1777
03

Commands for this case

chown -R www-data:www-data /var/www/site

this is almost always what was needed instead of 777

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

restore sane permissions after a 777

Work out other permissions

The calculator opens on this mode: checkboxes, octal and symbolic notation, an ls -l line and the ready command.

Open the calculator on this modeAll common modes

Updated

«» added to favorites