User Management commands
Command name: Useradd
Function: Add user (cannot be used immediately after adding, must change user password with passwd before use)
Usage: useradd [options] User name
Option parameters:
-U manually specify UID for user
-D Manually specify the user's home directory
-C Manually specify the user's description
-g Manually specify the user's initial group
-g Specifies the user's additional group
-s manually specify the user's login shell
Command name: passwd
Function: Modify user password
Usage: passwd [options] User name
Option parameters:
-S query the password status of the user's password
-L Temporarily lock user
-U Unlock User
--stdin can be used as the user's password with the data output by the pipe character
Command name: Usermod
Function: Modify user Information
Usage: usermod [options] User name
Option parameters:
-U modify UID of user
-C Modify the user's description
-G Modify the user's additional group
-L Temporary Lock user
-U Unlock user lock
Command name: chage
Function: Modify User Password status
Usage: chage [options] User name
Option parameters:
-l lists the user's detailed password status
-D Change the password last changed date
-M two times password change interval
-M Password expiration date
-W warning days before password expires
-I grace days after password expires
-E Account Expiry time
Command name: Userdel
Function: Delete User
Usage: Userdel [-r] User name
Options:
-R Delete User's home directory while deleting user
Command name: ID
Features: View the user uid and GID, as well as information on the additional groups in which they are located
Usage: ID User name
Command name: su
Function: Switch User identity
Usage: su [option] User name
Options:
-Option to use only-switch between environment variables representing the associated user
Related commands:
-C executes only one command without switching the user identity (executing a command in that identity without switching identities)
Example:
Su-root-c "Useradd user666"
User Group Management commands
Command name: Groupadd
Features: Adding user groups
Usage: groupadd [options] Group name
Options:
-G Specify Group ID
Command name: Groupmod
Features: Modifying user groups
Usage: groupmod [options] Group name
Options:
-G Modify Group ID
-N Modify Group name
Command name: Groupdel
Function: Delete user group (cannot delete the initial group of a user, or call the primary group, because the user must exist in a group)
Usage: Groupdel Group name
Command name: GPASSWD
Function: Add user to group or remove from group
Usage: GPASSWD option group name
Options:
-A user name. Adding users to a group
-D user name. To remove a user from a group
Linux notes: User management commands and user Group management commands