I have this structure:
and I would like to have read and write access to it, but I want to be unable to read or write anything above it, that is
Is that possible?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
It's better to do this in a location other than home such as creating the folder structure in
/ but here it goes:
Set the owner of
subfolder as the user you want to have read and write permissions.
chown user /home/the_user/folder/subfolder chmod u+rwx /home/the_user/folder/subfolder
Set execute for others on
folder and make sure that there is no read and write for the user.
chmod +x for each of them and
chmod -rw for the user.
That will allow the user to traverse the above directories but not read them or write to them while allowing him to read and write to
Once again, I recommend against doing this in
/home and suggest that you create the directory as a subfolder of root such as:
....and use my answer there instead of potentially making a mistake and giving permissions to someone's home directory.
Another approach is to mount the folder to a folder the user have access to.
Say we have the folder
/home/the_user/folder/subfolder you want to show to user
cat without disclosing anything else in your home:
mkdir /home/cat/subfolder chown cat /home/the_user/folder/subfolder sudo mount -o bind /home/the_user/folder/subfolder /home/cat/subfolder
Should do the trick.