Linux User Management-user account management, linux User Management

Source: Internet
Author: User

Linux User Management-user account management, linux User Management

1. add, delete, modify, and query user accounts

1> Add User ------ useradd

Note: 1. the user name should not be a pure number or start with a number.

2. Change the logon shell to/sbin/nologin to disable user logon.

Format: useradd [Option] User Name

Common Command Options

-U: sets the UID mark number.

-D: Specifies the user's home directory. The default value is/home/'username'

-G: Specifies the user's basic group.

-G: Specify the user's additional group.

-E: Specifies the user's expiration time.

-M: Do not create and initialize the home directory for the user

-S: Specifies the user's logon shell

Exercise:

 

1) create an account stu01 and set the home directory to/opt/stu01.

[Root @ stu ~] # Useradd-d/opt/stu01 stu01

 

2) create an account stu02 with the uid of 10001. The account expired on November 30,. Set the basic group to stu01.

 

[Root @ stu ~] # Useradd-u 10001-e-g stu01 stu02

[Root @ stu ~] # Id stu02
Uid = 10001 (stu02) gid = 502 (stu01) groups = 502 (stu01)

  Command: id username --- view user information

2> set password ------ passwd

Format: passwd [Option] User Name

Note: 1. the root user can change the password of any user.

2. All users can change their passwords.

Common Command Options

-D clear the user's password so that the user can log on without the password

-L locking the user account means that the user cannot log on. [add two exclamation points before the corresponding password string in shadow !!]

-S: Check whether the user account is locked

Stu01 LK 0 99999 7-1 (Password locked.) [Account locked]

Stu01 PS 0 99999 7-1 (Password set, MD5 crypt.) [Account unlocked]

-U: Unlock the user account. [clear the two exclamation points added before the timed password string]

-- Stdin obtains the password from the standard input

Exercise:

1) set the password to redhat from standard input to stu01 for stu01 operations

[Root @ stu ~] # Echo 'redhat' | passwd -- stdin stu01

 

3> modify existing user ------ usermod

Format: usermod [Option] User Name

Common options

-L change the user's login name

-L lock the user account [add an exclamation point before the password string in shadow !]

-U unlock user account [exclamation point added upon unlocking]

-U-d-e-g-G-s and useradd commands are the same

4> password validity period control ------ chage

Format: chage [Option] User Name

Common command: chage-d 0 user name [requires the user to change the password upon initial logon]

-L list password validity period information

-E specifies the Account expiration time YY-MM-DD

-I specifies how many days after the password expires to lock the account

-M: specifies the minimum number of days for password invalidation

-M specifies the maximum number of days for password invalidation

5> delete user ------ userdel

Format: userdel [Option] User Name

Userdel username [Delete only user accounts, do not delete data such as home directories and email files]

Userdel-r username [delete all user data]

6> view User id ------ id

View the user's id: id

View the user id: id Username

Only the IDs of private groups are listed: id-g username and id-gn username.

Only column IDs with public groups: id-G username and id-Gn Username

-N indicates the display name of the logo.

 

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.