| Create a New User and Add in sudo group in Linux
Linux provides a multi-user system in which more than one person can interact with the same system at the same time. You have the responsibility, as a system administrator to manage the system’s users and groups by creating and removing users and assign them to different groups.
In Linux distribution, you can easily create a user account and assign the user to different groups using the useradd command. useraddis a low-level utility, Debian and Ubuntu users will use the friendlier adduser command instead.
Basic syntax for creating a user is as follows:
sudo adduser vetechno
In the above command “vetechno” is my username you can replace it if needed.
useradd command will create a new user in Linux system which has file location is /etc/default/useradd file
Now the user is created in Linux, now you have to set password. To do that run the passwd command followed by the username:
| Add in sudo group
Another method is to create a new user is given below:-
sudo adduser –force-badname <username or first_name.(dot)last_name>
Now if you want to add user to sudo group then run the following command
sudo usermod -aG sudo <username>
sudo adduser <username> sudo
In this example, we are adding the user to sudo group through the following command:-
sudo gpasswd -a <username> sudo
If you want to remove the user from sudo group then follow this command:-
sudo gpasswd -d <username> sudo
Congratulations, you have successfully created a new user and added to sudo group to your Ubuntu Linux Server 20.04 LTS system!. You can now log in to your Ubuntu server with this user account and use sudo to run administrative commands. sudo command is the safest way of running commands that require root privileges. That’s all! Feel free to leave a comment if you have any questions.