Creating a Sudo-Enabled User

Creating a Sudo-Enabled User Техника
  • 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.

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

add users to sudoers group in Debian 11

Save the file by pressing Ctrl + O and exit the file by using the Ctrl +X keys.

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 h2smedia
Password:
h2sm[email protected]:/home/h2s$ cd
[email protected]:~$ sudo whoami

We 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 sudo

How to Add a Superuser in Fedora

 adduser username 
 passwd username 
 usermod -aG wheel username 
usermod command in fedora
 visudo 
 ## Uncomment to allow members of group wheel to execute any command
%wheel ALL=(ALL) ALL
Visudo command - Fedora

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
Verify sudo access - CentOS

Confirm New Sudo User

su <example username>

Example with my name:

su josh
sudo whoami
root

Add New User To Sudoers Group

sudo usermod -aG sudo <example username>

Example with my name:

sudo usermod -aG sudo josh
id <username>

Example with my name:

id josh
uid=1001(josh) gid=1001(josh) groups=1001(josh),27(sudo)
gpasswd -a <example username> sudo

Example with my name:

gpasswd -a joshua sudo
adding joshua to group sudo

Create a User Account

sudo adduser <example username>

Example with my name:

sudo adduser josh

Example of the prompt:

example set new password on new user account on debian

Example of the prompt:

new user added to debian all information is correct
cat /etc/passwd
list users to confirm sudo status on debian linux

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 
Edit wheel group - Arch linux

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-adduser-Ubuntu
 sudo usermod -aG sudo username 
 groups username 
 sudo adduser username sudo 

The verification process remains the same as before.

2. Using the Graphical Interface

  1. Go to the Applications menu and click on the Users option. You will see a list of users including the newly created user(s).
    GUI user add

  2. Click on the Unlock option, followed by the root password. You can switch to another user account by simply clicking it.
    Add-user-via-GUI

  3. 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

su

Example output of root account:

root@debian:/home/joshua# 

Оцените статью
Master Hi-technology
Добавить комментарий