- Execute commands with root rights
- View files that only users with root privileges can open (e.g. the / etc / shadow file)
- In the same way, the system administrator can revoke the rights of the user by removing the user from the Sudoers file.
- Edit Sudoers file on Debian 11
- Creating Users
- Test Sudo and Install (If Necessary)
- Installing Vim
- Assigning Sudo Rights to a User
- Testing Sudo-Enabled Users
- Verdict of Sudo Debian tutorial
- Prerequisites
- Install sudo package
- How to Add a Superuser in Fedora
- Adding a sudo Account in CentOS
- Confirm New Sudo User
- Add New User To Sudoers Group
- Create a User Account
- Creating a New Superuser on Arch Linux
- Adding a Superuser on Ubuntu and Debian
- 1. The Command-Line Approach
- 2. Using the Graphical Interface
- Change to Root Account
su -
First, run this:
ln /usr/sbin/usermod /usr/bin
usermod -aG {Group} {Username}- sudo = Work with root rights
- usermod = changes a user account
- -aG = –append (adds the user to further groups), G = –groups (groups)
usermod -aG sudo rajm
adduser username
su root
Edit Sudoers file on Debian 11
Now, edit the sudoers file using the given command.
nano /etc/sudoers
username ALL=(ALL:ALL) ALL
rajm ALL=(ALL:ALL) ALL

Save the file by pressing Ctrl + O and exit the file by using the Ctrl +X keys.
Creating Users
CentOS 7, CentOS Stream 8, and CentOS Stream 9
Enter the desired password and repeat it.
Ubuntu 18.04, Ubuntu 20.04, Ubuntu 22.04, Debian 10, and Debian 11
Enter the desired password and repeat it.
Type Y and press Enter.
Suse Linux
Enter the desired password and repeat it.
Test Sudo and Install (If Necessary)
CentOS 7, CentOS Stream 8, and CentOS Stream 9
yum install sudo -y
Debian and Ubuntu
apt install sudo
Suse Linux
zypper in sudo
Installing Vim
CentOS 7, CentOS Stream 8, and CentOS Stream 9.
sudo yum install vim
Ubuntu
sudo apt-get install vim
Suse Linux
sudo zypper search vim
sudo zypper install vim
Assigning Sudo Rights to a User
CentOS 7, CentOS Stream 8, and CentOS Stream 9
Example:
localhost:~ # groups jsmith
Debian and Ubuntu
Suse Linux
Note
The vim editor has an insert mode and a command mode. You can enter the insert mode by pressing the i key. In this mode, the entered characters are immediately inserted into the text. To enter the command mode, press the ESC key afterwards. When you use the command mode, your keyboard inputs are interpreted as a command.
Caution
Testing Sudo-Enabled Users
sudo adduser h2smedia
[email protected]:~$ sudo adduser h2smedia [sudo] password for h2s: Adding user `h2smedia' ... Adding new group `h2smedia' (1001) ... Adding new user `h2smedia' (1001) with group `h2smedia' ... Creating home directory `/home/h2smedia' ... Copying files from `/etc/skel' ... New password: Retype new password: passwd: password updated successfully Changing the user information for h2smedia Enter the new value, or press ENTER for the default Full Name []: How2shout Room Number []: Work Phone []: 971684565 Home Phone []: Other []: demo user Is the information correct? [Y/n] Y[email protected]:~$
sudo usermod -aG sudo h2media
su username
It will then ask for the password for the same, enter that and then use the below command:
sudo whoami
This command output at the end shows a text: root; which means you are now a part of Sudoers group of Debian.
[email protected]:~$ su h2smediaPassword: h2sm[email protected]:/home/h2s$ cd[email protected]:~$ sudo whoamiWe trust you have received the usual lecture from the local System Administrator. It usually boils down to these three things: #1) Respect the privacy of others. #2) Think before you type. #3) With great power comes great responsibility. [sudo] password for h2smedia:root[email protected]:~$
Verdict of Sudo Debian tutorial
Prerequisites
Install sudo package
sudo apt install sudoHow to Add a Superuser in Fedora
adduser username passwd username usermod -aG wheel username
visudo ## Uncomment to allow members of group wheel to execute any command
%wheel ALL=(ALL) ALL
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.
su useradd -G wheel username passwd username su username
sudo whoami
Confirm New Sudo User
su <example username>Example with my name:
su joshsudo whoamirootAdd New User To Sudoers Group
sudo usermod -aG sudo <example username>Example with my name:
sudo usermod -aG sudo joshid <username>Example with my name:
id joshuid=1001(josh) gid=1001(josh) groups=1001(josh),27(sudo)gpasswd -a <example username> sudoExample with my name:
gpasswd -a joshua sudoadding joshua to group sudoCreate a User Account
sudo adduser <example username>Example with my name:
sudo adduser joshExample of the prompt:

Example of the prompt:

cat /etc/passwd
Creating a New Superuser on Arch Linux
su pacman -Sy sudo useradd --create-home username passwd username usermod --append --groups wheel username visudo #%wheel ALL=(ALL) ALL Remove the # symbol preceding the %wheel line and save the changes. Press Ctrl + O on the keyboard to save the file.
su username whoami sudo whoami Adding a Superuser on Ubuntu and Debian
1. The Command-Line Approach
sudo adduser username sudo usermod -aG sudo username groups username sudo adduser username sudo The verification process remains the same as before.
2. Using the Graphical Interface
- 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.
Change to Root Account
suExample output of root account:
root@debian:/home/joshua# 





