Since there are several Linux operating systems, more commonly known as distros, there are multiple ways to add a sudo user. Read on to find more about how you can use Linux commands within different distros to achieve this simple, yet essential task.

Adding a Superuser on Ubuntu and Debian

Within Ubuntu and other Debian-based distros, there are two prominent ways of adding a sudo user. You can either do it through the terminal or take the graphical approach, using System Settings.

1. The Command-Line Approach

To add a sudo user via the command line, you have to launch the terminal first. Then, type the following command:

…where username is the name of the new user that you want to create.

This command will create a new user that you can add to the sudoers group. Yet again, there are multiple ways to add a user to the sudo group. The first way is using the usermod command.

…where -a refers to the Append function and G stands for Group.

Once you’ve added the user to the sudo group, you need to check if the aforementioned command worked properly. To verify, type the following:

In case you are a power user, who prefers to avoid multiple commands, you can directly create a new superuser using a single command:

The verification process remains the same as before.

2. Using the Graphical Interface

Before adding the user to the sudo group using System Settings, you’ll have to create a new user first through the command line. Then, follow the steps given below to proceed:

Go to the Applications menu and click on the Users option. You will see a list of users including the newly created user(s). Click on the Unlock option, followed by the root password. You can switch to another user account by simply clicking it. As soon as you select it, you will see an option to convert the newly created user account into an administrator account. Toggle the button next to the Administrator label, and the account will get added as a sudo account.

Creating a New Superuser on Arch Linux

On Arch Linux, since the system doesn’t create a sudo account by default, the user has to create one manually. The first step is to get root access using the su command.

Enter the password for the root user followed by the below command:

As soon as sudo is installed, create a new user.

Set up a password for the new user using the passwd command.

Now, it is time to add the newly created user name to the sudoers list. Use the usermod command to achieve this.

You can check the sudoers file using the following command:

Once the /etc/sudoers file opens, you need to edit some user privilege specifications, located at the bottom of the sudoers file. Locate the following line in the text file:

Output:

Remove the # symbol preceding the %wheel line and save the changes. Press Ctrl + O on the keyboard to save the file.

To check if the user has been added successfully, you need to execute the following command:

The bash prompt will change to reflect the name of the new user. To verify, type:

It should display the name of the current user. To check if the new user has sudo privileges, type:

If the output displays root, then the current user has administrative access.

Adding a sudo Account in CentOS

Considering CentOS’s popularity, it would be a shame to miss out on the process of adding a sudo account in this distro. The process for adding a sudo account in CentOS is quite similar to the process specified above for Arch Linux, but with a few basic changes.

Before you create a new user, you have to log in as root. To do so, use the su command:

After logging in as the root user, it is time to create a new user, which we will then add to the sudoers list.

Set the password for this new user, using the passwd command.

Now, log in as the new user, to check if you have sudo access. To do so, enter the following commands one by one:

Output:

As soon as you hit enter after typing the first command, the system will prompt you for the password. Enter the new password to continue. The output of the above command will display root, which means that the current user has root privileges.

How to Add a Superuser in Fedora

Last but not the least, in case you are using Fedora as your primary OS, you can assign superuser privileges to a new user in a few easy steps.

To create a new user, use the adduser command as follows:

Now, set a password for the new user.

Add this newly created user to the wheel group using the usermod command.

Open the sudoers file using the following command:

Now, you need to edit some user privilege specifications. Locate the following line in the text file and uncomment the %wheel ALL=(ALL) line by removing the Pound character (#) preceding it.

Granting Superuser Privileges to New Users

Depending on which distro you are using, the process of creating new sudo users is going to be the same more or less, with a few slight differences. The idea is to make sure you are able to grant root permissions to any new administrators who will be using the distro.

Not many Linux users know about this, but sudo and su are two different commands. Although both of them perform similar functions, they are very different from one another in many aspects.