Linux usermod command, user password management, mkpasswd command

Source: Internet
Author: User
Tags stdin

Usermod Command

usermod Command is a command to change a user's properties, Usermod Similar to the usage of useradd, there are several uses of this command:

u sermod  -u number username   change the user's uid user1 user's uid 1111

650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M02/A7/18/wKioL1ngeqOz-hxKAAJffpyNavM417.png "style=" float : none; "title=" usermod command, User password management, mkpasswd command 179.png "alt=" Wkiol1ngeqoz-hxkaajffpynavm417.png "/>


u Sermod -G user group or GID username change user's gid: For example, I change the user group of the user1 user to grp:

650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M02/08/62/wKiom1ngfVqw5isPAAJu89IZBx0004.png "style=" float : none; "title=" usermod command, User password management, mkpasswd command 242.png "alt=" Wkiom1ngfvqw5ispaaju89izbx0004.png "/>


u Sermod - D path username Changes the user's home directory, for example:

650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M02/A7/18/wKioL1ngeqTxylg6AAFFxV1eGYk064.png "style=" float : none; "title=" usermod command, User password management, mkpasswd command 282.png "alt=" Wkiol1ngeqtxylg6aaffxv1egyk064.png "/>


u Sermod - s shell username changes the user's shell, for example:

650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M00/08/62/wKiom1ngfVuxph0HAAJkFri9Gdk625.png "style=" float : none; "title=" usermod command, User password management, mkpasswd command 327.png "alt=" Wkiom1ngfvuxph0haajkfri9gdk625.png "/>


  u Span style= "font-family: ' The song body '; font-weight:bold;font-size:20px;" >sermod user group or gid username   extended user Group ( expansion group ) gid Span style= "font-family: ' The song Body '; > There is only one, for example I will user1 user add one more Span style= "FONT-FAMILY:CALIBRI;" >grp2

650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M00/A7/18/wKioL1ngeqaQYYlKAAJQ73U0YKQ195.png "style=" float : none; "title=" usermod command, User password management, mkpasswd command 416.png "alt=" Wkiol1ngeqaqyylkaajq73u0ykq195.png "/>


u Sermod -G user group or gid, user group or GID username This usage can extend multiple user groups:

650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M02/08/62/wKiom1ngfV3zV-zoAAKKMgwjqZY300.png "style=" float : none; "title=" usermod command, User password management, mkpasswd command 472.png "alt=" Wkiom1ngfv3zv-zoaakkmgwjqzy300.png "/>


The ID user1 command can view the uid,gid , and user groups of the user1 User:

650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M00/A7/18/wKioL1ngeqfjCMUsAAFg03dyGGw191.png "style=" float : none; "title=" usermod command, User password management, mkpasswd command 510.png "alt=" Wkiol1ngeqfjcmusaafg03dyggw191.png "/>


User Password Management

The passwd command is a command used to modify a user's password, and many people should have used this command several times.

to change the root user's password:

650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M01/08/62/wKiom1ngfV_jPnIJAAIe1C2ysyc689.png "style=" float : none; "title=" usermod command, User password management, mkpasswd command 578.png "alt=" Wkiom1ngfv_jpnijaaie1c2ysyc689.png "/>

650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M01/A7/18/wKioL1ngeqqzVCeWAAOpNqY_Idc219.png "style=" float : none; "title=" usermod command, User password management, mkpasswd command 580.png "alt=" Wkiol1ngeqqzvcewaaopnqy_idc219.png "/>

Password Section Two * indicates that the user's password is locked, is not available, meaning that this user is not able to log on

To change the password for a normal user:

650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M02/08/62/wKiom1ngfWCASSN1AAHM5oW2t5U377.png "style=" float : none; "title=" usermod command, User password management, mkpasswd command 636.png "alt=" Wkiom1ngfwcassn1aahm5ow2t5u377.png "/>

650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M02/A7/18/wKioL1ngeqzgvid-AAPDPc3RW2w776.png "style=" float : none; "title=" usermod command, User password management, mkpasswd command 639.png "alt=" Wkiol1ngeqzgvid-aapdpc3rw2w776.png "/>

password Section two ! indicates that the user does not have a password, which means that the user is not able to log on


Passwd-l command can lock a user's password, for example, I want to lock the user1 user, after the successful lock will be in front of this user's password plus two ! Number:

650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M00/08/62/wKiom1ngfWXz0u96AATyzoJ0R_s510.png "style=" float : none; "title=" usermod command, User password management, mkpasswd command 735.png "alt=" Wkiom1ngfwxz0u96aatyzoj0r_s510.png "/>


The passwd-u command can unlock the user's password and cancel the two before the user's password ! the number disappears:

