What does it mean to chown a directory non-recursively?
You can do either chown $user $path
or chown -R $user $path
. What's the difference when $path
is a directory?
The second invocation would also chown
all files and directories inside $path
recursively. But what permissions do you get from that beyond what you get from owning the parent directory?
Solution 1:
But what permissions do you get from that beyond what you get from owning the parent directory?
You actually don't get much from owning the parent directory. This only grants you the chmod privilege to the directory itself – if you aren't the owner of a particular file or subdirectory inside, you're still not allowed to perform "owner only" operations on it (chmod, chattr) regardless of what permissions you might have on the parent.
(Move/rename/unlink are directory entry operations and only require the 'write' permission on the parent directory but nothing on the file; but many other things – chmod, chgrp, chattr, setfattr, utime, many ioctls – are file operations that require ownership of the file itself, but nothing on the parent directory.)