Linux user, group, and password management

Source: Internet
Author: User

This article mainly summarizes common commands and options for Linux users and group management.


I. User Management

1. Add a user

Command: useradd

-U UID, valid range: 0-65536
-G GID, which must already exist
-G GID, additional group, must exist
-C Note
-D User directory
-S Specify User shell
-R System User UID creation is between 1 and), the System user does not automatically create a home directory
-M You must create a home directory for the user.
-M Do not create home directories for users

Passwd USERNAME: Set the password for the user

Passwd-l USERNAME: User locked

Passwd-u USERNAME to unlock a user


2. view User attributes

Command 1: id

-U

Show UID only
-G Show only basic GID
-G Show all gids
-N It is displayed as data and used together with u, g, and other options

Command 2: finger this command tool needs to be installed separately)


3. Modify user attributes

Command: usermod

-U Modify UID
-G Modify GID
-A-G Modify the extra group. Option-a can retain the original extra group.
-C Modify comments
-S Modify User shell
-L Modify user name
-M-d Modify the home directory. The-m option can be used to move the original home directory to a new home directory.

2. Group Management

1. Add a user group

Command: groupadd

-G Specify GID
-N Create System Group

Set the password for the gpasswd GROUPNAME group.

Newgrp GROUPNAME: temporarily switch the specified group to the basic group. The password has been set)


2. Modify group attributes

Command: groupmod

-G Modify GID
-N Modify group name

Iii. Password Management

Command 1: passwd

-E The password expires and requires the user to change the password upon next login
-N Minimum Password usage days
-X Maximum days
-W Warning days
-I Inactive duration

Command 2: chage

-D Last password modification time
-M, -- mindays MIN_DAYS Shortest term
-M, -- maxdays MAX_DAYS Maximum service life
-W, -- warndays WARN_DAYS Warning days
-I, -- inactive INACTIVE Inactive days
-E, -- expiredate EXPIRE_DATE Expiration time

Command 3: usermod

-E YYYY-MM-DD Expiration time of the specified account


This article from the "Linux/Unix O & M Technology" blog, please be sure to keep this source http://wangyc.blog.51cto.com/31193/1304826

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.