How to use adduser command In Linux

In this approach, we will use the adduser command, The adduser command is a wrapper around the basic system management commands like useradd and usermod, … and is commonly found in Debian-based systems like Ubuntu. This command can add a new user and also able to update a user account Information with the provided data. To add the user to the sudo group, the user should exist in the system.

Command:

sudo adduser username sudo

Output:

Using adduser Command

In the above image, we can verify whether the user is added to the sudo group with the id command.

How to Add User to Sudoers in Ubuntu

Sudo is a command line tool in a Unix-based system that allows a regular user to run a command as the superuser or another user. Only the super user is allowed to modify the majority of the System-wide settings and configurations. It is not advisable to run any Linux machine as a super user, so always create a normal user for day-to-day usage. To use the super user privileges we don’t need to log in as root users every time, just provide the sudo rights to a normal user to portray the normal user as a root user. It is often done with the help of Sudo group or sudoers file in Linux systems.

In this article, we will discuss how to add a normal user to the sudoers list so that the normal user can use the Sudo command to perform privileged operations.

Similar Reads

How to Add User to Sudoers in Ubuntu?

In this section, we will see how we can add users to Sudoers in the Ubuntu environment. We have five different methods which are listed below....

Method 1: Using the usermod command

In this method, we will use the usermod command, usermod is a system management command found in every major Linux distribution to modify the information of a user account. Here, we are going to modify the newly created user account by adding the user account to a group called sudo. For this command to work, the given user account should exist in the system, if not create an account with the command (sudo adduser username}....

Method 2: Using the useradd command

In this approach, we will use the useradd command, useradd command is a system management command used to create or update the default new user Information of the user account. It is the command commonly used to create a new user in Linux systems. To use this command the user should not exist in the system, as it can’t update the existing user rather it can update the defaults of the new user....

Method 3: Using adduser command

In this approach, we will use the adduser command, The adduser command is a wrapper around the basic system management commands like useradd and usermod, … and is commonly found in Debian-based systems like Ubuntu. This command can add a new user and also able to update a user account Information with the provided data. To add the user to the sudo group, the user should exist in the system....

Method 4: Using gpasswd command

In this approach, we will use the gpasswd command, gpasswd is a user command to administer the group functionality like adding a member to the group, removing a member, etc. For this command, the user should exist in the system, and pass the user name along with the group to add the user to the command....

Method 5: using visudo command

visudo is a special command used to edit the sudoers file. visudo edits the “/etc/sudoers” to provide a user sudo privilege. It also checks the syntax for the sudoers file, it is the preferred way of editing the sudoers file as any syntax error may result in losing sudo access to the system. By default, ubuntu uses nano to open the sudoers file, you can change that with update-alternatives....

Conclusion

In conclusion, sudo is an important command that needs to be handled with care to maintain the security of your system. Make sure you only allow trusted users to be a part of sudoers in your system for better security and reliability. To conclude we have seen different approaches to add users to the sudoers list in the Ubuntu system with examples....