Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In my server (cpanel) I see now that with a simple DIR script (PHP) I can list files of all users over public_html


How can I prevent users from accessing the files of other users?

share|improve this question

closed as off-topic by HopelessN00b, HBruijn Feb 24 at 19:47

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

Your best bet, guessing that all users have different user id's, is to have their homes set to 0711 that is, readable, writable and executable to them, and only executable to others.

For a directory, the executable bit means that you can go in it but you can't list the content, which is what you're looking for.

share|improve this answer

When you create a user, create a group also with the same name


groupadd mike useradd -g mike mike

and change group of all folders owned by user 'mike' to group 'mike'

chgrp -R mike /home/mike/
chmod 770 to all folders and chmod 640 to all files

and make all user's umask value to 0[2|7]7 in /etc/bashrc, which will help to make these settings persistant for user accounts which will be created in future

share|improve this answer
As it seems to be a public_html problem, I think the web server will need to access the files, setting the homes to 770 will not allow that unless the group of the home directory is the same as the web server, and in that case, all users with web server privileges will be able to look into the files. – mat Feb 18 '10 at 13:17