Bekijk de volledige versie : Reading permissions

07-04-2008, 11:36
This is a simple tutorial for any newbie to the asus Wl-700 community

How to read permissions on a Linux system
You will find as you dabble with the linux system a confusion of numbers assigned to change permissions and then the permissions write out in the form rwx rwx rwx owner user etc.....

Assignment values are 4 for read, 2 for write and 1 for execute.

so if you wanted to only have the user of a file execute it
the command you will use will be 700
giving u rwx --- --- owner users filename as the out put.

Below the make up of assigned numbers and then use the chmod command

rwx rwx rwx
4+2+1 4+2+1 4+2+1
7 7 7


24-04-2008, 09:31
Personally I prefer NOT to use the XXX (e.g. 755) syntax, as you might overwrite permission flags that already were fine as they were... Besides calculation failures might happen.. :(

The chmod command allows you to use a (from my point if view) better syntax which allows better reading and setting delta's (see the examples below for more clarity)

chmod [who][operator][permission] file/directory
(More syntaxes are possible but I wanted to keep it "simple" at first)

u User
g Group
o Other
a All

- Take away permissions
+ Add permissions
= Assign permissions absolutely

r read permission
w write permission
x execute permission
(And the special permissions that need a bit more knowledge:
l mandatory locking
s user or group set-ID
t sticky bit
X execute permission if the file is a directory or if there is execute
permission for one of the other user classes)

So if you want to give your mp3 files a read permission for the user (owner) without changing the other permissions you would do something like:
chmod u+r *.mp3

To remove write for Other:
chmod o-w *.mp3

To remote read/write/execute for other:
chmod o-rwx *.mp3

To add read/write for user/group and add read for other:
chmod ug+rw,o+r *.mp3

To SET (removes permissions when not in set) read/write for user/group and read for other:
chmod ug=rw,o=r *.mp3

For clarity, a chmod 770 would be:
chmod ug=rwx,o= *.mp3

and a cgmod 775 would be:
chmod ug=rwx,o=rx *.mp3

BETTER would be the following, as an execute bit on the mp3 doesn't make sense and it would only set the execute when it's a directory or already have it:
chmod ug=rwX,o=rX *.mp3

How this doesn't confuse some people, but calculating bits... I find it old fashioned!

Anyway, there is always the man page (man chmod) which will help too!! :p