创建用户相关的文件

/etc/login.defs 文件说明
此文件的作用是预先定义创建用户时需要的一些用户默认配置信息。

[root@testdb62 ~]# 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     #<== 设定用户对应的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为1000,也就是说添加用户时,UID是从1000开始的
UID_MAX                 60000  #<== 默认最大UID为60000
# System accounts
SYS_UID_MIN               201
SYS_UID_MAX               999

#
# Min/max values for automatic gid selection in groupadd
#
GID_MIN                  1000  #<== 默认最小GID为1000,也就是说添加用户时,GID是从1000开始的
GID_MAX                 60000  #<== 默认最大GID为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   #<== 是否创建用户家目录,默认要求创建。可以用-m参数进行控制

# The permission mask is initialized to this value. If not specified, 
# the permission mask will be initialized to 022.
UMASK           077  #<== 家目录对应umask默认值

# This enables userdel to remove user groups if no members exist.
#
USERGROUPS_ENAB yes  #<== 删除用户同时删除用户组(如果用户组没有其他成员,则删除)

# Use SHA512 to encrypt password.
ENCRYPT_METHOD SHA512   #<== 密码加密算法



/etc/default/useradd  文件 
此文件的作用是使用useradd添加用户时预先加载的默认用户信息配置文件,可以使用useradd -D 修改此文件的配置

[root@testdb62 ~]# cat /etc/default/useradd 
# useradd defaults file
GROUP=100               #<== 依赖于/etc/login.defs USERGROUPS_ENAB参数,如果为no,则受此处控制。
HOME=/home              #<== 在/home目录下创建用户的家目录。
INACTIVE=-1             #<== 是否启用用户过期停权,-1表示不启用。
EXPIRE=                 #<== 用户终止日期,不设置表示不启用。
SHELL=/bin/bash         #<== 新用户默认使用的shell解释器。
SKEL=/etc/skel          #<== 配置新用户家目录的默认环境变量文件的存放路径。
CREATE_MAIL_SPOOL=yes   #<== 创建mail文件。


/etc/skel  目录下的文件

[root@testdb62 ~]# ls -lA  /etc/skel
总用量 12
-rw-r--r--. 1 root root  18 8月   8 2019 .bash_logout
-rw-r--r--. 1 root root 193 8月   8 2019 .bash_profile
-rw-r--r--. 1 root root 231 8月   8 2019 .bashrc

当使用useradd添加用户时,用户家目录下的隐藏环境变量文件,都是从这里配置的 /etc/skel目录中复制过去的。
默认情况下,/etc/skel 目录下的文件下的所有文件都是隐藏文件。
原文地址:https://www.cnblogs.com/l10n/p/14113902.html