chmod - octal notation

Started by Metgod, January 17, 2003, 09:45:30 PM

Previous topic - Next topic
Note: I remembered something from Attrition and this was the topic of it. But I think it's a valuable thing to learn. Though Brian did give me the idea of writing about this, I have talked to others about it too, and it is pretty well known.


A lot of people who use chmod tend to use alpha notation, so all letters. This works fine because you can even use commas to make more than one change.

But I think everyone should learn octal notation too, as it may be of use sometime.

The numbers can be three digits or four digits. Four digits have a more special purpose and if you are curious, read the man page on chmod (I have attached the man page on Solaris [in plain text -> "man chmod | col -b > chmod.txt"]).

The first digit is the user, the second digit is the group, and the third digit is all others. That is going from left to right, in case there are any confusions there. So in actuality, when you do an ls -l you'll see nine spaces (read, write, and execute for user, then group, then others).


For octal notation, remember these three numbers and their purpose:

4    Read
2    Write
1    Execute (search in directory)

One little problem, though:

What if you want execute and write ? You just add up the appropriate numbers. Execute is 1 and write is 2. Add those up and you get 3.

Do this for each block. It could end up being any digit from 0 to 7.

So it could be 072, where the 0 is the user (no access), 7 is the group (all access), and 2 is other (write).

BTW: for those who don't know, other is anyone that is not the owner and not in the group.  

Met

"My Terminal is my Soul"

When I took my first real job I managed to convince my boss that a Unix seminar would be a really helpful thing for me to attend (I'm not sure how that worked considering that we only used Win2k). At the seminar the lecturer was really good and really knew what she was doing (in my humble opinion) and so this is what she taught us. I did it that way for quite awhile, but I have to admit, I find that the other way is less confusing personally. Still it's fun just to know how to do it! (godaigo with another contentless post for your viewing enjoyment!  :o )
Godaigo
All's fair in Love and Brewing.

the other way.. I assume you mean alpha notation ?

it does work well yes.. with the right syntax you can specify everything.. just ocat is quicker.

there is actually a way to see how octal actually makes sense (binary stuff), I just can't think of it right off hand. :)

it's all preference and I don't care really.. just thought it'd be something of interest.

Met
"My Terminal is my Soul"

Yeah, I think it's definately worthwhile to learn both ways, because lets face it, who knows when (or in what situation) you'll have to work with one or the other. Something that could come up in an interview, just to throw you a curve ball, or you might have to help some total newbie like myself. I think that basically it comes down to the fact that everyone should always be trying to expand their knowledge and level of skill. I mean isn't that the basis of what hacking is all about, regardless of the area?
Godaigo
All's fair in Love and Brewing.

good points, godaigo..

yeah it is.. learn more and more.. expriement, read.. and start at step one again..

int i;
while (i)
{

system("read");
system("experiment");

}

something like that :)

"My Terminal is my Soul"

I don't think I've ever used alpha for chmod... heh... guess once you get used to doing it one way, that's the easiest until you try any other. I never had any reason to use anything other than octal, so... :P
*** Sleep: A completely inadequate substitute for caffeine. ***
01010010010101000100011001001101

hehe yep

why fix something when nothing is wrong.. or how is a better question. :)

Octal is good, alpha is also good at times. Either way, to those who don't use it, this was a way to remember it and see how it actually works.

Met
"My Terminal is my Soul"

so many users mess this up when they first start off... it may be worth it to add the augo, rstw, etc...

I'm not going to recreate the manpage though...

man chmod

Wilnix
alt email address: wilnix@hackphreak.org

SMF spam blocked by CleanTalk