Usermod command:
Cases:
[[email protected] ~]# Usermod-u 111 username//Change UID
[[email protected] ~]# USERMOD-G 1010 username//Change GID
[Email protected] ~]# usermod-d/home/aslkdfjlsk username//Specify home directory
[Email protected] ~]# usermod-s/sbin/nologin username//Specify Shell
[[email protected] ~]# usermod-g grp2 aming//expansion Group
Cases:
[[email protected] ~]# ID aming
uid=1000 (aming) gid=1000 (aming) group =1000 (aming)
Examples of experiments:
Description: Define an extension group for the aming user, add the aming user to the GRP2 group, so that aming users not only belong to the Aming group, but also to the GRP2 group, and then add a user5 group, the result is to replace the previous GRP2 group, how can I also have multiple groups? Yes, press this command to enter at the same time add Usermod-g grp2,user5 aming, but how to use small g is not, that small g can only be specified to add a group to the user, and large g can specify more than one.
Operation Result:
[Email protected] ~]# usermod-g user5 aming
[[email protected] ~]# ID aming
uid=1000 (aming) gid=1000 (aming) group =1000 (aming), 1007 (USER5)
[Email protected] ~]# usermod-g grp2,user5 aming
[[email protected] ~]# ID aming
uid=1000 (aming) gid=1000 (aming) group =1000 (aming), 1005 (GRP2), 1007 (USER5)
[Email protected] ~]# usermod-g grp2,user5 aming
Usermod: "Grp2,user5" group does not exist
[Email protected] ~]# usermod-g grp2 aming
[[email protected] ~]# ID aming
uid=1000 (aming) gid=1005 (GRP2) group =1005 (GRP2), 1007 (USER5)
User Password Management:
passwd Change the user password, it has a permission set_uid.
Change the root user password to enter passwd directly, change the normal user password input passwd user
View user password File command Tail/etc/shadow, you can see the user's encrypted string password.
Cases:
[Email protected] ~]# Tail/etc/shadow
Sshd:!! : 17455:::::: NOTE: two!! Indicates that the user does not have a password and cannot log on.
chrony:!! : 17455::::::
Aming:$6$bnsx1iz5$q/mks6.knoo4tgqnuq5nta0gjbrelcf894telmo/6auzkch8uao6uzezdjfzsuiec5mqyuv7xku/zwejhcggn. : 17468:0:99999:7:::
user1:!! : 17464:0:99999:7:::
aminglinux:!! : 17466:0:99999:7:::
user2:!! : 17468:0:99999:7:::
user3:!! : 17468:0:99999:7:::
user4:!! : 17468:0:99999:7:::
user5:!! : 17468:0:99999:7:::
user6:!! : 17468:0:99999:7:::
Cases:
[Email protected] ~]# Head/etc/shadow
root:$6$d/ka/dyhdjmyt3sm$mgvgaiq26dxli0z65uotoigg60tskcneaaxrbmnf/jz5phmuo5bb9rj7mzninvovakei1fvck30zo/ Wfudb.q1::0:99999:7:::
Bin:*:17110:0:99999:7:::
Daemon:*:17110:0:99999:7:::
Adm:*:17110:0:99999:7::: Note: * Indicates that the user is locked and cannot log in.
Lp:*:17110:0:99999:7:::
Sync:*:17110:0:99999:7:::
Shutdown:*:17110:0:99999:7:::
Halt:*:17110:0:99999:7:::
Mail:*:17110:0:99999:7:::
Operator:*:17110:0:99999:7:::
Example: Passwd-l aming
[Email protected] ~]# passwd-l aming
Locks the password of the user aming.
PASSWD: Successful operation
[Email protected] ~]# Tail/etc/shadow
Sshd:!! : 17455::::::
chrony:!! : 17455::::::
aming:!! $6$bnsx1iz5$q/mks6.knoo4tgqnuq5nta0gjbrelcf894telmo/6auzkch8uao6uzezdjfzsuiec5mqyuv7xku/zwejhcggn. : 17468:0:99999:7::://Encrypt files in front of two!! Indicates a password lock
user1:!! : 17464:0:99999:7:::
Example: Passwd-u aming
[Email protected] ~]# passwd-u aming
Unlocks the user aming password.
PASSWD: Successful operation
[Email protected] ~]# Tail/etc/shadow
Sshd:!! : 17455::::::
chrony:!! : 17455::::::
Aming:$6$bnsx1iz5$q/mks6.knoo4tgqnuq5nta0gjbrelcf894telmo/6auzkch8uao6uzezdjfzsuiec5mqyuv7xku/zwejhcggn. : 17468:0:99999:7::://Two A!! No, it means the password is unlocked.
user1:!! : 17464:0:99999:7:::
Usermod-l aming Lock user password usermod-u aming unlock user password, this method is the same as passwd, here is not an example.
passwd--stdin to set a password for a user.
Example 1:PASSWD--stdin user5
[Email protected] ~]# passwd--stdin user5
Change the password for the user user5.
Szyino-123
PASSWD: All the authentication tokens have been successfully updated.
Example 2: Using the shell to change a user's password:
[[email protected] ~]# echo "szyino123" |passwd--stdin user5//| pipe meaning pass the result of the previous command to the following command.
Change the password for the user user5.
PASSWD: All the authentication tokens have been successfully updated.
Example 3: NewLine printing, changing user passwords in this way
[Email protected] ~]# echo-e "123\nsss"
123
Sss
650) this.width=650; "Src=" Https://s4.51cto.com/oss/201710/31/2e58b9b00a04dbe5b8158a93fe9b4946.png-wh_500x0-wm_3 -wmp_4-s_1995611428.png "title=" 1.png "alt=" 2e58b9b00a04dbe5b8158a93fe9b4946.png-wh_ "/>
MKPASSWD command:
MKPASSWD installing the Yum install-y expect generate password command
Mkpasswd-l specifying the build password length usage: mkpasswd-l 12
Mkpasswd-l 12-s 3 Specifies the Generate password special symbol
Cases:
[Email protected] ~]# mkpasswd
vkbfgz07[
[Email protected] ~]# mkpasswd-l 12
4ij#khc0eesz
[Email protected] ~]# mkpasswd-l 12-s 3
8_vy]>wwh5op
[Email protected] ~]# mkpasswd-l 12-s 0
hstfc5qypu7e
[Email protected] ~]#
This article is from the "Gary Blog" blog, please be sure to keep this source http://taoxie.blog.51cto.com/10245493/1977899
Linux usermod, user password management, mkpasswd command description