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