/etc/login.defs 文件为多个用户帐户参数提供默认配置信息。
useradd、usermod、userdel 和 groupadd 命令以及其他用户和组实用程序从该文件中获取默认值。
每行包含一个指令名称和相关值。
下面是来自 CentOS 7 系统的示例 /etc/logins.defs 文件。
# cat /etc/login.defs # # Please note that the parameters in this configuration file control the # behavior of the tools from the shadow-utils component. None of these # tools uses the PAM mechanism, and the utilities that use PAM (such as the # passwd command) should therefore be configured elsewhere. Refer to # /etc/pam.d/system-auth for more information. # # *REQUIRED* # Directory where mailboxes reside, _or_ name of file, relative to the # home directory. If you _do_ define both, MAIL_DIR takes precedence. # QMAIL_DIR is for Qmail # #QMAIL_DIR Maildir MAIL_DIR /var/spool/mail #MAIL_FILE .mail # Password aging controls: # # PASS_MAX_DAYS Maximum number of days a password may be used. # PASS_MIN_DAYS Minimum number of days allowed between password changes. # PASS_MIN_LEN Minimum acceptable password length. # PASS_WARN_AGE Number of days warning given before a password expires. # PASS_MAX_DAYS 99999 PASS_MIN_DAYS 0 PASS_MIN_LEN 5 PASS_WARN_AGE 7 # # Min/max values for automatic uid selection in useradd # UID_MIN 1000 UID_MAX 60000 # System accounts SYS_UID_MIN 201 SYS_UID_MAX 999 # # Min/max values for automatic gid selection in groupadd # GID_MIN 1000 GID_MAX 60000 # System accounts SYS_GID_MIN 201 SYS_GID_MAX 999 # # If defined, this command is run when removing a user. # It should remove any at/cron/print jobs etc. owned by # the user to be removed (passed as the first argument). # #USERDEL_CMD /usr/sbin/userdel_local # # If useradd should create home directories for users by default # On RH systems, we do. This option is overridden with the -m flag on # useradd command line. # CREATE_HOME yes # The permission mask is initialized to this value. If not specified, # the permission mask will be initialized to 022. UMASK 077 # This enables userdel to remove user groups if no members exist. # USERGROUPS_ENAB yes # Use SHA512 to encrypt password. ENCRYPT_METHOD SHA512
以下是 /etc/login.defs 指令的部分列表:
- 用户邮箱的位置
- 密码时效控制
- 自动 UID 选择的最小值和最大值(1000 到 60000)
- 自动 GID 选择的最小值和最大值(1000 到 60000)
- 添加新用户时是否应创建主目录
- 默认 umask
- 用于加密密码的加密方法
如果 /etc/login.defs 中的 USERGROUPS_ENAB 指令设置为 YES ,则会为用户创建一个与用户名同名的组。
如果该指令设置为 NO ,则 useradd 命令将新用户的主要组设置为 /etc/default/useradd 文件中 GROUP 指令指定的值,或者默认为 100。
日期:2020-09-17 00:14:32 来源:oir作者:oir