[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: yee-gads! i almost had it.



On Wed, Feb 23, 2005 at 03:07:04PM -0600, bntly.rhds wrote:
> apparently if i want -rwxrw-r-- then i need to put 764 minus 666 which 
> gives me 098.  i don't know, but does that sound right?  umask=098 (aka 
> 764)? 

You take the complement of the mode you'd set with chmod.  This isn't
straight-up arthmetic, either; these are logical operations.

In binary:

000 111 110 100 (in octal, 0764, set with chmod)
111 000 001 011 (in octal, 7013, set with umask)

You should notice a pattern here. :)

FWIW, the modes work like this (with comedy ASCII art option):

  ___ ___ ___ 
 /2^2/2^1/2^0/'
------------- | 
| r | w | x | '
-------------/

2^2, if high, sets the permission bit for reading.
2^1, if high, sets the permission bit for writing.
2^0, if high, sets the permission bit for executing.

Now, there are four groups (the special group isn't really included
here, and it's often omitted since there aren't usually special octal
modes you'd set on files) that comprise a full permission setting.  As
mentioned already, the group furthest to the left is the special
group.  The three following that, respectively, are the owner, group,
and world groups.

So, the permission set above (0764) would mean that there would be no
special bits set, the file would be writeable, readable, and
executable by the owner, the file would be writeable and readable by
the owning group, and the file would be readable by the world.

Now, in case anyone is absolutely curious, this isn't the only time
masks like these are used.  Think about your IP address and subnet
mask and the relationship between them.  Try ANDing and ORing them. :)

-- 
Nathaniel Reindl

    "Die Grenzen meiner Sprache bedeuten die Grenzen meiner Welt."
       (The limits of my language mean the limits of my world.)
			-- Ludwig Wittgenstein

-
To unsubscribe, send email to majordomo@silug.org with
"unsubscribe silug-discuss" in the body.