website logo

Last Updated:

Solve Username Is Not in the Sudoers File Debian Error

In a fresh Debian Linux installation, When you run the sudo command, then you get this error. In this quick blog, I will show you how to resolve this issue.

Why Username is not in the sudoers file error occurs

Before showing you the solution, it is beneficial for you to know about what is the reason this error occurs.

When you freshly install Debian Linux in your system, there is a screen where you have to create a new user.

After installation, when you logged in with that user, the Username is not in the sudoers file error is reported. This is primarily because, when Debian created the user, it doesn’t put the created user into the sudo group.

This is the opposite behavior in comparison to Ubuntu or Fedora. In Ubuntu, the user is by default added to the sudo group, that’s why you don’t face any error like this.

Solve Username is not in the sudoers file

First, check what groups your user has access to. In the command, replace the username with your original username.

groups username

If you don’t find sudo in the output, then you have to add your user to the sudo group.

  1. Switch to the root user using the following command and put your root password.
  2. Run the following command to add the username to the sudo group.
    sudo usermod -a -G sudo username
    Replace the username with your username.
  3. Now exit the terminal and restart the device.
    exit && sudo reboot

After following all the above steps one by one, the Username is not in the sudoers file error should be gone.

Sudo command does not exist

Sometimes, when you make a server install, the sudo command is not installed by default. To install sudo, run the following command.

sudo apt update
sudo apt install sudo

See Also