Linux CentOS7 VMware usermod Command, user password management, mkpasswd command

Source: Internet
Author: User
Tags stdin

First, Usermod command

usermod can be used to modify the user account settings

-C,--comment note the new value of the GECOS field
-D,--home Home_dir user's new home directory
-E,--expiredate expire_date set the account expiration date to Expire_date
-F,--inactive inactive expired inactive days, set password to invalid state
-G,--gid group enforces the use of group as the new primary group
-G,--groups groups new list of additional groups groups
-A, the--append group appends the user to the additional group mentioned in-G above,
Do not remove this user from other groups
-H,--help displays this help information and launches
-L,--login login New login Name
-L,--lock lock user account
-M,--move-home move home directory content to a new location (only with-D)
-O,--non-unique allows the use of duplicate (non-unique) UID
-p,--password password set the encrypted password (password) to the new password
-R,--root Chroot_dir CHROOT to the directory
-S,--shell shell the new login shell for the user account
-U,--uid UID user account's new UID
-U,--unlock unlock user account
-Z, new SELinux user mapping for--selinux-user seuser user account


[Email protected] ~]# Usermod-u 111 Uaername
[Email protected] ~]# usermod-g GID username
[Email protected] ~]# usermod-d/home/ss username
[Email protected] ~]# usermod-s/sbin/nologin Usernamer

Add GRP1 into the Davery group

and add User3 into the Daery group.

[Email protected] ~]# usermod-g GRP1 davery
[[email protected] ~]# ID davery
uid=1000 (davery) gid=1003 (GRP1) group =1003 (GRP1)
[Email protected] ~]# usermod-g User3 davery
[[email protected] ~]# ID davery
uid=1000 (davery) gid=1003 (GRP1) group =1003 (GRP1), 1006 (User3)
[Email protected] ~]#

Second, the user password management

change user Password

[Email protected] ~]# passwd
Change the password for the user root.
New Password:
[Email protected] ~]# passwd davery
View User Password

[Email protected] ~]# Head/etc/shadow
Root:$6$6evirlcaxdf9st5r$xz/u82j7ljf.y/rjsrjhmbbwvc8us0r.qkgxmhqx3e3qac2eins.o/pydo6gqsqolopg.av.pi.bajvfiptwp /::0:99999:7:::
Bin:*:17110:0:99999:7:::
Daemon:*:17110:0:99999:7:::
Adm:*:17110:0:99999:7:::
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:::
[Email protected] ~]#

Lock/unlock user password

[[Email protected] ~] #passwd-L davery

[[Email protected] ~] #passwd-U davery

[Email protected] ~]# usermod-l davery

[Email protected] ~]# usermod-u davery

Set a password for a user

[Email protected] ~]# passwd--stdin davery
Change the password for the user davery.

*******
PASSWD: All the authentication tokens have been successfully updated.

[Email protected] ~]# echo "* * * *" |PASSWD--stdin davery
Change the password for the user davery.
PASSWD: All the authentication tokens have been successfully updated.
[Email protected] ~]#

Extended

[Email protected] ~]# echo-e "123\nsss"
123
Sss
[Email protected] ~]# echo-e "123nsss"
123nsss
[Email protected] ~]# echo-e "123\tsss"
123sss
[Email protected] ~]# echo-e "1233\n1321" |passwd davery
Change the password for the user davery.
[Email protected] ~]#

Third, mkpasswd generate password tool

Automatically generate random passwords

[Email protected] ~]# mkpasswd
-BASH:MKPASSWD: Command not found
[email protected] ~]# Yum install-y expect

...

[Email protected] ~]# mkpasswd
M07grj#oj
[Email protected] ~]# mkpasswd-l 12
gse2e^enuq2l
[Email protected] ~]# mkpasswd-l 12-S4
passwd: Wrong parameter-s4: unknown option
[Email protected] ~]# mkpasswd-l 12-s 4
]ke>;7s^bf0y
[Email protected] ~]#

Linux CentOS7 VMware usermod Command, user password management, mkpasswd command

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.