[root@localhost ~]# pwunconv 将密码回写 [root@localhost ~]# grep root /etc/passwd /etc/shadow /etc/passwd:root:$6$IglT.f7rqrwKA7tJ$1YXkCR3shYkNopl03UaIrBf7e1PUW9JXkxlpHg4sb8MPKy4xYqFVelynW7Ww6F.x1nfqKknJZzE6n7vKENAZP0:0:0:root:/root:/bin/bash /etc/passwd:operator:*:11:0:operator:/root:/sbin/nologin grep: /etc/shadow: No such file or directory [root@localhost ~]# ls /etc/shadow ls: cannot access /etc/shadow: No such file or directory
但此时依然可通过用户名、密码登录: [c:\~]$ ssh 192.168.0.128
Connecting to 192.168.0.128:22... Connection established. To escape to local shell, press 'Ctrl+Alt+]'.
Last login: Tue Feb 7 09:55:23 2017 from 192.168.0.1
[root@localhost ~]# 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 500 UID_MAX 60000
# # Min/max values for automatic gid selection in groupadd # GID_MIN 500 GID_MAX 60000
# # 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
[root@localhost ~]# useradd test [root@localhost ~]# passwd test Changing password for user test. New password: BAD PASSWORD: it is based on a dictionary word Retype new password: passwd: all authentication tokens updated successfully.
用户名为test,密码为test123。
查看用户信息
1 2
[root@localhost ~]# id test uid=500(test) gid=500(test) groups=500(test)
创建第二个用户test1
1 2 3 4 5 6 7 8 9 10 11 12 13 14
[root@localhost ~]# useradd test1 [root@localhost ~]# passwd test1 Changing password for user test1. New password: BAD PASSWORD: it is too simplistic/systematic Retype new password: passwd: all authentication tokens updated successfully.
用户名为test1,密码为abc123,。
[root@localhost ~]# id test1 uid=501(test1) gid=501(test1) groups=501(test1)
Options: -c, --comment COMMENT new value of the GECOS field -d, --home HOME_DIR new home directory for the user account -e, --expiredate EXPIRE_DATE set account expiration date to EXPIRE_DATE -f, --inactive INACTIVE set password inactive after expiration to INACTIVE -g, --gid GROUP force use GROUP as new primary group -G, --groups GROUPS new list of supplementary GROUPS -a, --append append the user to the supplemental GROUPS mentioned by the -G option without removing him/her from other groups -h, --help display this help message and exit -l, --login NEW_LOGIN new value of the login name -L, --lock lock the user account -m, --move-home move contents of the home directory to the new location (use only with -d) -o, --non-unique allow using duplicate (non-unique) UID -p, --password PASSWORD use encrypted password for the new password -s, --shell SHELL new login shell for the user account -u, --uid UID new UID for the user account -U, --unlock unlock the user account -Z, --selinux-user new SELinux user mapping for the user account