View Single Post
Old 24. May 2009, 04:18 PM   #4 (permalink)
Senior Member
debtboy's Avatar
Join Date: May 2009
Location: ~/
Posts: 128
Default Permissions

Thanks for the positive feedback,
I've never tried explaining this stuff before.


here is a typical example of a ls -l listing:
drwxr-xr-x 2 debtboy users 4096 2009-05-23 20:17 Documents

d This character means directory, you might see - (file), l (link) or d (directory)

Now you have 3 sets of 3 permissions each, always in the exact same order.
The 3 permissions are rwx (Read, Write, Execute) and they can be in any combination, the - hyphen means you don't have this permission.

rwx The first set of 3 are owner permissions, if you created the file you are the owner.

r-x The second set of 3 are group permissions, everyone in the group will have these permissions unless your the owner which gives you additional permissions.

r-x The third 3 are other permissions, I like to think of these permissions as everyone else.

In the listing above you have the owner debtboy
then you also have the group users
so you can determine who has what permissions
(no who is on first , what's on second Ha! Ha! Ha!)

There are 3 basic manipulation commands:
chown Which changes the owner
chgrp Which changes the group
chmod Which can change permissions for all 3 (owner, group, other)

We are only worried about permissions in this post so:
There are different ways use chmod so I will go over how I use it.
Permissions equate to numbers (octal actually)
r equates to a 4
w equates to a 2
x equates to a 1

I give 3 numbers after chmod the first for the owner, the second for the group and the third for other.

Just add up the equated numbers of the permissions you wish to grant.

For example (using the same listing above):

chmod 777 Documents would produce:

chmod 724 Documents would produce:
drwx-w-r-- (not your typical permissions but a good example)

The 7 is really rwx or (4 read + 2 write + 1 execute)
A 6 is really rw- or (4 read + 2 write)
A 5 is really r-x or (4 read + 1 execute)
A 4 is really r-- or (4 read)
A 3 is really -wx or (2 wite + 1 execute)
A 2 is really -w- (2 write)
A 1 is really --x (1 execute)
A 0 is really --- or no permissions

All permissions can be manipulated by the user root (all powerful OZ!!)

This was just a basic overview of permissions (no extended details to confuse),
I'll show 4 images in my next post,
sometimes a picture is worth a thousand words.
debtboy is offline   Reply With Quote