LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   chmod (https://www.linuxquestions.org/questions/linux-newbie-8/chmod-358786/)

bruse 08-31-2005 07:29 AM

chmod
 
shell i know the option 4777 or 4775.

these are frequently used by some guys.

jtshaw 08-31-2005 08:11 AM

I'm not sure exactly what your question is here... but I can tell you what those mean.

Lets start by ignoring the first number (the 4) and taking the last three numbers.

The first of the last three numbers is the "owner permission", the 2nd of the last three numbers is the "group permission", and the last number is "others" or "world".

There are three bits of importance for each number. The Read, Write, and Execute bits.

100 binary (aka 4 in decimal) means read only.
010 binary (aka 2 in decimal) means write only.
001 binary (aka 1 in decimal) means execute only.

To give multiple permissions you just add them. 110 (or 6, aka 4+2) means read and write. 101 (or 5) means read and execute. 111 (or 7) is read, write, and execute. These aren't all the combinations, but you get the idea.

So, 777 means the files owner, group, and others can read, write, and execute the file. 775 on the other hand means the files owner and group can read, write, and execute while others can only read and execute.

Now comes in the first number. It works exactly the same as the others but each bit means something different.

100 binary (aka 4 in decimal) means the program will always execute as if the owner ran it.
010 binary (aka 2 in decimal) means the prrogram will always execute under the owning group.
001 binary (aka 1 in decimal) is the "sticky bit". This means the program stays in memory even after execution is complete for faster startup next time. Typically you don't need to set the sticky bit on things unless it will be running over and over on a very short cycle.

You can combine these just like you could the read, write, and execute permissions. If you only use 3 numbers in your chmod it assumes the special bits are 0's. "chmod 0777 <file>" is the same as "chmod 777 <file>". "chmod 4770 <file>" isn't the same as "chmod 477 <file>".

Now... hopefully that was something on the line of what your looking for...

Edit: Fully explained the first number...

bruse 08-31-2005 08:39 AM

sorry for short information.

and i look ur answer.and somethink related to my question. thanks anyway.

here is my question.

while using chmod command in linux.i know the options like 777 or 770 or 775.

but i saw some where that 4 is added b4 that?
that is

#chmod 4777 <file>

now may i know that option 4 ?

titopoquito 08-31-2005 09:17 AM

@ bruse
Read jtshaw's post again. The info you request is written there.

@ jtshaw
And thank you jtshaw for your good explanation, now I really understood the sticky bit for the first time :)

theYinYeti 08-31-2005 09:43 AM

Wow jtshaw, I'm tempted to bookmark your post, to refer people back to it when needed... Done, bookmarked :)

Just edit it to add this last bit of information:

First number when applied to directories:
100 binary (aka 4 in decimal) means that files and dirs created inside this directory by users have the same owner as this directory, not that of the user.
010 binary (aka 2 in decimal) means that files and dirs created inside this directory by users have the same group as this directory, not that of the user.
001 binary (aka 1 in decimal) is the "sticky bit". This means that files and dirs created by a user in this directory can only be removed by this same user, even if everyone has writing permission on the directory.

Yves.


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