Linux

Add a User to the Sudoers List in Linux

Add-User-to-Sudoers

As system administrators, performing some administrative tasks on our PC is crucial. However, it must be noted that while it is crucial to perform administrative tasks using the superuser do command (Sudo). It has the overall administrative power on your PC. This command must be used with caution so as to prevent accidental deletion and destruction of your PC. Learn how to add a User to the Sudoers List in Linux. Here are some interesting guides: How to Switch between Users in Linux, how to use Systemd Timers on Linux, how to Install PlayonLinux on a Linux System, How to install WireShark on a Linux Ubuntu System, and how to Create Symbolic Links in Linux.

Sudo, which stands for “superuser do” or “substitute user do,” is a command that allows you to run an elevated prompt without changing your identity. It is one of the most crucial commands you can use as a Linux system administrator or power user. Depending on your settings in the /etc/sudoers file, you can issue single commands as root or as another user. You can grant common users administrative access by adding them to the sudoers list.

By doing this, you can avoid having to disclose your system’s root password to other users. Users who have been added to the sudoers list can run system commands as root.

You have the ability as the root or superuser to perform functions such as installing and installing files, deleting any or all files, modifying the permissions of one or more files, and even deleting and modifying other users. Root users can also modify the system’s run level and create, change, or delete file systems.

How to add Users to the Sudoers Group

Let’s assume that you have a list of users that you wish to add to the Sudoers list already created.

Note: Before you can add a user to the sudoers list, you must first create the user. 

The steps to add users to the sudoers list are:

1. Create a New User

To create a new user, run the below command in your terminal:

sudo adduser <user name> or sudo useradd <user name>
Adding-a-user-in-Linux
Creating a New User

From the screenshot above, we create a new user tova with the adduser command. Notice that the user was assigned the user id of 1006 and added to a group named tova with the group id of 1004 and we were also prompted to supply the user details such as full name, room number, work/home phone number and so on.

Note: Adding a user with the "sudo useradd <user name>" will not prompt to supply user details but adds user automatically.

To view the user list, run:

sudo cat /etc/passwd
List-of-user
Viewing user list

2. Adding a User to the Sudoer Group

Let’s take a look at the groups we have already in our system by running the below command:

sudo cat /etc/group
Viewing-the-list-of-groups
Viewing list of Groups

As you can see, we have the sudo the group listed in the above screenshot.

Now, let’s add the user tova we created previously to the sudo group using the below command:

sudo adduser tova sudo
Added-a-user-to-Sudo-group
Adding a user to the Sudoer Group

Finally, run the sudo cat /etc/group command to verify that the user has been added to the Sudoer group successfully.

Viewing-the-list-of-groups1
User Added to the Sudeors Group

The user tova is rightly added to the Sudoers group.

I hope you found this blog post helpful. You have learned how to add a User to the Sudoers List in Linux. If you have any questions, please let me know in the comment session.

Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x