I would like to share a folder called ‘files’ with user1 and user2 in my Linux account. Is there a way to set the authorizations to read write or execute for only these two users and keep it secure from other users? To my knowledge, it is only possible to do this for a usergroup as a whole.
Thank you
Advertisement
Answer
If your Linux has a “modern” filesystem (ext3/ext4,… )you can achieve this with POSIX ACLs:
Enable ACLs for the FS. –> only required for ext3 and ext4 on kernels older than 2.6.38. All other FS with ACL-support have them automatically activated.
mount -o remount,acl / tune2fs -o acl /dev/<partition>
Give
user1
access to the folderfiles
: (r/w/x)setfacl -m user:user1:rwx /home/philipovic/files
Give
user2
access to the folderfiles
: (r/w/x)setfacl -m user:user2:rwx /home/philipovic/files
If your linux does not support ACLs you have to create a group:
- Create a group
- Add the desired users to that group
chgrp
the directory to that group, and give permissions withchmod
:chgrp groupname /home/philipovic/files chmod g+rwx /home/philipovic/files