Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How do I stop one user account from being able to read files in another user account.

Right now once i log in, I can easily navigate to /home/[username] and copy/read any file. How do I make it thus that only /home/[username]/shared is allowed to be read/copied.

I would also like to prevent listing of directories.

share|improve this question
add comment

migrated from stackoverflow.com Oct 8 '10 at 0:12

This question came from our site for professional and enthusiast programmers.

2 Answers

up vote 2 down vote accepted
sudo chown -R [username] /home/[username] (1)
sudo chmod -R 700 /home/[username]        (2)
sudo chmod -R 755 /home/[username]/shared (3)

(1) Makes the user's folder owned by that user
(2) Prevents read, write and execute access for everyone but that user
(3) Adds read and execute access for everyone and write access for the user to the shared folder

-R means apply the command recursively.

I wrote all this off the top of my head, so someone please correct me if I'm wrong :)

share|improve this answer
    
how do I make this to be the automatic default for every current user and future user, instead of manually doing this? –  Ali Oct 7 '10 at 22:34
    
@Ali: Take a look at umask linked in my answer as far as future users are concerned. For currents, just back up the command one directory and say: sudo chmod -R XXX /home –  Bryan Oct 7 '10 at 22:57
    
it should be 711 /home/[username]. 'x' permission on a directory allows you to pass through, but not to read the files. Also, you don't really need the -R. Having no read permission on a top level directory really prevents you from accessing any files under it unless you already know the name. –  gorilla Oct 8 '10 at 2:48
add comment

Check out the man chmod. It allows you to change read/write for files. You may also want to check out umask, which is what changes the default values for files you create.

share|improve this answer
add comment

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.