Linux – Restricting directory access for a user in linux

linuxpermissions

How can I restrict user to read other users directory in linux ?

for instance I have user1 and user2, I dont want the user2 to read /home/user1/… How can I do this ?

Thanks

Best Answer

Like zed said but you probably have service running which mean that it if you do this, these services will not be able to read theses files either if the service doesn't run under the user permission, which is rarely the case, most service runs under their own users.

ACL (Access control list) are what you may need. Here is the official doc http://centos.org/docs/5/html/Deployment_Guide-en-US/ch-acls.html

Follow the documentation by editing the /etc/fstab and remounting the partition then simply

setfacl -m d:o:--- /home/user1/
setfacl -m d:u:rwx /home/user1/

o for others, u for users.
Now retreive the acl :

getfacl /home/user1/

I recommend you read the docs and do some tests. Hope this helped.

Related Topic