DEVESSENTIALS

chmod 777 — what does it mean?

777 removes every permission check except 'does this account exist'. It is the most common answer on forums for a 'Permission denied' error, and it does make the error go away, by letting every local user and every running service modify the file. On a single-user laptop that is mostly harmless; on a server it turns any bug in any process into write access to your code. The real fix is almost always to correct the owner or group, then grant the one missing bit.

In plain English

777

rwxrwxrwx

Every user on the system can read, modify, delete (inside a directory) and execute it.

Symbolic equivalent: chmod u=rwx,g=rwx,o=rwx uploads/

Open 777 in the chmod calculator

What each digit in 777 means

Each octal digit is the sum of read (4), write (2) and execute (1) for one class of users. The digits are, in order, the file's owner, the file's group, and everyone else.

ClassDigitSumr w xls -l
Owner (u)74 + 2 + 1rwxrwx
Group (g)74 + 2 + 1rwxrwx
Others (o)74 + 2 + 1rwxrwx
  • Owner: can list the names of entries, create, rename and delete entries and enter the directory and open files by name.
  • Group: can list the names of entries, create, rename and delete entries and enter the directory and open files by name.
  • Others: can list the names of entries, create, rename and delete entries and enter the directory and open files by name.

When to use chmod 777

  • Short-lived debugging on a throwaway VM or container to confirm that a problem really is permissions. Revert immediately.
  • Almost nothing in production. Shared temporary directories such as /tmp are 1777 (with the sticky bit), not 777.
  • Symbolic links always show lrwxrwxrwx. That is normal: Linux ignores a symlink's own mode and checks the target's permissions.

Security risks and gotchas

Any process can replace your code

If a PHP app, a Node service, or a plugin with a file-upload bug runs as any user on the box, a 777 directory lets it write a web shell or overwrite your scripts. A 777 script run by cron or root is a privilege-escalation path: anyone can change what root executes.

Any user can delete other users' files

Write on a directory means the right to create, rename and delete entries, regardless of who owns the files. That is exactly why /tmp uses 1777: the sticky bit restricts deletion to each file's owner.

chmod 1777 /shared/tmp

Tools will refuse to work

sshd ignores authorized_keys when ~/.ssh or your home directory is group- or world-writable (StrictModes). Many daemons and package managers also refuse world-writable config or plugin directories.

Commands

Instead of 777: fix the owner

sudo chown -R www-data:www-data /var/www/html/uploads
chmod 755 /var/www/html/uploads

If the web server needs to write, make it the owner (or the group) rather than opening the directory to everyone.

Instead of 777: a shared group

sudo chgrp -R devs /srv/shared
chmod 2775 /srv/shared

Members of devs can write; others can only read. The leading 2 (setgid) makes new files inherit the devs group.

Find world-writable files to clean up

find / -xdev -type f -perm -0002 2>/dev/null
find / -xdev -type d -perm -0002 ! -perm -1000 2>/dev/null

The second command lists world-writable directories that lack the sticky bit, which are the dangerous ones.

Docker volume 'Permission denied'

sudo chown -R 1000:1000 ./data

Match the UID the container runs as (check with docker exec <c> id) instead of chmod 777 on the bind mount.

How to check for 777

# Symbolic view
ls -ld uploads/
drwxrwxrwx  2 deploy deploy  4096 Oct 16 09:12 uploads/

# Octal view (Linux / GNU coreutils)
stat -c '%a %A %n' uploads/
777 drwxrwxrwx uploads/

# Octal view (macOS / BSD)
stat -f '%Lp %Sp %N' uploads/

The first character of the ls -l output is the file type (- regular file, d directory), followed by the nine permission characters. stat -c %a prints the octal mode directly; it only shows a fourth leading digit when setuid, setgid or the sticky bit is set.

Related chmod modes

Try variations of 777 in the chmod calculator, browse all chmod modes, or read Linux file permissions explained for chown, umask and ACLs.

Frequently Asked Questions

Is chmod 777 ever OK?▾

On a disposable test machine to confirm a permission problem, briefly. In production, practically never: use the right owner with 755/644, a shared group with 775/664, or 1777 for a shared scratch directory.

How do I undo chmod -R 777?▾

Reset directories and files separately: find DIR -type d -exec chmod 755 {} + and find DIR -type f -exec chmod 644 {} +. Then restore execute on real scripts (chmod +x) and tighten secrets to 600 or 640. If it was a system directory such as /etc or /usr, restoring from backup or reinstalling packages is safer.

What is the difference between 777 and 1777?▾

Both let everyone create files in the directory. With 1777 the sticky bit is set, so users can only delete or rename their own files. /tmp and /var/tmp use 1777 for this reason.