[sf-lug] favorite interview questions (chmod, perms, etc.)

Michael Paoli Michael.Paoli at cal.berkeley.edu
Mon Apr 26 20:39:47 PDT 2010


[Bcc: <sender>]

Quoting [Bcced]:

> Is it safe to assume that the line (about half way down)
> """
> implications of the following command? chmod 01777 /scratch
> """
> is a typo?

No.

$ mkdir d && >>f && chmod 01777 f d && echo $?

$ ls -ld f d
drwxrwxrwt  2 michael users 48 Apr 26 20:28 d
-rwxrwxrwt  1 michael users  0 Apr 26 20:28 f
$ perl -e 'printf("%05o\n",(lstat(q;f;))[2] & 07777);'
01777
$ perl -e 'printf("%05o\n",(lstat(q;d;))[2] & 07777);'
01777
$ stat -c '0%a %n' f d
01777 f
01777 d
$

Bonus question:
Is specifying permissions to chmod(1) in octal form deprecated?
And if so, per which standard(s)?

references/excerpts:
chmod(1)
chmod(2)
stat(2)
perl(1)
http://linuxmafia.com/pipermail/sf-lug/2010q2/007718.html

>> From: Michael Paoli <Michael.Paoli at cal.berkeley.edu>
>> Subject: Re: [sf-lug] favorite interview questions
>> To: sf-lug at linuxmafia.com
>> Date: Sunday, April 25, 2010, 11:20 AM

>> implications of the following command? chmod 01777
>> /scratch





More information about the sf-lug mailing list