Unix File Permissions Explained (chmod 755, 644)
chmod 755 = rwxr-xr-x (owner: all, group: read+execute, others: read+execute). chmod 644 = rw-r--r--. Each octal digit is the sum of read (4), write (2), and execute (1). Three digits set permissions for owner, group, and others respectively.
Permission Number Reference
| Number | Letters | Meaning |
|---|---|---|
| 7 | rwx | Read + Write + Execute |
| 6 | rw- | Read + Write |
| 5 | r-x | Read + Execute |
| 4 | r-- | Read only |
| 2 | -w- | Write only |
| 1 | --x | Execute only |
| 0 | --- | No permissions |
Common chmod Values
| chmod | Symbolic | Use Case |
|---|---|---|
755 | rwxr-xr-x | Directories, executables, scripts |
644 | rw-r--r-- | Regular files (HTML, CSS, images) |
600 | rw------- | Private keys, credentials |
700 | rwx------ | Private directories (.ssh) |
777 | rwxrwxrwx | Everyone can do everything (avoid!) |
Examples
# Set file permissions
chmod 644 index.html
chmod 755 deploy.sh
chmod 600 ~/.ssh/id_rsa
# Check permissions
ls -la file.txt
# -rw-r--r-- 1 user group 1234 Apr 11 12:00 file.txt
# Symbolic mode
chmod u+x script.sh # Add execute for owner
chmod go-w file.txt # Remove write for group and others
Frequently Asked Questions
How do Unix permission numbers work?
Each digit is the sum of: read (4) + write (2) + execute (1). Three digits represent owner, group, and others. So 755 means: owner=7 (rwx), group=5 (r-x), others=5 (r-x).
Why should I never use chmod 777?
chmod 777 gives everyone read, write, and execute access. This is a security risk because any user on the system can modify or execute the file. Use the minimum permissions necessary.