Despite your non-root access, the sudo command on Linux grants you the ultimate power to conduct numerous administrative activities. However, in order to utilize sudo, you must have a superuser account on your system.
Because there are several Linux distributions, or distros, there are numerous methods to install a sudo user. Continue reading to learn more about how to utilize Linux commands on various distros to do this basic, but critical activity.
Adding a Superuser on Ubuntu and Debian
There are two common methods for adding a sudo user in Ubuntu and other Debian-based distributions. You may do it either via the terminal or using the graphical interface, System Settings.
1. The Command-Line Approach
To add a sudo user using the command line, you must first open the terminal. After that, enter the following command:
sudo adduser username
…where username is the name you wish to give to the new user.
This command will create a new user who will be added to the sudoers group. There are many methods to add a user to the sudo group. The first method is to use the usermod command.
sudo usermod -aG sudo username
…where -a denotes the Append function and G denotes Group.
After adding the user to the sudo group, you must verify that the preceding operation was successful. To confirm, enter the following:
If you are a power user who prefers not to use numerous commands, you may establish a new superuser with a single command:
sudo adduser username sudo
The verification process remains the same as before.
2. Using the Graphical Interface
Before adding the user to the sudo group through System Settings, you must first establish a new user using the command line. Then, to continue, follow the procedures outlined below:
- Go to the Applications menu and click on the Users option. You will see a list of users including the newly created user(s) (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.
Related: How to Use sudo Commands Without Password in Linux
Creating a New Superuser on Arch Linux
Because Arch Linux does not generate a sudo account by default, the user must create one explicitly. The first step is to use the su command to get root access.
Enter the root user’s password, then run the following command:
pacman -Sy sudo
As soon as sudo is installed, create a new user.
useradd --create-home username
Set up a password for the new user using the passwd command.
It is now time to add the newly formed user name to the list of sudoers. To do this, use the usermod command.
usermod --append --groups wheel username
You can check the sudoers file using the following command:
Once the /etc/sudoers file has been opened, you must update certain user privilege parameters near the bottom of the sudoers file. Look in the text file for the following line:
Save the modifications after removing the # sign before the%wheel line. To save the file, use Ctrl + O on your keyboard.
To see whether the user has been successfully added, use the following command:
The bash prompt will be updated to reflect the new user’s name. To double-check, enter:
It should show the current user’s name. Type: sudo to see whether the new user has sudo capabilities.
If the report shows root, the current user has administrative privileges.
Adding a sudo Account in CentOS
Given CentOS’s popularity, it would be a mistake to overlook the procedure of creating a sudo account under this distribution. The procedure for creating a sudo account in CentOS is quite similar to the one described above for Arch Linux, with a few minor differences.
You must first log in as root before you can create a new user. Use the su command to do this:
After signing in as the root user, we’ll create a new user who will be added to the sudoers list.
useradd -G wheel username
Using the passwd command, create a password for this new user.
Now, log in as the new user to see whether you have sudo privileges. Enter the following instructions one by one to do this:
The system will ask you for your password as soon as you press enter after inputting the first command. To proceed, enter the new password. The result of the above command will show root, indicating that the current user has root rights.
How to Add a Superuser in Fedora
Last but not least, if you use Fedora as your main operating system, you may provide superuser rights to a new user in a few simple steps.
To create a new user, use the adduser command as follows:
Now, set a password for the new user.
Using the usermod command, add this newly generated user to the wheel group.
usermod -aG wheel username
Open the sudoers file using the following command:
You must now modify certain user privilege parameters. Locate the following line in the text file and remove the Pound character (#) before it to uncomment the%wheel ALL=(ALL) line.
Granting Superuser Privileges to New Users
The procedure of establishing new sudo users will be similar regardless of whatever distribution you use, with a few minor changes. The goal is to ensure that you can offer root access to any new administrators who will be using the distribution.
Sudo and su are two distinct commands that few Linux users are aware of. Despite the fact that they both serve comparable jobs, they are significantly distinct in many ways.
You are looking for information, articles, knowledge about the topic How to Add or Create a New Superuser on Linux on internet, you do not find the information you need! Here are the best content compiled and compiled by the achindutemple.org team, along with other related topics such as: How.