Почему все файлы + r (читаемые) другими в Linux (Ubuntu)?

1011
Pacane

Я не знаю, легко ли ответить на этот вопрос, но у меня есть VPS, и я недавно заметил, что все созданные файлы могут быть прочитаны другими пользователями (потому что по некоторым причинам файлы + r для "других") ).

Почему это так? Я использую Ubuntu Server Edition, это только так на Ubuntu?

Я думаю, что это не уважает частную жизнь пользователей ...

Есть ли веская причина, чтобы держать это так?

Если нет, то как я могу изменить его, чтобы все файлы, созданные пользователем в его домашней папке, например, не читались другими?

1

3 ответа на вопрос

7
Phil Lello

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.
4
Riguez

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.

1
Xenoactive

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