3

If a directory /foo/bar/baz has 700 (rwx------) for its permissions, thereby making it inaccessible to all but its owner (and the superuser), does it matter what the "group" and "other" permissions are for the directories and files under /foo/bar/baz?


What motivated this question is that I noticed that the files

/root/.bashrc
/root/.profile

in a freshly-installed Debian system have 644 (rw-r--r--) as their permissions. I would have expected 600 (rw-------) instead. But then I realized that /root itself has permission 700. This made me wonder whether a 700 permission of a directory would render moot the g- and o- permissions of anything under it.

(If the answer is "no", i.e., if the g- and o- permissions of the contents still matter even when a component along the path has 700 permissions, then I'd like to know if there's any reason not to change the permissions of the files above to 600.)

2 Answers 2

6

Yes it does (could).

If you create a file underneath /foo/bar/baz which is readable by others and then create a hard link to this file in an accessible path, they'll be able to read it regardless of the permissions on /foo/bar/baz.

0

If a directory is 700, then only the owner (and root) can access it.

This means that any other users can not see, never mind change, any files in that directory.

So yes, you probably could change all the files in that directory to 600 or 400 or 700, but why bother? Does it matter that someone could read (but not write to) root's .bashrc and .profile if root were to change permissions on their home directory to 777?

root's .bashrc and .profile should, as a matter of best practice, be as close to the defaults as is practical. You don't want any surprises when you're working as root, and storing anything secret in these files is just daft.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .