Similar to groups, Ubuntu provides command line tools to manage users and GUI tools to manage users. In comparison, the command line tool is more powerful and flexible. Common User management command line tools include: useradd -- Add a new user to Linux. The options that can be customized mainly include the user's/home directory and start group. (The default/home directory is/home/username, and the default group name is username.) useradd-D -- this command is used to create a new user.
Similar to groups, Ubuntu provides command line tools to manage users and GUI tools to manage users. In comparison, the command line tool is more powerful and flexible. Common User management command line tools include:
Useradd -- Add a new user to Linux. The options that can be customized mainly include the user's/home directory and start group. (The default/home directory is/home/username. The default group name is the user name)
Useradd-D -- this command is the default setting when the system creates a new user. If no parameters are used, the current default settings of the system are returned.
Userdel -- this command completely removes the user account (including deleting the/home directory of the user and all files in the directory ).
Passwd -- "authentication tokens" used to update the password management system"
Usermod -- Change User attributes. The most commonly used parameters include-s to change shell and-u to change UID. When a user logs on to the system or runs a program, the user attributes cannot be changed.
Chsh -- this command changes the user's default shell. For Ubuntu systems, the default shell is/bin/bash, that is, Bourne Again Shell.
The following is a simple example to create a user. Here we use the-p option to set the password, the-s option to set the shell, and the-u option to set the UID (when using the default settings to create a user, you do not need to specify these options ).
Sudo useradd sunny-p AbcDe-s/bin/zsh-u 1042
Monitor user ACTIVITIES IN THE SYSTEM
The w command can tell the system administrator which users are logged on to the system, where they are logged on, and what are currently being done. Add the user name after the w command to return only the status of a specific user.
The ac command returns the user's total link time. It obtains information from the/var/log/wtmp file. To use the ac command, install the acct software package.
The last command retrieves information from/var/log/wtmp and lists all login records created by users from this file.
The lastb command outputs all failed/wrong logins, which provides good guidance for system maintenance.
To lock a user's account, run the following command: sudo passwd-l username. You can use the-u option, that is, sudo passwd-u username.