Add User: useradd
-U uid specifies the UID of the new user. By default, the current maximum uid is used to add 1
-G group: Specifies the group of the new user.
-G: Specify the additional group for the new user
-D specify the Home Directory of the new user
-S specifies the shell used by new users. The default value is Bash.
-C Additional information
-E: Specifies the user expiration time.
-M: create a home directory for the new user
View the user's basic information: IDUser1: view the basic information of user1.
If you only enter the id command, the basic information of the current user will be returned. whoami can also be. Who can also.
Add User Group: groupadd
Groupadd-G 888 group2 creates a user group group2 whose GID is 888
Delete user: userdel
Userdel-r username Delete account and its home directory
Disable User Account
Disabling an account means that users are not allowed to log on to the system for the moment, and their data must be retained. you can edit the etc/passwd file and mark the row of the account to be stopped. add a ticket number to stop the user Jane.
# JANE: X: 1000: 1000: Jane,:/home/JANE:/bin/bash
You can also use another method to change the user's shell to false or null or nologin.
Jane: X: 1000: 1000: Jane,:/home/JANE:/bin/false
Jane: X: 1000: 1000: Jane,:/home/JANE:/bin/null
Jane: X: 1000: 1000: Jane,:/home/JANE:/usr/sbin/nologin
Delete user group: groupdel
Change User: usermOd
Usermod-l username disable account
Passwd-l Username Password Disabled
Usermod-u username resume Disabled Account
Passwd-u username resume disabled Password
Change User Group: groupmod
Change Password: passwd
Switch User: su
If the root account does not have a password set, it cannot run with Su to the root account.
Directly run the su command without any user name parameters. By default, the system switches back to the root user.
Note: We recommend that you use Su-user when using the su command to load environment variables of that user.
Switch user execution: sudo
Sudo passwd this command sets the password for the root user.
Sudo is equivalent to Sudo-u root command by default.
If you want to use another user, you can use Sudo-u user2 command.