Search
Close this search box.

How to Create a Sudo User on Debian

Table of Contents

How to Create a Sudo User on Debian

Sudo is a program that runs on Unix-like computer operating systems that enables users to execute programs under the privileges provided by another user, usually the superuser. Sudo refers to either “substitute user do” or “super user do” – either of which allows you to temporarily elevate your user account to have root privileges. This is not the same as “su”, which has a more permanent effect.

 

 

Our goal here is to walk you through setting up a sudo user on Debian,

 

 

Step 1: Configure VPSie cloud server

 

 

  1. Sign in to your system or register a newly created one by logging in to your VPSie account. 
  2. Connect by SSH using the credentials we emailed you.
  3. Once you have logged into your Debian instances and update your system.

 

Run the command to upgrade your system,

apt-get update && apt-get upgrade -y

 

 

Step 2: Install sudo

 

Installing Debian Without sudo is possible. In that case, add sudo via apt-get,

 

apt install sudo

 

Step 3: Add a New User Account

 

 

Use the adduser command to create a new user account. The user information can be filled in or left blank by pressing ENTER. A user named “testuser” will be created here.

 

adduser testuser

 

# adduser testuser
Adding user `testuser' ...
Adding new group `testuser' (1000) ...
Adding new user `testuser' (1000) with group `testuser' ...
Creating home directory `/home/testuser' ...
Copying files from `/etc/skel' ...
New password:
Retype new password:
passwd: password updated successfully
Changing the user information for testuser
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] y

 

Step 4: Set up the Sudo Group for the User and test it

 

Include the new user in the sudo group,

 

adduser testuser sudo

It’s now time to test, 

su - testuser

 

#  su - testuser
testuser@Debian:~$

 

That’s all for now, I hope you’ve found this informational

 

one-click apps VPSie

 

 A sudo user on Debian is a user account that has been granted permission to execute administrative commands as the superuser or root user. This allows the user to perform tasks that require elevated privileges, such as installing software or modifying system configurations.

To create a sudo user on Debian, follow these steps:

  1. Log in to your Debian server as the root user.

  2. Create a new user account by running the following command:

 
adduser username

Replace ‘username’ with the name you want to give to the new user.

  1. Add the new user to the sudo group by running the following command:
 
usermod -aG sudo username
  1. Verify that the new user has been added to the sudo group by running the following command:
bash
groups username

This will display a list of groups that the user belongs to, including the sudo group.

  1. Log out of the root account and log in to the new user account.

  2. To test that the new user has sudo privileges, run the following command:

bash
sudo command

Replace ‘command’ with the command you want to execute with elevated privileges.

Yes, you can customize the sudoers file on Debian to control which users and commands have sudo privileges. However, it is important to be careful when making changes to the sudoers file, as incorrect configurations can cause security vulnerabilities. To edit the sudoers file, run the following command:

 
sudo visudo

This will open the sudoers file in the nano text editor. Make your changes and save the file by pressing ‘Ctrl+X’, ‘Y’, and ‘Enter’.

Make a Comment
Share on
Facebook
Twitter
LinkedIn
Print
VPSie Cloud service

Fast and Secure Cloud VPS Service

Try FREE
For a month

The First 1 orders gets free discount today! Try Sign up on VPSie to get a chance to get the discount.