Share your love
Fix Error User Not in Sudoer File on Ubuntu: 1 Best Soulution

In this guide, we want to teach you How To Fix Error User Not in Sudoer File on Ubuntu. When you want to run Linux Commands with sudo privileges on your Ubuntu server, you may get this error that said User Not in Sudoer File. This will happen when the sudo user is not in the sudo group on your Ubuntu server. You can follow the steps below to fix it.
Table of Contents
How To Fix Error User Not in Sudoer File on Ubuntu?
To complete this guide, you must have access to your server as a root user. Then, follow the steps below to Fix Error User Not in Sudoer File on Ubuntu.

Step 1 – Create a non-root User on Ubuntu
First, we will create a non-root user to show you how it will happen. To do this, run the command below:
adduser orcacore
Enter a password for your user:
Output
Adding user `orcacore' ...
Adding new group `orcacore' (1000) ...
Adding new user `orcacore' (1000) with group `orcacore' ...
Creating home directory `/home/orcacore' ...
Copying files from `/etc/skel' ...
New password:
Retype new password:
passwd: password updated successfully
Changing the user information for orcacore
Enter the new value, or press ENTER for the default
Full Name []:
Room Number []:
Work Phone []:
Home Phone []:
Other []:
Is the information correct? [Y/n] y
Now switch to your user account with the following command:
su - orcacore
Step 2 – Fix User Not in Sudoers File Error on Ubuntu
At this point, when you want to try to run the sudo commands with your user, you will get the following error:
sudo -i
Output
[sudo] password for orcacore:
orcacore is not in the sudoers file. This incident will be reported.
To Fix Error User Not in Sudoer File on Ubuntu, you must add your user to the correct group. In Ubuntu servers, you just add the user to the sudo group.
To do this, switch back to your root account with the following command:
su -
Enter your root password and press enter.
Then, use the following command to add your user in the sudoers file:
usermod -aG sudo orcacore
To apply the changes, reboot your Ubuntu server with the command below:
systemctl reboot
Step 3 – Verify that the User is in the Sudoers File
When you log back to your server, switch to your user account again:
su - orcacore
You will see the following output:
Output
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.
This means that you have added your user to the sudoers file correctly.
Conclusion
At this point, you have learned How To Fix Error User Not in Sudoer File on Ubuntu. As you saw, it will happen when your user is not in the correct sudo group.
Hope you enjoy it. You may be interested in these articles:
How To Change SSH Port on Debian
Check HTTPS Port 443 is Open on Linux
How To Manually Install Driver Module in Linux
FAQs
What does the “User is not in the sudoers file” error mean?
It means that the current user has no access to admin privileges for running commands with sudo.
Why do I need sudo permissions on Ubuntu?
The sudo allows you to run commands with root privileges which is necessary for installing, managing, and performing admin tasks.
How do I verify if my user is in the sudo group?
You can use the groups username
to check the membership.