How To Fix ‘Not In Sudoers File’ in Debian 12 Bookworm

After logging into Debian 12 Bookworm, if you try running different commands using sudo, you will see an error that is something like this.

User not in sudoers file error in Debian

For that, you will have to edit the sudoers file. To do that, first switch to the root account by typing in the Terminal:

su root

After switching to root, edit the sudoers file that is found in /etc. You can open it with any text editor like vi or nano for this.

Open sudoers file using any text editor like nano or vi

After opening this sudoers file, scroll down to the User privilege specification section, and add the username below the root privileges.

add the user to sudoers file

Save the changes and exit.

Switch back to the user from before and try running the previous commands again. They will now complete successfully without any errors.

sudo access is now granted to the user after editing the sudoers fille

All done.

Leave a Comment