LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 07-08-2009, 10:06 AM   #1
Completely Clueless
Member
 
Registered: Mar 2008
Location: Marbella, Spain
Distribution: Many and various...
Posts: 775

Rep: Reputation: 67
Angry File permissions v. directory permissions


Hi all,

Well I HAD thought I'd got this licked a year ago as one of the simpler aspects of Linux administration. However, I've just come across a chapter in the Linux Command Line and Shell Scripting Bible which I can't reconcile with reality. Perhaps someone can explain what I'm not understanding.

The author makes a distinction between permission sets for ordinary files on the one hand and directories on the other. He states that a full set of permissions for a file is 666 (octal) whereas for a directory it's 777.

Now I must be out of kilter with this book, because I've created test files and test directories and they appear to need identical octal permission triplets to give identical permissions. For example, the author's claim that 666 gives full permissions to a file is flat-out wrong as it grants no 'execute' permissions to _anyone_. From his text, it is clear that 666 is the highest set of permissions for a file. However, AIUI, it is actually 777; exactly the same as for a directory.

Can someone please explain WTF this guy is getting at? Thanks!
 
Old 07-08-2009, 10:25 AM   #2
jdkaye
Senior Member
 
Registered: Dec 2008
Location: Westgate-on-Sea, Kent, UK
Distribution: Debian Testing Amd64
Posts: 4,469

Rep: Reputation: Disabled
Hi CC,
This from the 2006 edition of Linux Bible (p.68)
Quote:
Here are some examples of how to change permission on a file (named file) and
what the resulting permission would be:
# chmod 777 file rwxrwxrwx
# chmod 755 file rwxr-xr-x
# chmod 644 file rw-r--r-
# chmod 000 file ---------
My bible is stronger than your bible!
As you said, the guy was talking bollocks.
Cheers,
jdk
 
Old 07-08-2009, 10:29 AM   #3
jphilput
Member
 
Registered: Nov 2007
Posts: 58

Rep: Reputation: 15
You're right, the statement that 666 grants full access permissions to a file is incorrect. Setting a file's permissions to 777 gives everyone full read, write and execute permissions.

Is it possible that the author is using different language to refer to executables? Perhaps the author is using the term "file" to refer to a flat file on the system that under no circumstances could/would be executed. If that is the case, his statement on permissions makes more sense.
 
Old 07-08-2009, 10:43 AM   #4
Completely Clueless
Member
 
Registered: Mar 2008
Location: Marbella, Spain
Distribution: Many and various...
Posts: 775

Original Poster
Rep: Reputation: 67
Thanks, guys. It's nice to know I'm not completely nuts.
I don't understand why he's stated this. It would only make sense if no regular files on the system were ever executable, which is clearly rubbish.
 
Old 07-08-2009, 10:47 AM   #5
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,531
Blog Entries: 27

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
Hello Completely Clueless

For an ordinary file that is not a program any further permission (a 7 in some place) would not have any effect. For any file or directory 777 is all the permissions it can have (ignoring the fourth permission, used for SUID, GID and sticky -- see /tmp for an example of a directory with the stick bit set)

Permissions are well explained at http://www.zzee.com/solutions/linux-permissions.shtml

Best

Charles
 
Old 07-08-2009, 10:58 AM   #6
Completely Clueless
Member
 
Registered: Mar 2008
Location: Marbella, Spain
Distribution: Many and various...
Posts: 775

Original Poster
Rep: Reputation: 67
The author explains that a full set of file permissions is 666. A full set of directory permissions is 777. If your umask value is 022 and you create a new file, then by default it will have the permission 644 (666 'less' 022). But if you create a new directory, the umask of 022 is 'subtracted' from the directory full permission value of 777, giving a permission triplet of 751.
Does that give any better insight into his thinking? It's on p.163 (2008 edition).

Last edited by Completely Clueless; 07-08-2009 at 11:00 AM.
 
Old 07-08-2009, 07:50 PM   #7
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,251

Rep: Reputation: 2025Reputation: 2025Reputation: 2025Reputation: 2025Reputation: 2025Reputation: 2025Reputation: 2025Reputation: 2025Reputation: 2025Reputation: 2025Reputation: 2025
Possibly he's trying (badly) to distinguish between dirs, files & programs(!)
Sounds as though its badly written though...
 
Old 07-09-2009, 08:33 AM   #8
Completely Clueless
Member
 
Registered: Mar 2008
Location: Marbella, Spain
Distribution: Many and various...
Posts: 775

Original Poster
Rep: Reputation: 67
I have finally got to the bottom of it. I have another Linux 2008 Bible by a different author (some fellow called Negus) who explains it properly.
The confusion arises because whilst both directories *and* files have 777 as full read, write and execute permission sets for the owner, the group and others; by default, *files* are created from a 666 template as they are assumed to not require execute permission. So consequently, a default umask value of 022 results in new *directories* being created with a 755 set of permissions whereas new *files* with the same umask end up with a 644 set of permissions (execution off by default for all users). Phew!!!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
File and directory permissions or groups kuplo Linux - Newbie 1 11-11-2005 03:06 AM
File/Directory Permissions waynevnc Debian 1 05-23-2005 04:23 PM
File & directory permissions waynevnc Debian 5 07-06-2004 02:29 PM
File and Directory permissions plasmapudding Red Hat 3 09-09-2003 10:26 AM
Directory and file permissions ryan Linux - Security 2 12-06-2000 12:46 PM


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

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration