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.

I don't know if this is an easy one to answer, but I have a VPS and I have noticed a while back that all files created can be read by other users (because files are +r for "others", for some reason).

Why is it like this? I'm using Ubuntu Server edition, is it only like that on Ubuntu?

I think it doesn't respect users' privacy...

Is there a good reason to keep it that way?

If not, how can I change it so all files created by a user in its home folder, for example, is not readable by others?

share|improve this question
add comment

3 Answers 3

up vote 7 down vote accepted

If you're only concerned with files under a home folder, run chmod o-rwx on the relevant directory; taking permission away on the folder blocks access.

The defaults come from /etc/useradd.conf, which is well documented in the comments. The specific value you'll need to change is DIR_MODE.

The default permissions for new files and directories during a shell session are controlled by umask.

This sounds like an odd default, but there may be an assumption by the VPS provider that:

  • home directories will normally be used for website files, so must be readable by apache (which normally runs as nobody), and this reduces their support tickets.
  • than Linux users will change permissions on directories/files they don't want to share.
share|improve this answer
add comment

Reason

The permissions are set very loose by default to allow users to share files with each others. It is safer in general to do this because most users are inexperienced and would find it easier to share their password than to set permissions. The more experienced user can change it rather easily so its just better to do it this way.

Fix

You can change the umask if you would rather have tigher settings. Here is a quick tutorial for how to set it.

share|improve this answer
add comment

You are not required to keep the default permissions for your personal files. Change the umask to set the default permissions.

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.