usermod command, user password management, mkpasswd

Keywords: Operation & Maintenance less shell Nginx Zabbix

Mission 12 June

3.4 usermod command

3.5 User Password Management

3.6 mkpasswd command

 

 

 

 

3.4 The usermod command:

Commands for usermod to change user attributes

 

Usermod-u 1000 file to change uid

Usermod-g 111 file to change gid (with ID or group name)

Usermod-d/home/gdsgsdg file to change home directory

Usermod-s/sbin/nologin file change shell

 

 

Usermod-G specifies an extension group that can be expanded at intervals of ",".

Usermod-g can only set changes for users to join a single group

 

Usermod-L file can lock the user and check the shadow password with it in front! That means not logged in

Usermod-U file can unlock users, before viewing the shadow password! Cancel to indicate login

 

[root@afeilinux-01 ~]# usermod -L axin
[root@afeilinux-01 ~]# tail -n3 /etc/shadow
aming2:!!:18156:0:99999:7:::
user5:!!:18156:0:99999:7:::
axin:!$6$t0EqJJXV$tAT.eiChMG1BYomFff3GGRiNTC.JQvpBz3Nt9Ejtq6icS3zJ11WtGekwzTtEl1MBzkrgk194fXcbtypF/e/Tq.:18156:0:99999:7:::
[root@afeilinux-01 ~]# usermod -U axin
[root@afeilinux-01 ~]# tail -n3 /etc/shadow
aming2:!!:18156:0:99999:7:::
user5:!!:18156:0:99999:7:::
axin:$6$t0EqJJXV$tAT.eiChMG1BYomFff3GGRiNTC.JQvpBz3Nt9Ejtq6icS3zJ11WtGekwzTtEl1MBzkrgk194fXcbtypF/e/Tq.:18156:0:99999:7:::

---------------------------------------------------------------------------------------------------------------------------------------

 

3.5 User password management:

 

Under root

Direct passwd can change the password of root

passwd aming can change the password of aming user

 

[root@afeilinux-01 ~]# passwd
Change the password of the user root.
New password:
Invalid password: password less than 8 characters
Re-enter the new password:
Sorry, the password doesn't match.
New password:
Re-enter the new password:
passwd: All authentication tokens have been successfully updated.
[root@afeilinux-01 ~]# passwd axin
Change user axin's password.
New password:
Invalid password: password less than 8 characters
Re-enter the new password:
Sorry, the password doesn't match.
New password:
Re-enter the new password:
passwd: All authentication tokens have been successfully updated.

Passwd-l locks users, and you can see a password in front of it under shadow!

Passwd-u can unlock users, you can see the password in front of the shadow! disappear

It can be found that there are still many users with!! That is, not logged in

[root@afeilinux-01 ~]# passwd -l axin
//Lock the password of user axin.
passwd: Successful operation
[root@afeilinux-01 ~]# passwd -U axin
passwd: False parameters -U: unknown option
[root@afeilinux-01 ~]# tail -n5 /etc/shadow
nginx:!!:18115::::::
zabbix:!!:18130::::::
aming2:!!:18156:0:99999:7:::
user5:!!:18156:0:99999:7:::
axin:!!$6$kp8nMehA$PlD015LQhf7kuUeB2xgs2qSbp/Bui9kpWcI5Q8Cz2cAod6iO4kUYhpT/6uh3.yd0Xok7A.2WUJXg0Wo93e4o//:18157:0:99999:7:::
[root@afeilinux-01 ~]# passwd -u axin
//Unlock user axin's password.
passwd: Successful operation

passwd --stdin file can modify user's password directly

Or directly

echo "111222" | passwd --stdin file "|" indicates the command pipeline character, which means that the previous results are transmitted directly to the subsequent commands.

Such operations are mostly used in scripts.

 

Another use of echo

echo -e

 

He can juxtapose two characters and use them on commands that require two validations

Written as echo-e "wangxin789 nwangxin789" | passwd aming2?

Note that two lines of numbers need to be spaced, double quotation marks, followed by spaces and command pipes |, and finally receive commands that want to transmit this result.

 

---------------------------------------------------------------------------------------------------------------------------------------

 

3.6 mkpasswd command:

 

A package needs to be installed

expect

You can use mkpasswd

The method of use is as follows:

[root@afeilinux-01 ~]# mkpasswd
0vx8iq\KA
[root@afeilinux-01 ~]# mkpasswd -l 12
h3hdsoqYQ$7z
[root@afeilinux-01 ~]# mkpasswd -l 12 -s 6
l?:{~P38[&Fw
[root@afeilinux-01 ~]# mkpasswd -l 12 -s 0
rb8JsbG3nqly

Posted by eelmitchell on Tue, 17 Sep 2019 23:50:27 -0700