Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

In unices, do new folders/files inherit parent permissions?

What about groups and owners? (maybe those don't qualify as permissions...?)

share|improve this question

2 Answers 2

up vote 2 down vote accepted

Permissions on UNIX and UNIX-like systems aren't inherited. All new folders and files created use the umask value to determine the default permissions they will be created with.

The umask value is subtracted from 777 (full rwx permissions for everyone) to set a directory's default permissions, and from 666 for a file's default permissions. This is a security feature so files don't get execute permissions unless explicitly set.


To answer your edit, no, group and owner permissions are not inherited either.

share|improve this answer

Not really, no. However, some directory permissions are particularly important in regards to this: g+s makes new files in a directory be group-owned by the directory's group. u+s would do the same but for user-ownership, except that it's not supported on Linux. x on a directory will control traversal -- the ability of people to look "through" that directory to files underneath it. r is used to allow listing a directory. t can be used to prevent deleting files in a directory if a user doesn't own (i.e., didn't create, usually) the file.

Groups and owners definitely count as part of the permissions system. In fact, you'll need to create lots of groups to get fine-grained permissions on unix, unless you want to use ACLs instead. Or unless your needs simply aren't complex, of course. For example, if your file is owned by bob:users, and you need to add the staff group as legitimate readers, but don't want to allow access to others, then all you can really do is create an additional group containing everyone from staff and users, and give that group ownership of the file. ACLs handle this more elegantly, and I think systems like NFS allow groups to contain other groups (which makes this sort of group hack much cleaner and easier to maintain).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.