CHMOD is a Unix/Linux command and file-permission model that controls read ®, write (w), and execute (x) access for three classes: owner (user), group, and others. Permissions can be shown symbolically (e.g., rwxr-xr–) or numerically (octal) where r=4, w=2, x=1 and each class’s sum gives a digit (e.g., 754 → owner=7 rwx, group=5 r-x, others=4 r–).
Common uses:
- chmod 755 file — make file executable by owner and readable/executable by group and others.
- chmod 644 file — readable/writable by owner, readable by group and others (common for web files).
- chmod -R 700 dir — recursively set private access to a directory.
Special bits:
- Setuid (4xxx) — executes file with owner’s privileges.
- Setgid (2xxx) — new files inherit group; on directories, files inherit group.
- Sticky bit (1xxx) — on directories, users can only delete their own files (e.g., /tmp: 1777).
Quick mapping:
- Symbolic: u+r, g-w, o+x, u=rw
- Octal examples: 777 (rwxrwxrwx), 644 (rw-r–r–), 600 (rw——-), 2755 (setgid + 755)
Security tips:
- Avoid 777 for writable web directories.
- Use 644 for static web files and 755 for directories/executable scripts unless tighter restrictions are needed.
- Be cautious with setuid binaries and apply least privilege.
If you want, I can convert specific symbolic permission strings to octal (or vice versa) or provide a small reference table.
Leave a Reply