Paradox's answer is indeed the best answer.
However I feel like it was not fully explained as to why a root folder should be created.
If you have a shared folder in /home/user1/sharedfolder
then you need access to the folder /home/user1
as well (which was explained). But you should notice that /home/user1
is user/group owned by user1. user2 would need to be a part of the group user1 (or permissions of /home/user1
need to be 751 or more specifically gives "other users" executable permissions which is not a good idea) to access /home/user1
. Executable access to /home/user1
is required in order to access the shared folder. Like sometimes I forget that even the command "cd"
is a program, and if you cant cd
into /home/user1
as user2 then how can you access /home/user1/sharedFolder
?
So unless you want user2 to be able to access everything user1 has access to in their home folder then you would definitely require the use of a more "public meeting" spot rather than in the home. I mean, think about it this way you can't share something in your home without giving access to your home in the first place.
Lets say you have a secondary hard drive / mounted folder. If you want multiple users to access that, I recommend to throw it into `/mnt/mountedFolder', then have a shared group own that mountedFolder using the directions from the best answer above.
When using containers its acceptable to map /mnt/mountedFolder
to a root folder inside the container like /data
or /config
and basically the user of your container would need to be apart of that shared group. Your container may create new users with different user IDs...if that user in the container creates a folder/file with its own permissions the users who had access to the /mnt/mountedFolder
will be unable to access those folders/files unless those users are apart of the group of the containerised user group and that containerised user is creating files/folders where the group permission is g+rwx
.
Hope this adds a better explanation for those who didn't understand after the best answer. Dealing with permissions can frustrating because it seems like it should be so simple, but there's actually a lot to consider. When you feel frustrated about permissions try not to do something silly and try to make everything have more elevated permissions than necessary... you are probably missing something.
/home/user1
has no execute permission for user2. The simplest way to fix this would bechmod o+x /home/user1
since I guess you don't want to change the group on the home directory you need to give everyone execute permission on it.home
directory of each user is only traversable by the respective user. Rather than having the folder inside of another user'shome
, just put it inmnt
and change the permissions in that directory or create an NFS export that only the two users can access.