How to create a sudo user on Ubuntu

sudo Is a Linux command that provides a mechanism that allows ordinary users to gain administrator privileges. In this tutorial, you will learn how to create a sudo user on Ubuntu. In this guide, we will show you how to create a new user on an Ubuntu computer and give it sudo access. You can then use that user account to execute administrative commands without having to log into the Ubuntu server in the following way: Root user.

Create a new Sudo user in Ubuntu

Follow the steps below to create a new user account and grant it sudo access. If you want to configure sudo for an existing user, skip to step 3.

1. Log in to your server

Log in to the system as the root user:

ssh [email protected]_ip_address

2. Create a new user account

Create a new user account using adduser command

adduser rasho

You will be prompted to set and confirm a new user password. Make sure the password for the new account is as strong as possible. Example output:

Adding user `rasho' ...
Adding new group `rasho' (1001) ...
Adding new user `rasho' (1001) with group `rasho' ...
Creating home directory `/home/username' ...
Copying files from `/etc/skel' ...
New password:
Retype new password:
passwd: password updated successfully

After setting a password, this command will create a home directory for the user, copy several configuration files in the home directory, and prompt you to set up information for the new user. If you want to leave all this information blank, press ENTER to accept the default settings.

Changing the user information for rasho
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]

3. Add new user to sudo group

On Ubuntu systems, by default, Sudo group be awarded Sudo visit. To add the user you created to sudo group To use usermod command:

usermod -aG sudo rasho

Test sudo access

Test now Sudo visit Use the new user account by switching to the account of rasho.

su - rasho

To use sudo command Run whoami command:

sudo whoami

if you have Sudo visit Then you will get the following output:

root

How to use sudo

To use Sudo, Just prefix the command Sudo And space:

sudo ls -la /root

Now enter the password for the new user to get a list of files:

#Output
[sudo] password for username:

in conclusion

That’s it so far. In this guide we show how Create sudo user on Ubuntu. For more details SudoSee “man sudo_root”. Do you have any questions or ideas to share? If so, please contact us via the feedback form below.

Sidebar