On Debian 12, the root user has unrestricted access to the entire system. For security reasons, it is better to use a regular user account and grant it elevated privileges through sudo only when needed. The sudo keyword lets you run individual commands with root-level access without logging into the root account directly or leaving a privileged session open.

This guide covers four methods to enable sudo on a user account in Debian 12: using the usermod command, using adduser, editing the /etc/sudoers file with visudo, and using the graphical Users Settings panel.

Quick Answer

Switch to root with su -, then add the user to the sudo group and activate it:

usermod -aG sudo username
newgrp sudo

Replace username with the actual account name. Log out and back in to make the change permanent.

How to Enable Sudo on a User Account on Debian 12

Method 1: Using the usermod Command

The usermod command modifies user account properties, including group membership. Use it to add an existing user to the sudo group from the root account.

Step 1: Switch to the root user:

su -
Terminal showing su - command switching to the root user on Debian 12

Step 2: Add the user to the sudo group. Replace testuser with the actual username:

usermod -aG sudo testuser
Terminal showing usermod -aG sudo testuser command adding testuser to the sudo group on Debian 12

Step 3: Refresh the sudo group to apply the change, then verify:

newgrp sudo
groups testuser
Terminal showing groups testuser output confirming sudo group membership on Debian 12

Method 2: Using the adduser Command

The adduser command creates new users and manages group memberships. Use it to create a new user and add them directly to the sudo group in one workflow:

adduser newdeb
adduser newdeb sudo
Terminal showing adduser and adduser newdeb sudo commands creating a new user and adding them to the sudo group

Confirm that the user now appears in the sudo group:

getent group sudo
Terminal showing getent group sudo output listing all users currently in the sudo group on Debian 12

To add an existing user (one already on the system) to the sudo group, use:

sudo adduser newuser sudo
Terminal showing sudo adduser newuser sudo command granting sudo access to an existing user on Debian 12

To remove a user from the sudo group with adduser’s counterpart:

sudo deluser newuser sudo
Terminal showing sudo deluser newuser sudo command removing a user from the sudo group on Debian 12

Method 3: Editing the /etc/sudoers File

The /etc/sudoers file controls which users and groups can use sudo and what commands they can run. Always edit it with visudo, which opens a temporary copy and validates syntax before saving, preventing errors that could lock you out of the system. Add a line in the format username ALL=(ALL:ALL) ALL to grant full sudo access:

sudo visudo
Terminal showing the /etc/sudoers file open in the visudo editor with a new user entry being added

After adding the entry, press Ctrl + S then Ctrl + X to save and exit. This also resolves the “User is not in the sudoers file” error. Verify the groups assignment:

groups newdeb
Terminal showing groups newdeb output confirming the user group memberships after editing the sudoers file

Method 4: Using the Users Settings (GUI)

Debian 12 includes a graphical Users Settings panel for managing accounts. Open the Activities search and search for Users:

Debian 12 GNOME Activities search showing the Users Settings application in the search results

Click Unlock and enter your password to enable account management:

Debian 12 Users Settings panel showing the Unlock button to allow changes to user accounts

Click Add User to open the new user creation wizard:

Debian 12 Users Settings panel showing the Add User button to begin creating a new user account

Fill in the user’s details and toggle Administrator to on before clicking Add. Administrator accounts have sudo privileges automatically. You must have sudo privileges yourself to manage other users through this panel.

Debian 12 Add User dialog showing Full Name, Username, Password fields and the Administrator toggle set to on

How to Disable Sudo on a User Account on Debian 12

To revoke sudo access from a user, run this command as root and replace testuser with the username:

gpasswd -d testuser sudo
Terminal showing gpasswd -d testuser sudo command removing testuser from the sudo group on Debian 12

Once sudo is configured, you can use it to install VirtualBox on Debian 12, schedule system tasks with Debian crontab, or build and install Debian packages from source.