English
+370 5 205 5502 sales@monovm.com

In this guide, we will show you how to create a new user on a Debian system and give it sudo access. You can use this user account to execute administrative commands without a need to log in to your Debian server as a root user.

13

Apr, 19

How To Create a Sudo User on Debian

 

In this guide, we will show you how to create a new user on a Debian system and give it sudo access. You can use this user account to execute administrative commands without a need to log in to your Debian server as a root user.

Create a sudo user

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

step1: First, log in to your system as the root user:

$ ssh root@server_ip_address

step2: Create a new user account.

Create a new user account using the adduser command. Don’t forget to replace username with your desired user name:

$ adduser username

The command will prompt you to set and confirm the new user password. Make sure that the password for the new account is as strong as possible (combination of letters, numbers and special characters).

output

Adding user `username' ...

Adding new group `username' (1001) ...

Adding new user `username' (1001) with group `username' ...

Creating home directory `/home/username' ...

Copying files from `/etc/skel' ...

New password:

Retype new password:

passwd: password updated successfully

 

Once you set the user password the command will create a home directory for the user, copy several configuration files in the home directory and prompt you to set the new user’s information. If you want to leave all of this information blank just press ENTER to accept the defaults.

output

Changing the user information for username

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]

 

step3:Add the user to the sudo group

By default on Debian systems, members of the group sudo are granted with sudo access. To add a user to the sudo group use the usermod command:

$ usermod -aG sudo username

 

Test the sudo access

Switch to the newly created user:

$ su - username

Use the sudo command to run the whoami command:

$ sudo whoami

If the user has sudo access then the output of the whoami command will be root

 

 

How to use sudo

To use sudo, simply prefix the command with sudo and space:

$ sudo ls -l /root

The first time you use sudo in a session, you will be prompted to enter the user password:

output

[sudo] password for username:

 

You can now log in to your Debian server with this user account and use sudo to run administrative commands.

 

 

linda Y

My name is Linda, I have Master degree in Information Technology Engineering. I have some experiences in working with Windows and Linux VPS and I have been working for 2 years on Virtualization and Hosting.