Permission Basics
-rwxr-xr-x 1 user group 4096 Feb 22 file.txt
│├─┤├─┤├─┤
│ │ │ └── Others: read + execute
│ │ └───── Group: read + execute
│ └───────── Owner: read + write + execute
└─────────── Type: - file, d directory, l symlink
Octal Notation
| Number | Permission | Meaning |
7 | rwx | Read + Write + Execute |
6 | rw- | Read + Write |
5 | r-x | Read + Execute |
4 | r-- | Read only |
0 | --- | No permission |
Common chmod Values
| Command | Meaning | Use Case |
chmod 755 file | Owner: full, Others: read+exec | Scripts, executables |
chmod 644 file | Owner: read+write, Others: read | Regular files |
chmod 600 file | Owner only: read+write | SSH keys, secrets |
chmod 700 dir | Owner only: full access | Private directories |
chmod 777 file | Everyone: full access | Almost never use this! |
Symbolic Notation
chmod u+x file # Add execute for owner
chmod g-w file # Remove write from group
chmod o=r file # Set others to read only
chmod a+r file # Add read for all
chmod u=rwx,go=rx file # Same as 755
Ownership
chown user file # Change owner
chown user:group file # Change owner and group
chown -R user:group dir/ # Recursive