DevToolsmith

Chmod 777

chmod 777 sets the permissions to rwxrwxrwx: it gives everyone full read, write and execute access. Here is exactly what that allows on files and directories, when to use it, and the commands to apply it.

Runs 100% in your browser — nothing is uploaded

ClassreadwriteexecuteValue
owner7
group7
others7
Common:
$ chmod 777 file.sh
$ chmod u=rwx,g=rwx,o=rwx file.sh
  • • The owner can read, write and execute.
  • • The group can read, write and execute.
  • • Everyone else can read, write and execute.

What chmod 777 means

WhoDigitLettersOn a fileOn a directory
owner 7 rwx Can read, modify and run Can list files, create, delete and rename files and enter it and open files
group 7 rwx Can read, modify and run Can list files, create, delete and rename files and enter it and open files
others 7 rwx Can read, modify and run Can list files, create, delete and rename files and enter it and open files

Each digit is the sum of read (4), write (2) and execute (1). In ls -l output it looks like this:

$ ls -l
drwxrwxrwx  2 alice  staff  4096 Oct 21 10:30 example-dir
  • The owner can read, write and execute.
  • The group can read, write and execute.
  • Everyone else can read, write and execute.

When to use 777

  • Almost never the right choice
  • Throwaway files on a single-user machine

777 lets every user and every process on the machine change or replace the file, so one compromised service can inject code into another. It is usually a symptom of the wrong owner. If a web server can’t write to a directory, chown www-data:www-data uploads/ with 755, or a shared group with 775, fixes the real problem without opening the file to everyone.

Is chmod 777 safe?

Rarely. Every user and process on the system can modify it. Give the users who need access a shared group instead.

Commands

# One file or directory
chmod 777 path

# Same thing in symbolic form
chmod u=rwx,g=rwx,o=rwx path

# Every directory under a tree (leaves files alone)
find /path/to/dir -type d -exec chmod 777 {} +

# Check the result
stat -c '%a %A %n' path    # Linux
stat -f '%Lp %Sp %N' path  # macOS

Avoid chmod -R 777 on a whole tree: it gives files and directories the same mode. The find form above changes only directories.

Compare with similar modes

ModeSymbolicDifference
775 rwxrwxr-x Gives the owner and group full access, and others read and execute
770 rwxrwx--- Gives the owner and group full access, and others nothing

Other chmod values

775 · 770 · 755 · 751 · 750 · 744 · 711 · 700 · 666 · 664 · 660 · 644 · 640 · 600 · 555 · 500 · 444 · 400 · 000 · 1777 · 2775 · 4755

Need a different combination? Use the Chmod Calculator.

Sources

Spotted a mistake? Email hello@devtoolsmith.com and we’ll fix it.

Frequently asked questions

What does chmod 777 mean?

chmod 777 sets the permissions to rwxrwxrwx. The owner can read, write and execute. The group can read, write and execute. Everyone else can read, write and execute.

Is chmod 777 safe?

Rarely. Every user and process on the system can modify it. Give the users who need access a shared group instead.