Linux usermod, user password management and password random generation tool mkpasswd

Source: Internet
Author: User
Tags stdin


One, Usermod command 1. Usermod changing a user's properties

Usermod-u 111 User1 Change the UID of user User1 to 111

Usermod-g grp2 user2 Change user2 Group to User2

usermod-d/home/test User3 Change User3 's home directory to/home/test/

Usermod-s/sbin/nologin user2 Change user2 login Shell is not able to log in

2. ID User1

View information such as user Uid,gid, expansion group, etc.

A user can belong to more than one group, with an extension group:

Usermod-g Grp2 user1 Add User1 expansion group to GRP2

[[Email Protected]_46_188_centos ~]# usermod-g grp1,fxq user2[[email protected]_46_188_centos ~]# ID user2uid=1015 ( User2) gid=1017 (user2) groups=1017 (user2), + (FXQ), 1016 (GRP1) [[Email Protected]_46_188_centos ~]#
Second, the user password management 1. change user password:

passwd Root Change root password

passwd fxq change fxq user password

View password file Real storage file/etc/shadow

[[EMAIL PROTECTED]_46_188_CENTOS ~]# CAT /ETC/SHADOWROOT:$1$QOTJNBBE$O3XVX5L0KNPVMXMIVSFNF .:: 0:99999:7:::bin:*:16659:0:99999:7:::d aemon:*:16659:0:99999:7:::adm:*:16659:0:99999:7:::lp:*:16659:0:99999:7 ::: Sync:*:16659:0:99999:7:::shutdown:*:16659:0:99999:7:::halt:*:16659:0:99999:7:::mail:*:16659:0:99999:7:::o Perator:*:16659:0:99999:7:::games:*:16659:0:99999:7:::ftp:*:16659:0:99999:7:::nobody:*:16659:0:99999:7::: avahi-autoipd:!! : 16912::::::systemd-bus-proxy:!! : 16912::::::systemd-network:!! : 16912,:::::d bus:!! : 16912,:::::p olkitd:!! : 16912::::::abrt:!! : 16912::::::libstoragemgmt:!! : 16912::::::tss:!! : 16912::::::ntp:!! : 16912,:::::p ostfix:!! : 16912::::::chrony:!! : 16912::::::sshd:!! : 16912::::::tcpdump:!! : 16912::::::apache:!! : 17296::::::mysql:!! : 17319::::::fxq:$1$ymvfhplx$ixmvlg4chjsxr6ffxtugs1:17322:0:99999:7:::nginx:!! : 17323::::::saslauth:!! : 17344::::::mailnull:!! : 17344::::::smmsp:!! : 17344::::::test:$1$lv1g6wil$gprgn2db1dftlihgc9fbw.:17365:0:99999:7:::zabbix:!! : 17373:0:99999:7::: fxq1:$1$b5o76dkm$sougjjiu7px5avbewrz/o/:17386:0:99999:7:::user2:!! : 17391:0:99999:7:::user3:!! : 17391:0:99999:7:::[[email protected]_46_188_centos ~]#
2. Lock user and Unlock user

At the password! * They are not allowed to log in.

Passwd-l user2 put the user password before adding!!

passwd-u user2 Unlock user password

Usermod-l User2 can also lock the user User2

Usermod-u user2 Unlocking User User2

3. A command in the script changes the password of the user user2:

passwd--stdin user2 change user password

[[Email Protected]_46_188_centos ~]# passwd--stdin user2changing password for user User2.123456passwd:all Authenticatio N Tokens updated successfully. [[Email Protected]_46_188_centos ~]#
    • echo "qing123." | passwd--stdin User2

[Email Protected]_46_188_centos ~]# echo "qing123." | passwd--stdin user2changing password for user User2.passwd:all authentication tokens updated successfully. [[Email Protected]_46_188_centos ~]#

Echo-e "123\naaa" implements \ n line-break usage

    • Echo-e "qing123.\nqing123." | PASWD User2

[Email protected]_46_188_centos ~]# echo-e "qing123.\nqing123." | passwd user2changing password for user user2. New Password:retype New Password:passwd:all authentication tokens updated successfully. [[Email Protected]_46_188_centos ~]#
4. Password Security settings:
    • Greater than 10 bits

    • Contains numbers, uppercase and lowercase letters, special symbols

    • cannot be set with regularity

    • Cannot contain information such as name, birthday, etc.

Iii. mkpasswd Order

MKPASSWD Generate Anytime Password tool: (Make passwd)

If you do not have the MKPASSWD command, install the expect package

Yum Install expect

Options:

-l length number of digits

-s special sign bit number

[Email protected]_46_188_centos ~]# mkpasswd [email protected][[email protected]_46_188_centos ~]# mkpasswd-l 12yme0qzt#3xfe[[email protected]_46_188_centos ~]# mkpasswd-l 12-s 3g\fn%ha2nw7*[[email protected]_46_188_centos ~]# Mkpasswd-l 12-s 08oakipqcnfw3[[email Protected]_46_188_centos ~]#

Mkpasswd-l 12-s 0 Length 12 bits without special symbols


This article is from the "Feng Xiaoqing blog" blog, make sure to keep this source http://fengyunshan911.blog.51cto.com/995251/1956572

Linux usermod, user password management and password random generation tool mkpasswd

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.