To create a user in Ubuntu, two commands are usually used: useradd and adduser. Although they have the same functions, their usage is different. This article will give readers a detailed explanation.
AD: 51CTO School: Excellent IT courses are available online!
InUbuntuTo create a user, two commands are usually used:UseraddAndAdduser. Although the function is the same, the usage is different:
1. when useradd is used, if no Parameter options are added later, for example: # The user created by sudo useradd test is the default "Three none" User: one has no Home Directory, and the other has no password, 3. No system Shell.
2. When adduser is used, the user creation process is more like a human-machine conversation. The system will prompt you to enter various information and then help you create new users based on the information.
Useradd is an ELF executable program;
Useradd adds a user name and creates a group name that is the same as the user name. However, it does not create a user name-based directory in the/home directory, nor prompts you to create a new password.
-B,-base-dir BASE_DIR specifies the base Directory of the home Directory
-D,-home-dir HOME_DIR specifies the home Directory
-G,-gid GROUP specifies gid
-L,-no-log-init do not add the user to the lastlog and
Faillog databases
Do not add a user to lastlog or failog. This user's logon record does not need to be recorded.
-M,-no-create-home do not create the home Directory
-P,-password PASSWORD specifies the password of the new user
-R,-system: Create a system account
-S,-shell SHELL specifies shell
Adduser-m-d/usr/system-s/bin/bash-p passwd system
Adduser is a perl script that allows you to set user parameters interactively.
Problem:
The-p Parameter of adduser cannot be shadow password
The parameters of/usr/sbin/usermod and useradd are similar.
Usermod-password PASSWORD username
In summary, in Ubuntu, adduser is more suitable for beginners, because you do not need to remember the cumbersome Parameter options, as long as you follow the system prompts to proceed step by step, the disadvantage is that the entire creation process is complicated and long. useradd is suitable for users with some high-level experience. It is very convenient to create a line of commands and parameters.