Reading Permissions
Let's learn to read that cryptic ls -l output without thinking twice.
Decoding ls -l
Let's break down each column.
The Permission String
-rw-r--r--
│├─┤├─┤├─┤
│ │ │ └── Others: r-- (read only)
│ │ └───── Group: r-- (read only)
│ └──────── Owner: rw- (read + write)
└────────── Type: - (regular file)
File Types
The first character indicates type:
| Character | Type |
|---|---|
- | Regular file |
d | Directory |
l | Symbolic link |
c | Character device |
b | Block device |
s | Socket |
p | Named pipe |
Notice c for character device (null) and b for block device (sda).
Common Permission Patterns
644 (-rw-r--r--)
Standard for files. Owner can edit, everyone can read.
755 (-rwxr-xr-x)
Standard for executables and directories. Owner has full control, everyone can read and execute.
700 (-rwx------)
Private. Only owner has access.
777 (-rwxrwxrwx)
Avoid 777
Everyone can do everything. Almost never appropriate. If you're using 777 to "fix" a permission issue, you're creating a security hole.
Reading the Other Columns
| Column | Value | Meaning |
|---|---|---|
| Permissions | -rw-r--r-- | File type and access |
| Hard links | 1 | Number of hard links |
| Owner | alice | User who owns the file |
| Group | developers | Group assignment |
| Size | 4096 | Size in bytes |
| Modified | Jan 14 10:00 | Last modification time |
| Name | report.txt | Filename |
Quick Permission Check
stat shows both symbolic (rwx) and numeric (755) formats.
Who Can Do What?
For secret.txt:
- alice (owner): read + write
- Members of developers group: read only
- Everyone else: no access
Can bob access it? Only if bob is in the developers group.
Yes, bob is in developers, so bob gets group permissions (read only).
What does `-rw-------` mean?
Key Takeaways
- First character = file type (-, d, l, etc.)
- Next 9 characters = permissions in groups of 3
- Each group: owner, group, others
- Each position: read, write, execute (or - if denied)
- Common patterns: 644 (files), 755 (executables/dirs), 700 (private)
- 777 is almost always wrong
Next: changing permissions with symbolic mode (chmod u+x).