What chmod 666 means
| Class | Digit | Permissions |
|---|---|---|
| Owner | 6 | read and write |
| Group | 6 | read and write |
| Others | 6 | read and write |
Warning: anyone on the system can modify this file. World-writable permissions are almost never correct on a server โ prefer 755 for directories and 644 for files.
chmod 666 file.txt # one file
find /var/www -type f -exec chmod 666 {} + # all files in a tree
How octal permissions work
Each digit is the sum of read (4), write (2) and execute (1) for owner, group and others. So 7 = 4+2+1 = rwx, 5 = 4+1 = r-x, 4 = r--. An optional leading digit sets special bits: setuid (4), setgid (2) and sticky (1) โ e.g. 1777 is /tmp.
Safe defaults for web servers
- Directories: 755
- Files: 644
- Secrets (.env, SSH keys): 600
- Laravel
storage/andbootstrap/cache/: 775 with the web server group โ never 777.