I had to draw this up for a co-worker today. I didn’t want to waste his time with metaphors and other nonsense. I wanted it to ‘click’. He wanted to know how drwx------
came out to ‘700’. This is what I came up with.
Examples
Linux permissions are displayed in 10 characters, like this:
drwxrwxrwx
The first character is the type of resource. Here are 3 common types you might encounter.1
File | f |
Directory | d |
Link | l |
The last nine are really groups of three.
User | Group | Other |
---|---|---|
rwx | rwx | rwx |
rwx
have integers attached to them.
Letter | Function | Value |
---|---|---|
r | Read | 4 |
w | Write | 2 |
x | Execute | 1 |
How it adds up
rwx = 7 | because | 4 + 2 + 1 = 7 |
rw- = 6 | because | 4 + 2 = 6 |
r-x = 5 | because | 4 + 1 = 5 |
Full Example:
drwxr-xr-x
Type | User | Group | Other |
---|---|---|---|
d | rwx | r-x | r-x |
7 | 5 | 5 |
1Special thanks to cantonboy329. I re-phrased this so that it can be accurate without going into too much detail.
Well, that was easy.