ls -l shows ten characters such as -rwxr-xr--. The first is the type; the next three are the owner’s rights, then the group’s, then everyone else’s.
| Bits | Octal | Meaning |
|---|---|---|
r |
4 | read |
w |
2 | write |
x |
1 | execute (or enter a directory) |
chmod 640 app.conf # owner rw, group r, others nothing
chmod u+x deploy.sh # add execute for the owner only
sudo chown app:app /var/lib/app
umask # 0022 by default: new files are 644, directories 755
Never fix a permission problem with chmod 777. Work out which user the process runs as, then give that user or group exactly the access it needs. Special bits exist (setuid 4000, setgid 2000, sticky 1000); /tmp uses the sticky bit so users cannot delete each other’s files.