The root or administrator account in Linux gives you a lot of power. The root user can change the run level of a system, change and remove any file, remove software, add and remove accounts and a lot more. You can practically do anything in Linux with the root account. Using the root account to manage your system can be dangerous. In most cases, you won’t get a chance to confirm that you want to execute certain tasks before executing, even if the commands would damage the system. That’s why a sudo process was added to prevent running Linux as root. With sudo, there are some checks and safeguards to prevent users from running commands that will cause serious damage without first confirming the actions. To understand the sudo and su processes and how they work, please read the post below: What is the sudo or su command on Ubuntu Linux Now that you understand sudo and su and their differences, continue below to learn how to add a user to the sudoers file to allow the user to run commands with the sudo process.

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

To allow regular users to run commands with administrative privileges on Ubuntu Linux, you need to make them use the sudo process. You can achieve this in two ways: One way is to add the user to the sudoers group which is already specified in the sudoers file with all the necessary administrative permissions. The other is to manually append the user to the sudoers file that defines which elevated privileges to assign to the user. Below we’ll show you how to do that.

How to create a user in Ubuntu Linux

If you don’t already know how to create a user account on Ubuntu Linux, then the post below should help you do that. Read the post below to learn how to create a user on Ubuntu Linux How to create a user on Ubuntu Linux Now that you know how to create and remove users on 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. Replace the username with the user account name on Ubuntu. For example, to add a user named octopus to the sudoers group, run the commands below: Next, you can verify that the octopus belongs to the sudo group by running the commands below. 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 and allow the octopus to run with root or sudo privileges is to append the account to the sudoers file. As mentioned above, the sudoers file defines the user’s and group’s privileges. The sudoers file at /etc/sudoers can be invoked using the command below. Now, to allow the octopus to run all with root privileges, append the line below into the file and save. Save the close the file and octopus should run commands as administrator. That should do it! Conclusion: This post showed you how to add a user to the sudoers file on Ubuntu Linux. If you find any error above or have something to add, please use the comment form below.