Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

share|improve this question

2 Answers 2

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.

share|improve this answer
    
acls! how good.. I can't believe I've been using CentOS for years with just perms and groups.. /me headdesk in a good way! –  Grizly Apr 7 '10 at 23:19

chmod 700 /home/user1

This assumes that ownerships are set correctly, of course, and that you aren't needing something like a webserver to be able to see files in a public_html directory.

If you want to restrict listing files in a directory, without removing the ability to read specific files or subdirectories with known names and appropriate permissions, use: chmod 711 /home/user1

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.