How to Create a user, Add User to the sudoers file, and Verify it

How to Create a user, Add User to the sudoers file, and Verify it

The creation of users is a crucial component of system management. add user to the sudoers file We’ll look at the fundamentals of managing users on a Linux system, including adding new users, allowing sudo commands, protecting passwords, and using SSH to confirm configurations.

Add User to the sudoers file Objective:

  • Creating a new user.
  • Setting their password.
  • Granting them sudo permissions.
  • Verifying the sudo configuration.

Prerequisites:

Root Access

Basic Linux Knowledge

Action Plan: 

Step 1:

Open the terminal and connect to the root user

sudo su -

Step 2:

Creating a new user.

sudo useradd -m apps

Step 3:

Setting their password. Please enter your password 

echo "apps:XXXXXXX" | sudo chpasswd

Step 4:

Granting them sudo permissions.

usermod -aG sudo apps

if the sudo group does not exist on you are server try the below command 

usermod -aG wheel apps

Step 5:

Edit the sudoers file (optional)

visudo

find this line 

# %wheel ALL=(ALL) NOPASSWD: ALL

and uncomment it like this 

%wheel ALL=(ALL) NOPASSWD: ALL

And the respective location

apps ALL=(ALL) ALL

 

Edit the sudoers file

save and close it

Step 6:

Verifying the sudo configuration.

sudo -l -U apps

The Example output is shown below.

Verifying

We have successfully added a new user named apps to the Linux server.

Thank You!

Leave a Comment