LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Chmod Codes list (https://www.linuxquestions.org/questions/linux-software-2/chmod-codes-list-142654/)

AmdMhz 02-05-2004 11:11 AM

Chmod Codes list
 
Hi all

Anyone have a link to all the Chmod Codes there are and their meanings? I want to copy it in a text file for me.:newbie:

Thanks guys

jtshaw 02-05-2004 11:22 AM

all of them are listed in man chmod, but I will type them out here as well.

I am assuming you don't want the binary codes, though I quite like them, so here are the text codes:

u = user
g = group
o = other (not user or group)
a = all

+ = add permissions
- = remove permissions

r = read
w = write
x = execute
t = sticky bit

so to add read permissiones for people in the files group I would do chmod g+r file.

I think that is it, there might be some other options as well, consult the man page.

AmdMhz 02-05-2004 11:32 AM

Thanks, I guess I didnt make myself very clear. I am confused on the codes this why.

777
644
600

That is pretty much what I am looking for.

Thanks for the other codes though

DrOzz 02-05-2004 11:36 AM

0 == --- == no access
1 == --x == execute
2 == -w- == write
3 == -wx == write / execute
4 == r-- == read
5 == r-x == read / execute
6 == rw- == read / write
7 == rwx == read / write / execute

jtshaw 02-05-2004 11:45 AM

Ya, they are binary codes and the layout is rwxrwxrwx where the 1st rwx is user, 2nd rwx is group, and the 3rd is other. Put a one in the spots you want enabled, a 0 where you want disabled. And then convert the result of each group into decimal. For instance 101 (r-x) = 5.

AmdMhz 02-05-2004 12:00 PM

That just confused me to the point my head hurts. LOL

alar 02-05-2004 12:11 PM

I drew a reference guide to chmod once and I always refer to it:

Code:

OWNER  GROUP  WORLD
r w x  r w x  r w x
1 1 1  1 0 1  1 0 1
  7      5      5 
  |______|_______|
        | 
        755

As long as you can count in binary it makes perfect sense.
This way you can set precise: read, write or execute access levels
to files based on: owner, group or world
where or when ever you want.

So read only would be 100 or 4.

000, 001, 010, 011, 100, 101, 110, 111
0, 1, 2, 3, 4, etc ....


Does this help your head any?
cheers,
alar

DrOzz 02-05-2004 12:12 PM

ok well what he is trying to get across is that you only actually need the following :
1 === execute
2 === write
4 === read

cause he first states that each group has the available permissoins rwx ..
then now he states that if you want the outcome of the results to be for example r-x, which is read access, execute access, but no write access, then to make it a little easier just use 1's and 0's ....
so a - = not enabled
and either a r,w,x in a position means = is enabled

so in our example we have r-x .. so the following is true :
r = enabled (takes a value of 1)
- = write is NOT enabled (takes a value of 0)
x = execute is enabled (takes a value of 1)
so if you put them together you get 101 because the format is rwx .. got it so far :p

so if we look at the chart given above we see that read = 4 and execute = 1 so if we add 4 + 1 we get the answer of 5 ...

another quick example ...
we'll use the following -> --x
so if we break it down
- = read is not enabled (takes a value of 0)
w = IS enabled (takes a value of 1)
x = IS enabled (takes a value of 1)

so you put it together and you get 011 (keep in mind the format of rwx, and also our chart above), and add them together (0 + 2 + 1 = 3) you get the answer of 3 :D


just noticed that someone else got to it before me in explaining this little journey, but with both posts i think you'll get a better understand of what jtshaw was trying to get across ...

Crito 02-05-2004 12:19 PM

It's a bitmask, all possible combinations are represented by a unique number. You really only need to memorize 1, 2 and 4 (if there were more options would then go to 8, 16, 32, etc...) Just add the numbers together for the combinations. It's not that hard.

AmdMhz 02-05-2004 12:26 PM

starting to make sense guys. Thanks. All I need to do is contiune to reread it till it sticks. I love this place. Everyone is so helpful and no one has an attitude about. Thanks for being so cool

Thymox 02-05-2004 07:34 PM

Thanks Alar. That makes it much clearer for me too. I never could grasp the octal representation but I think I have it now. Cheers.

Crito 02-05-2004 11:28 PM

Really should use user, group and other instead of owner, group and world if you don't want to confuse people with things like chmod o+r. A newbie is more likely to think that grants the owner read permission than the world. There's no reason to make it more difficult than it really is IMHO.

jtshaw 02-05-2004 11:52 PM

DrOzz's method of figuring out the codes is great to learn but at some point everyone should be able to convert the oct and hex digits to binary and the reverse in there heads.

Ok, let me rephrase that, anyone who likes to work with computers.


All times are GMT -5. The time now is 09:11 AM.