650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M00/08/62/wKiom1ngfWeytkZzAAUeLHO6RYI491.png "style=" float : none; "title=" usermod command, User password management, mkpasswd command 782.png "alt=" Wkiom1ngfweytkzzaauelho6ryi491.png "/>


The Usermod-l command can also lock the user's password, but unlike using the passwd-l command to lock the password, this command locks the password in front of only one ! Number:

650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M00/A7/19/wKioL1ngerPTDR8sAASCBIM9b6k994.png "style=" float : none; "title=" usermod command, User password management, mkpasswd command 853.png "alt=" Wkiol1ngerptdr8saascbim9b6k994.png "/>


The Usermod-u command is the lock that unlocks the password:

650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M01/08/62/wKiom1ngfWvSm_TlAARmAbXtGZg425.png "style=" float : none; "title=" usermod command, User password management, mkpasswd command 880.png "alt=" Wkiom1ngfwvsm_tlaarmabxtgzg425.png "/>


The passwd--stdin command can change the user's password, which may be used on shell scripts:

650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M01/A7/19/wKioL1ngerWzkp1rAAGhZc10ilA386.png "style=" float : none; "title=" usermod command, User password management, mkpasswd command 930.png "alt=" Wkiol1ngerwzkp1raaghzc10ila386.png "/>


Using this command to change the user password is clear text, and you do not need to enter a second confirmation password.

So you can set a string to the user's password directly with a pipe character:

650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M01/A7/19/wKioL1ngerWTwbKwAAH2mrzHpbU023.png "style=" float : none; "title=" usermod command, User password management, mkpasswd command 993.png "alt=" Wkiol1ngerwtwbkwaah2mrzhpbu023.png "/>


The ECHO-E command can appear as a line break in a single line of command

650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M02/08/62/wKiom1ngfWyydhC2AAFl8JlNGVU325.png "style=" float : none; "title=" usermod command, User password management, mkpasswd command 1023.png "alt=" Wkiom1ngfwyydhc2aafl8jlngvu325.png "/>


so you can take advantage of this even if the passwd command does not add the --stdin option, you can set the password directly with a single command:

650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M01/08/62/wKiom1ngfW2jlFAwAAJmFKT33eU151.png "style=" float : none; "title=" usermod command, User password management, mkpasswd command 1076.png "alt=" Wkiom1ngfw2jlfawaajmfkt33eu151.png "/>


The principle of setting a password:

password length is greater than or equal to 10 bits ( except for special cases )

Password to include numeric capital letters lowercase letters and special characters

The password better not be regular

Passwords do not include personal information, such as name, birthday, etc.

Password change regularly



MKPASSWD Command

mkpasswd is the abbreviation for Make password , which is a tool that is used to generate a password. Typically this command needs to be installed on its own and requires the installation of the expect package:

650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M02/A7/19/wKioL1ngerjBtYFqAAPDPXnqmGE093.png "style=" float : none; "title=" usermod command, User password management, mkpasswd command 1251.png "alt=" Wkiol1ngerjbtyfqaapdpxnqmge093.png "/>


after installation, you can use mkpasswd Command randomly generate a password:

650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M02/A7/19/wKioL1ngerii5I4yAAEfAfaFyI0533.png "style=" float : none; "title=" usermod command, User password management, mkpasswd command 1284.png "alt=" Wkiol1ngerii5i4yaaefafafyi0533.png "/>


m kpasswd - L can specify the length of the generated password, for example I specify a password that generates a length of two

650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M00/08/62/wKiom1ngfW7jzhjWAADzczKjFN4875.png "style=" float : none; "title=" usermod command, User password management, mkpasswd command 1329.png "alt=" Wkiom1ngfw7jzhjwaadzczkjfn4875.png "/>


You can also specify that the generated password includes several special symbols, for example, I want to generate a password with a password length of 3 with a special symbol:

command:mkpasswd-l 12-s 3

650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M02/08/62/wKiom1ngfW7T9PSuAAEMQY6CF9A837.png "style=" float : none; "title=" usermod command, User password management, mkpasswd command 1404.png "alt=" Wkiom1ngfw7t9psuaaemqy6cf9a837.png "/>


Or specify that the generated password does not contain special characters:

650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M00/A7/19/wKioL1ngerjx4usOAAENVDLYIq8982.png "style=" float : none; "title=" usermod command, User password management, mkpasswd command 1426.png "alt=" Wkiol1ngerjx4usoaaenvdlyiq8982.png "/>


This article is from the "12831981" blog, please be sure to keep this source http://12841981.blog.51cto.com/12831981/1972145

Linux 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.