As a Debian 12 user after installing it the first time, you might be in a situation where the system would not let you perform Administrative tasks because your current is not part of the Sudoers group. And even for running the system update command, you need sudo access because it allows authorized users to execute administrative tasks without logging in as the root user.
So, in this tutorial, you will find the steps for adding users to the sudo group in Debian 12 Linux.
Add user to sudoers group in Debian 12
First Switch to root user
As our current user doesn’t have sudo rights on Debian, therefore we cannot add it to the sudo group with accessing Admin privileges. So, use the given command and first switch to the root user. When it asks for the password enter the one you have set for your Debian 12 root user.
Add your current user to the Debian 12 sudo group
Now, I am assuming that you already have a user on your Debian system that you want to add to the sudo group for running commands under root rights. If yes, then follow the below command.
You may get an error while usermod that the command is not found, so
First, run this:
ln /usr/sbin/usermod /usr/bin
Now, use the given syntax:
usermod -aG sudo linuxshout
Change the linuxshout in the above command with your current system user that you want to add to the sudo group.
After that refresh the sudo group:
Furthermore, if you don’t have any other user apart from root or you want to add a new user then run:
The above command will allow you to add a new user.
username with the name that you want to give your new user.
In case, due to any reason, the previously explained method couldn’t add your current user to the sudo group in Debian 12 then here is another. In this method, we directly edit the Sudoers file to add the user to it. For that use the below commands:
Switch to the root user, if you already have not.
Edit Sudoers file on Debian 12
Now, edit the sudoers file using the given command.
Add your User
Scroll down to the end of the file and add the following line.
username ALL=(ALL:ALL) ALL
Note: Replace the username with the user that you want to add to the
sudo group in Debian 12 BookWorm.
For example, here our username is linuxshout, thus the above command will be like this:
linuxshout ALL=(ALL:ALL) ALL
Save the file by pressing Ctrl + O and exit the file by using the Ctrl +X keys.
Log out and Log in again to apply the changes. After that, you will be able to use the sudo command with your current user in Debian 12 Linux systems.