Linux User Management-user account management

Source: Internet
Author: User
Tags stdin

First, the user account of the increase, delete, change, check

1> Add user------Useradd

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

2. Change the login shell to/sbin/nologin to prevent users from logging in

Format: useradd [options] User name

Common Command Options

-U: Set UID tag number

-D: Specify the user's host directory, the default value is/home/' user name '

-G: Specify the user's base group

-G: Specify additional groups for users

-e: Specify the user's expiration time

-M: Do not establish and initialize the host directory for the user

-S: Specify the user's login shell

Practice:

1) Create account stu01, host directory set to/OPT/STU01

[[Email protected] ~] #useradd-D/opt/stu01 stu01

2) Create account Stu02,uid 10001, account expires in 2018-06-30, base group is set to Stu01

[[email protected] ~]#useradd-u 10001-e 2018-6-30-g stu01 stu02

[[email protected] ~]# ID stu02
uid=10001 (stu02) gid=502 (stu01) groups=502 (stu01)

  Command: ID user name---View the user's owning information

2> Set Password------passwd

Format: passwd [options] User name

  Note: 1, the root user can modify any user's password

2. All users can modify their own password

Common Command Options

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

-L lock user account, that is, users cannot log in "shadow in the corresponding password string before adding two exclamation mark!! 】

-S View the user account status, that is, whether it is locked

Stu01 LK 2017-08-25 0 99999 7-1 (Password locked.) "Account is locked"

Stu01 PS 2017-08-25 0 99999 7-1 (Password set, MD5 crypt.) "Account is unlocked"

-U Unlock user account "Two exclamation marks added before password string when clearly locked"

--stdin getting the password from standard input

Practice:

1) Set password to stu01 for stu01 operation from standard input to Redhat

[Email protected] ~]# echo ' Redhat ' | passwd--stdin stu01

3> Modifying an existing user------Usermod

Format: usermod [options] User name

Common options

-L CHANGE the user's login name

-L Lock user account "Add 1 exclamation marks before the corresponding cipher string in shadow!" 】

-U Unlocks user account "exclamation mark added when unlocking"

-u-d-e-g-g-s Same as Useradd command

4> Password Expiration control------chage

Format: chage [options] User name

Common commands: chage-d 0 user name "Allow user to change password at first logon"

-l list Password expiration information

-e Specify the account expiration time Yy-mm-dd

-i specifies how many days to lock the account when the password expires

-m specifies the minimum number of days for password invalidation

-m Specifies the maximum number of days the password expires

5> Delete User------Userdel

Format: Userdel [options] User name

Userdel User Name "Delete user account only does not delete the host directory, mail files and other data"

Userdel-r User Name "Delete user all data"

6> view------ID of the user ID

View the user's own identity: ID

To view the identity of the specified user: ID user name

Only the identity of the private group is listed: ID-G user name, ID-GN user name

Only public groups with identity: Id-g user name, ID-GN user name

-N Identifies display name

Linux User Management-user account management

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.