The use and explanation of the useradd of Linux Primary command

Source: Internet
Author: User

a system, we cannot have only one user, so we need to create other users. As server Linux is more so, in the enterprise we have to avoid direct use of the root user directly to operate.

First we need to look at the user name of the current user first.

with WhoAmI : View the user name of the current user.

Usage :

1. whoami Direct return, you can see the current user.

650) this.width=650; "title=" 1.png "src=" Http://s1.51cto.com/wyfs02/M02/83/66/wKiom1dyPA3D6YOkAAAL_UXz0fU473.png " alt= "Wkiom1dypa3d6yokaaal_uxz0fu473.png"/>

There are several ways to add users.

Method One: Interactively set the password

Useradd [ user name ]

password [ username to set password ]

650) this.width=650; "style=" Float:none; "title=" 2.png "src=" http://s4.51cto.com/wyfs02/M01/83/66/ Wkiom1dypb2qh6bdaaalgrdbkvi314.png "alt=" Wkiom1dypb2qh6bdaaalgrdbkvi314.png "/>

650) this.width=650; "style=" WIDTH:722PX;HEIGHT:229PX; "title=" 3.png "src=" http://s1.51cto.com/wyfs02/M00/83/65/ Wkiol1dypb3biifdaabclccgnuu921.png "width=" 751 "height=" 225 "alt=" Wkiol1dypb3biifdaabclccgnuu921.png "/>

Useradd There are several parameters:

-c< Notes > Add note text. Note text is saved in the remarks field of the passwd.

-d< Log in Directory > Specifies the start directory at which the user logged in.

- D change the preset value.

-e< Validity period > Specify the expiration date for the account.

-f< Buffer Days > specify how many days after the password expires to close the account.

-g< Group > Specifies the group to which the user belongs.

-g< Group > Specifies the additional group to which the user belongs.

- M automatically establish the user's login directory.

- M do not automatically create a user's login directory.

- N cancels the creation of a group named after the user name.

- R set up the system account.

-s<shell>   Specifies the shell to use when the user is logged in.

-u<uid> Specify user ID .

Method Two: One Step set user password

Useradd [ user name ]

echo "[ password to be set ]" |passwd--stdin[ username to set password ] : by Password Give Oldboy set the password.

useradd passwd Set the password for the account. You can use userdel useradd /etc/passwd text file

userdel–r [ user name to delete ]

650) this.width=650; "title=" 4.png "src=" Http://s2.51cto.com/wyfs02/M02/83/65/wKioL1dyPC_DOV7-AABSHEKWJzY893.png " alt= "Wkiol1dypc_dov7-aabshekwjzy893.png"/>

Note: This article uses the " []"There is no need to write the command when it is actually written .

If there is the wrong place can tell me, we learn together.

The use and explanation of the useradd of Linux Primary 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.