How to create a new active Sudo user in Ubuntu

0 Shares
0
0
0
0

Introduction

When administering a server, sometimes you want to allow users to run commands as “root,” an administrator-level user. Command sudo It provides system administrators with a way to grant administrator privileges – normally only available to the root user – to regular users.

In this tutorial, you will learn how to create a new user with access sudo In Ubuntu, no need to change the file. /etc/sudoers Create your own server.

Step 1 – Log in to the server

SSH into your server as the root user:

ssh root@your_server_ip_address

Step 2 – Add the new Sudo user to the system

From the order adduser To add a new user to your system, use:

adduser sammy

Make sure to replace the username you want to create. Sammy You will be prompted to create and confirm a password for the user:

Output
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

Next, you will be asked to enter information about the new user. It is fine to accept the defaults and leave this information blank:

Output
Changing the user information for sammy
Enter the new value, or press ENTER for the default
Full Name []:
Room Number []:
Work Phone []:
Home Phone []:
Other []:
Is the information correct? [Y/n]

Step 3 – Add the user to the sudo group

From the order usermod To add a user to the sudo group, use:

usermod -aG sudo sammy

Again, make sure to replace the username you just added. Sammy By default in Ubuntu, all members of the sudo group have full sudo privileges.

Step 4 – Test sudo access

To test whether the new sudo permissions are working, first use the command su Use to switch to the new account:

su - sammy

As a new user, you can run the command with privileges by adding sudo to it. superuser Run, verify that you can use sudo:

sudo command_to_run

For example, you can view the contents of the directory root/ List which is usually only accessible to the root user:

sudo ls -la /root

The first time since sudo You will be prompted for the password for that user's account. Enter the password to continue:

Output:
[sudo] password for sammy:

If your user is in the right group and you entered the password correctly, the command with sudo You have exported it and it will run with root access.

Result

In this quickstart tutorial, we created a new user account and added it to the sudo group to enable sudo access.

Leave a Reply

Your email address will not be published. Required fields are marked *

You May Also Like