How to Add a User to sudo Group in Debian 12 Linux

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

 #1st method

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.

su -

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:

newgrp sudo

Furthermore, if you don’t have any other user apart from root or you want to add a new user then run:

adduser username

The above command will allow you to add a new user.

Note: Replace username with the name that you want to give your new user.

#2nd way

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.

su root

Edit Sudoers file on Debian 12

Now, edit the sudoers file using the given command.

nano /etc/sudoers

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
Add user to sudo group in Debian 12

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.

Other Articles:

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.