How to Add or Create a New Superuser on Linux – Guide

Granting administrator privileges to a new user can be tricky for beginners. See How to easily create a new superuser on Linux. On Linux, the sudo command offers the privilege final to perform various administrative functions despite its non-root access. But to use sudo, you need to have a superuser account on your system. As there are several Linux operating systems, better known as distros, there are several ways to add a sudo user. Read on to learn more about How to use Linux commands in different distros to accomplish this simple but essential task.

Add a superuser on Ubuntu and Debian

In Ubuntu and other Debian-based distros, there are two prominent ways to add a sudo user. You can do this through the terminal or take a graphical approach using System Settings.

1. The command line approach

To add a sudo user via the command line, you must first start the terminal. Then type the following command: sudo adduser username … Where username is the name of the new user you want to create. This command will create a new user that you can add to the sudoers group. Again, there are several ways to add a user to the sudo group. The first way is using the usermod command. sudo usermod -aG sudo username … Where -a refers to the Append function and G stands for Group. After adding the user to the sudo group, you need to verify that the mentioned command worked correctly. To verify, type the following: group username In case you are an advanced user, who prefers to avoid multiple commands, you can create a new superuser directly using a single command: sudo adduser sudo username 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 will have to create a new user first via the command line. Then follow the steps provided below to proceed:

Creating a new superuser in Arch Linux

On Arch Linux, since the system does not create a sudo account by default, the user must create one manually. The first step is to get root access using the su command. su Enter the password of the root user followed by the command below: pacman -Sy sudo Once sudo is installed, create a new user. useradd -create-home username To define up a password for the new user using the passwd command. username password Now, it’s time to add the newly created username to the sudoers list. Use the usermod command to do this. usermod –append –groups wheel username You can check the sudoers file using the following command: visudo Once the /etc/sudoers file is opened, you will need to edit some user privilege specifications, located at the bottom of the sudoers file. Locate the following line in the text file: #% wheel ALL = (ALL) ALL Remove the # symbol before the % wheel line and save your changes. Press Ctrl + O on your keyboard to save the file. To verify that the user was successfully added, you need to run the following command: username su The bash prompt will change to reflect the new user’s name. To verify, type: Who am I It should display the current username. To verify that the new user has sudo privileges, type: sudo whoami If the output displays root, the current user has administrative access.

Adding a sudo account on CentOS

Considering the popularity of CentOS, it would be a shame to miss the process of adding a sudo account to this distro. The process for adding a sudo account in CentOS is quite similar to the process specified above for Arch Linux, but with some basic changes. Before creating a new user, you must log in as root. To do this, use the su command: su After logging in as root user, it’s time to create a new user, which we will then add to the sudoers list. useradd -G wheel username Set the password for this new user using the passwd command. username password Now log in as the new user to verify that you have sudo access. To do this, type the following commands one by one: username su sudo whoami As soon as you press Enter after entering the first command, the system will ask for the password. Enter the new password to continue. The output of the above command will display root, which means the current user has root privileges.

How to Add a superuser in Fedora

Last but not least, if you are using Fedora as your main operating system, 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: adduser username Now set a password for the new user. username password Add this newly created user to the wheel group using the usermod command. usermod -aG wheel username usermod command in fedora Open the sudoers file using the following command: visudo 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 (#) that precedes it.

Uncomment to allow group wheel members to execute any command

% wheel ALL = (ALL) ALL

Final note

I hope you like the guide How to Add or Create a New Superuser on Linux. In case if you have any query regards this article you may ask us. Also, please share your love by sharing this article with your friends.

How to Add or Create a New Superuser on Linux  2022  - 54How to Add or Create a New Superuser on Linux  2022  - 75How to Add or Create a New Superuser on Linux  2022  - 81How to Add or Create a New Superuser on Linux  2022  - 45