Sudo stands for superuser do means whats superuser can do. A superuser is a root user that has full system access and can do pretty much everything on the system. Tasks like installing, updating, upgrading, deleting important files, modifying configuration files, starting and stopping system services require root powers.
As these tasks can modify the system and sometimes even harm the system they require root privileges. But we can’t make everybody a root user as it will be extremely dangerous. And Linux doesn’t even have an Undo option making another root account is risky.
So to perform everyday administrative tasks sudo comes in. For instance, when a regular user wants to perform administrative tasks they can perform using sudo command. Basically sudo lets a regular user exercise some of the superuser powers. But the condition here is that the user who wants to use sudo needs to be in the sudo group on Debian.
In this guide, we will see how to create a new user and then add that user or any other user to sudoers group on Debian.
Let’s start by logging in as a root user on Debian server via SSH
# ssh root@server_ip_address
Here replace server_ip_address with the IP address of your server. If you have created a server instance without selecting an SSH key to use for authentication. Then you will typically receive a password through email use this password to login.
To create a new user we are going to use adduser command here.
# adduser newusername
For example, here we are adding nick as the new user.
# adduser nick
This command will prompt you to enter the password for the new user’s account and then confirm it by retyping. Just remember to keep a strong password. Once the password is successfully set, the command will ask about additional information of the user. You can leave all of this information blank, just hit Enter.
New users by default, will not be able to modify files out of their home directory. For that, we need to add the new user to the sudo group.
Now let’s add the new user to sudo group by using usermod command. Type the command as follows.
# usermod -aG sudo newusername
For instance we are adding nick to sudoers group
# usermod -aG sudo nick
Now as we have added the new user in sudoers group lets verify if its done properly. For that switch to the new users account.
# su - newusername
# su - nick
The above command will login you into the newuser account. You can now verify sudo access through any command.
Now when you are done and don’t need a user account anymore you can delete that account by the following command.
deluser --remove-home username
Here –remove-home option will also delete that user’s home directory. If you are not logged in as root then use sudo in that command.
Now you know how you can a new user and add that user to sudo group on Debian. And as a piece of advice always keep a secure password.
Would you like to know how can you mount NFS in Linux, just click here
You can utilize a wide range of tools as a Linux user to keep organized, manage your time, and become… Read More
Have you ever caught yourself in a situation where you need details of an audio/ video media file? When you… Read More
If you have installed Linux alongside windows in the dual boot you might have noticed that every time you boot… Read More
Linux kernel is like the core of the operating system. It's a piece of software that works as a middle… Read More
Nowadays, most Linux Distros already have Python preinstalled. But you might have a distribution that might not have Python preinstalled.… Read More
Python is one of the most popular and easy to learn programming languages. Its a widely used high-level programming language… Read More
Just so that you know we use cookies on our website. Want to know more
read here