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
- Sign in to your system or register a newly created one by logging in to your VPSie account.
- Connect by SSH using the credentials we emailed you.
- 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
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' ...
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 :
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
That’s all for now, I hope you’ve found this informational
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:
Log in to your Debian server as the root user.
Create a new user account by running the following command:
Replace ‘username’ with the name you want to give to the new user.
- Add the new user to the sudo group by running the following command:
usermod -aG sudo username
- Verify that the new user has been added to the sudo group by running the following command:
This will display a list of groups that the user belongs to, including the sudo group.
Log out of the root account and log in to the new user account.
To test that the new user has sudo privileges, run the following 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:
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’.