This post shows students and new users the steps to add a user to the sudoers file on Ubuntu Linux. The sudoers file is a file used on Linux systems to grant administrative rights to system users.

The administrator or root account in Linux gives you a lot of power. The root user can change the run level of a system, change and remove any files, remove software, add and remove accounts, and much more.

You can practically do anything on Linux with the root account.

Using the root account to manage your system can be dangerous. In most cases, you will not have a chance to confirm that you want to run certain tasks before running them, even if the commands would damage the system.

This is why a sudo process was added to avoid running Linux as root. With sudo, there are some checks and safeguards to prevent users from executing commands that will cause serious damage without first confirming the actions.

To understand the sudo and su command and how they work, read the post below:

What are sudo and su commands in Ubuntu Linux?

Now that you understand sudo and su, continue below to learn how to add a user to the sudoers file to allow the user to execute commands with the sudo process.

How to add a user to the sudoers file to run the sudo command

To allow the normal user to run commands with administrative privileges on Ubuntu Linux, you have to make them use the sudo process. You can achieve it in two ways:

YOU CAN ALSO READ:   How to pair a Bluetooth device with Ubuntu Linux

One way is to add the user to the sudoers group that is already specified in the sudoers file with all the necessary administrative permissions. The other is to manually add the user to the sudoers file that defines what elevated privileges to assign to the user.

We will show you how to do it below.

How to create a user in Ubuntu Linux

If you still don’t know how to create a user account on Ubuntu Linux, the post below should help you do it.

Read the post below to learn how to create a user on Ubuntu Linux

How to create a user in Ubuntu Linux

Now that you know how to create and delete users in Ubuntu Linux, continue below to learn how to add a user to the sudoers file.

To add a user to the sudoers, use the usermod command to add the user to the sudoers group.

sudo usermod -aG sudo username

Replace the username with the name of the user account in Ubuntu.

For example, to add a user named octopus to the sudoers group, run the following commands:

sudo usermod -aG sudo octopus

You can then verify that octopus belongs to the sudo group by running the following commands.

groups octopus

One of the groups listed will be the sudo group. Now octopus can use the sudo command process to run administrative tasks.

Another way to add allow octopus to run with root or sudo privileges is to add the account to the sudoers file. As mentioned above, the sudoers file defines the privileges of users and groups.

YOU CAN ALSO READ:   How to use Android apps on Linux without an emulator

The sudoers file in / etc / sudoers it can be invoked using the following command.

sudo visudo

Now to allow octopus to run with root privileges, add the line below in the file and save it.

octopus ALL=(ALL:ALL) ALL

Save closing the file and octopus should run commands as administrator.

You should do that!

Conclusion:

In this tutorial we have seen how to add a user to the sudoers file in Ubuntu Linux. If you find any errors above or have something to add, use the comment form below.

Write A Comment