First, commonly used commands:
(1) Create user command two:
AddUser
Useradd
(2) User Delete command:
Userdel
Ii. differences between two user-created commands
AddUser: The home directory, System shell version is automatically specified for the created user, and the user password is entered when it is created.
Useradd: The above basic settings need to be specified using the parameter option, and if no parameters are used, the user is created without a password, no home directory, and no shell version specified.
Third, the use of AddUser
For example:
$ adduser Apple
Output display:
This creates the user's home directory and password when the user name is created.
By default:
AddUser will actively invoke/etc/adduser.conf when creating a user;
The user home directory is created by default at//and created as a/home/user name
If the home directory already exists, it is no longer created, but this home directory is the home directory of the new user, and the default login will enter this directory, but this directory is not a new user, when using Userdel to delete the new user, does not delete the home directory, Because this home directory exists before it is created and does not belong to this user.
Specify the shell version for the user:/bin/bash
So the common parameter options are:
(1)--home: Specify the path to create the home directory, by default, create a directory with the same name as the user name in the/home directory, which can be specified, if a directory with the same name exists, it is no longer created and only enters the home directory at login time.
(2)--quiet: Print only warnings and error messages, ignoring other information.
(3)--debug: Locate the error message.
(4)--conf: Use the specified configuration file when creating a user.
(5)--force-badname: The default is to create a user when the/etc/adduser.conf in the regular expression check whether the user name is legitimate, if you want to use weak check, then use this option, if you do not want to check, you can/etc/ The relevant options in adduser.conf are masked. Such as:
Iv. Use of Useradd
Note: When you use the Useradd command to create a new user, the home directory is not created for the user, the shell version is not specified for the user, and no password is created for the user.
For example:
1. Create a user without using any of the parameter options:
For example, create a new user TT
$ sudo useradd tt
(1) You need to specify a login password for the user:
(2) need to specify Shell version and user login home directory for user
As shown, the last line header only appears:
$
To view the shell version, discover that it is/bin/sh:
Description This is a shell version not specified
The directory where the user logged in is the root directory:/
Although the $HOME environment variable is/HOME/TT
2. Useradd command to specify parameters for the user:
Common command-line options:
(1)-D: Specify the user's home directory
(2)-M: if there is no longer created, but this directory does not belong to the newly created user, if the home directory does not exist, it is forced to create;
(3)-S: Specifies the shell version when the user logs on
(4)-M: Do not create home directory
For example:
$ sudo useradd-d "/home/tt"-m-s "/bin/bash" tt
To modify the TT password:
$ sudo passwd tt
V. Delete User commands
Userdel
(1) Delete users only:
sudo userdel user name
(2) Delete the user's home directory together:
sudo userdel-r user name
Vi. Related documents:
/ETC/PASSWD-user account information can be viewed by users
/etc/shadow-User account information encryption
/etc/group-Group Information
/etc/default/useradd-Defining information
/etc/login.defs-System Generalized setting
/etc/skel-the directory containing the definition files
Linux User Management (1)----Create users (AddUser and useradd) and delete users (Userdel)