Ubuntu creates users adduser and useradd
The difference between adduser and useradd#
When you first contact the user management content of Ubuntu, you may have such doubts. Both adduser and useradd in Ubuntu can be used to create users. There are many introductions on the Internet about the difference between the two, but some of these introductions are not accurate. Make a comparison of the difference between the two:
- The first thing that can be determined is that both adduser and useradd can be used to create users in Ubuntu, and there is no concept of one can and one cannot;
- Useradd is usually used in Linux, and adduser is usually used in Ubuntu;
- The adduser command tends to be a process of interpersonal dialogue. It will prompt the operator to follow the steps to set up. Of course, the first two steps are to enter the password and reconfirm the password, while useradd does not have a man-machine dialogue process;
- The adduser command can be used without any parameters, and the home directory is automatically created after completion, but useradd does not work. There is a saying on the Internet that the user created by useradd does not have a password and a home directory. This statement is not accurate because useradd does not This is the case with the use of parameters, which belongs to the use of useradd to create a user has not been done.
- The useradd process of creating a user, the user name, password and home directory are carried out separately, and they correspond to:
Create a user newuser
useradd newuser
Set password for newuser
passwd newuser
Set home directory for newuser
useradd -d /home/newuser newuser
- The above three processes, if created with adduser, only need:
Create a user newuser and set the password interactively
adduser newuser
Set sudo permissions#
To add sudo permissions to users, you can use two methods to modify sudoers and adduser. The second method is recommended:
The etc/sudoers file is the file related to the sudo group, add a line in it
newuser ALL=(ALL) ALL
The second is to use the adduser command, one line directly:
adduser newuser sudo