From: Janis Papanagnou on
Phred Phungus wrote:
> Janis Papanagnou wrote:
>> Phred Phungus wrote:
>>> Hello newsgroup, I've got a grab bag of questions that I think are
>>> topical here.
>>>
>>> Apparently, unix directories have permissions. How do I determine
>>> what the permissions are for, say, /usr/bin/ ?
>>
>> ls -ld /usr/bin
>>
>> Permissions are coded in the first column. For their meaning read
>>
>> man chmod
>
> This is what I've been banging my head against for the last few days.
> The clp.misc people recommend that I think of it as
> chmod 700 myfile
>
> My question is: how do I go the other way? I know the answer is going
> to involve some arithmetic:
>
>
>
> A numeric mode is from one to four octal digits (0-7), derived by
> adding up the bits with values 4, 2, and 1. Omitted digits are
> assumed
> to be leading zeros. The first digit selects the set user ID
> (4) and
> set group ID (2) and restricted deletion or sticky (1)
> attributes. The
> second digit selects permissions for the user who owns the file:
> read
> (4), write (2), and execute (1); the third selects
> permissions for
> other users in the file�s group, with the same values; and the
> fourth
> for other users not in the file�s group, with the same values.
>
> So for this example, what is the equivalent scalar for the chmod command:
>
> dan(a)dan-desktop:~$ ls -ld /usr/bin
> drwxr-xr-x 2 root root 36864 2010-02-08 19:24 /usr/bin
> dan(a)dan-desktop:~$ man chmod
>
> ?

Not sure what's exactly unclear.

The numerical value is an octal encoding, fast to type but not extremely
intuitive if you're not used to it. Consider it as 3 groups of permissions
for the owner of the file/directory, the group, and the rest of the world.
Your above mentioned 700 means read/write/execute for the owner, no access
for anyone else. To be more precise; the "execute" flag for directory means
the permission to "enter" that directory. For /usr/bin the flags are usually
as depicted above drwxr-xr-x which is equivalent to 755 octal code.

>
>
>
>>
>>>
>>> What are the roles of the . and .. ?
>>
>> The current directory and the parent of current directory, respectively.
>>
>> Janis
>
> Thanks Janis. Forgive my naivete, but doesn't this mean that a
> directory contains itself and its parent?

It's no containment, rather consider it as a reference. Every directory has
a reference to self (.) and a reference to its parent (..). That makes it
possible to, e.g., address an executable file by ./executablefile (in case
the local directory is not in the search PATH for executables), or to switch
to the parent directory by cd ..

Janis

>
> --
>
> Phred
From: Bill Marcum on
On 2010-02-10, Phred Phungus <Phred(a)example.invalid> wrote:
>> ls -ld /usr/bin
>>
>> Permissions are coded in the first column. For their meaning read
>>
>> man chmod
>
> This is what I've been banging my head against for the last few days.
> The clp.misc people recommend that I think of it as
> chmod 700 myfile
>
>
> So for this example, what is the equivalent scalar for the chmod command:
>
> dan(a)dan-desktop:~$ ls -ld /usr/bin
> drwxr-xr-x 2 root root 36864 2010-02-08 19:24 /usr/bin
755.

>
> Thanks Janis. Forgive my naivete, but doesn't this mean that a
> directory contains itself and its parent?
>
Every directory contains hard links to itself and its parent. You can
see that in the link count (the number after the permissions in the ls -l
listing).
From: Robert Bonomi on
In article <7tgr7nF2dqU1(a)mid.individual.net>,
Phred Phungus <Phred(a)example.invalid> wrote:
>Janis Papanagnou wrote:
>> Phred Phungus wrote:
>>> Hello newsgroup, I've got a grab bag of questions that I think are
>>> topical here.
>>>
>>> Apparently, unix directories have permissions. How do I determine
>>> what the permissions are for, say, /usr/bin/ ?
>>
>> ls -ld /usr/bin
>>
>> Permissions are coded in the first column. For their meaning read
>>
>> man chmod
>
>This is what I've been banging my head against for the last few days.
>The clp.misc people recommend that I think of it as
>chmod 700 myfile
>
>My question is: how do I go the other way? I know the answer is going
>to involve some arithmetic:
>
>A numeric mode is from one to four octal digits (0-7), derived by
> adding up the bits with values 4, 2, and 1. Omitted digits are
>assumed
> to be leading zeros. The first digit selects the set user ID
>(4) and
> set group ID (2) and restricted deletion or sticky (1)
>attributes. The
> second digit selects permissions for the user who owns the
>file: read
> (4), write (2), and execute (1); the third selects
>permissions for
> other users in the file�s group, with the same values; and the
> fourth
> for other users not in the file�s group, with the same values.
>
>So for this example, what is the equivalent scalar for the chmod command:
>
>dan(a)dan-desktop:~$ ls -ld /usr/bin
>drwxr-xr-x 2 root root 36864 2010-02-08 19:24 /usr/bin

there are 9 letter positions after the 'd'. three groups of three.

Within each group of three chracters the leftmost position is equivalent to
a '4', the middle position is equivalent to a '2', and the rightmost is
equivalent to a '1'. If the position has a letter in it (not a '-'), you
add the corresponding numeric value -- e.g. 'r-x' is (4+), or 5.

Repoeat this for all three groups. this gives you the rightmost 3 digits
of the numeric value.

Lastly, if there is an 's' (or 'S') in any of the three groups, you have to
construct a fourth (*leftmost*) digit of the numeric value. if there is an
's' (or 'S') in the first, leftmost group, this is a '4', in the middle group
it represents a '2', in the rightmost group, a '1'. add the values, and make
it the leftmost digit (eg. '4xxx') of the numeric value.

>dan(a)dan-desktop:~$ man chmod


>
>?
>
>
>
>>
>>>
>>> What are the roles of the . and .. ?
>>
>> The current directory and the parent of current directory, respectively.
>>
>> Janis
>
>Thanks Janis. Forgive my naivete, but doesn't this mean that a
>directory contains itself and its parent?

No. _Every_ directory contains a _reference_ (aka 'pnoonter', aka 'alias')
to itself, and to its parent.

There are exotic reasons, having to do with the flesystem design, why these
tags exist. but they are also major 'convenience' items, allowing you to say,
for example, './foo' at the shell prompt, to execute a file in the 'current
directory', _even_if_ there is a file of the same name 'somewhere' in the
'search list'/'search path'.



From: Maxwell Lol on
Janis Papanagnou <janis_papanagnou(a)hotmail.com> writes:

>> drwxr-xr-x 2 root root 36864 2010-02-08 19:24 /usr/bin
4214-14-1

or 755

From: Maxwell Lol on
Phred Phungus <Phred(a)example.invalid> writes:

> dan(a)dan-desktop:~$ ls -ld /usr/bin
> drwxr-xr-x 2 root root 36864 2010-02-08 19:24 /usr/bin
> dan(a)dan-desktop:~$
>
> My next question is how do I determine what the max path is for this
> directory.

Do you mean maximum pathlength (i.e. a the length of a string needed to hold
the largest file/pathname?)

There is a constant in the /usr/include files that gives the exact
limit if you are interested.


/usr/include/linux/limits.h:#define PATH_MAX 4096 \
/* # chars in a path name including nul */