Если я создаю новые файлы и каталоги в своем домашнем каталоге, по умолчанию они доступны для записи в группе:
will@together:~$ touch test
will@together:~$ mkdir test_dir
will@together:~$ ll | grep test
-rw-rw-r-- 1 will will 0 Apr 23 10:36 test
drwxrwxr-x 2 will will 4096 Apr 23 10:36 test_dir/
Причина такого поведения заключается в способе работы с пользователями и группами в Debian / Ubuntu, называется Личные группы пользователей .
Я только что сделал новую установку Ubuntu и заметил, что автоматически созданные каталоги (Documents, Desktop и т. Д.) Не доступны для групповой записи.
will@together:~$ ll | grep Documents
drwxr-xr-x 2 will will 4096 Apr 22 22:21 Documents/
Мне было просто интересно, какова причина этого.
Это вызвано тем, что в /etc/login.defs
значение по умолчанию umask
установлено на 022, когда Ваш корневой каталог создается. 022 "исторический" umask, который существовал, прежде чем идея частных групп появилась. Но USERGROUPS_ENAB yes
в /etc/login.defs
изменения это к 002 (для чего-либо созданного после того, как Ваш корневой каталог создается).
Конфигурации в /etc/adduser.conf
переопределят тот, упомянутый выше, только если отключены частные группы. Мотивация для перемещения в 002 - то, что с появлением частных групп, 022 стал очень строгим для, например: настраивать общие каталоги.
Вы видите больше информации об этом в Lauchpad и журнал ошибки Debian . Кроме того, от /etc/login.defs
:
> # UMASK is the default umask value for pam_umask and is used by
> # useradd and newusers to set the mode of the new home directories.
> # 022 is the "historical" value in Debian for UMASK
> # 027, or even 077, could be considered better for privacy
> # There is no One True Answer here : each sysadmin must make up his/her
> # mind.
> #
> # If USERGROUPS_ENAB is set to "yes", that will modify this UMASK default value
> # for private user groups, i. e. the uid is the same as gid, and username is
> # the same as the primary group name: for these, the user permissions will be
> # used as group permissions, e. g. 022 will become 002.
# Enable setting of the umask group bits to be the same as owner bits
# (examples: 022 -> 002, 077 -> 007) for non-root users, if the uid is
# the same as gid, and username is the same as the primary group name.
#
# If set to yes, userdel will remove the user´s group if it contains no
# more members, and useradd will create by default a group with the name
# of the user.
#
USERGROUPS_ENAB yes
Во-первых, Вы можете ll -d Documents
, и сохранять grep
для того, когда это необходимо.
В /etc/adduser.conf
каждый находит:
# If DIR_MODE is set, directories will be created with the specified
# mode. Otherwise the default mode 0755 will be used.
DIR_MODE=0751
См. man adduser
и man adduser.conf
.