Linux - NewbieThis 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!
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
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!
This from the 2006 edition of Linux Bible (p.68)
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.
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.
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.
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)
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.
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!!!