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 -

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

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

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

Confirm that the user now appears in the sudo group:
getent group sudo

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

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

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

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

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:

Click Unlock and enter your password to enable account management:

Click Add User to open the new user creation wizard:

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.

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

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.