Fixes and solutions are “not in the sudoers file. This incident is reported.” Fedora RHEL CentOS Debian Error

Attempting to execute commands using sudo on Fedora, RHEL, CentOS, Debian and other Linux distributions gives the following error:

USERNAME is not in the sudoers file. This incident will be reported.

Where USERNAME is the currently active login username. Here, my system username is “manikandan” and the error message is

manikandan is not in the sudoers file. This incident will be reported.

On Fedora, RHEL, CentOS or Debian, and some other Linux distributions, by default, normal users cannot execute commands with root privileges. On Linux, there are two common ways to execute commands as root administrator privileges. This can be done with the “su” and “sudo” commands. Here you can use su and root password. Like “su root”. But this is not a good practice. However, you can use the sudo command with your own user password. It can only be used by a user authorized by the administrator (root user). This allows you to access the system without sharing the password of the root user.

Resolution or fix “The sudoers file is not found. This incident will be reported.” Error:

To correct this error, you need to add the user to Sudoers, add the user to the sudo group, or add the user to the wheel group. This solution works for all Redhat-based Linux distributions.

1. Enable Wheel Group [Fedora, RHEL, CentOS Based OS]

By default, Fedora and Redhat-based distributions have a user group called the “wheel” group. Members of the wheel group are automatically granted sudo privileges.

Open a terminal, run this command in the terminal and log in as root.

su root

Next, enter the root password.

Then run this command and press Enter.

visudo

Press the down arrow key to scroll down the text on the terminal and find the line in the file that allows sudo access to group wheel users when enabled.

Fixes and solutions are "not in the sudoers file. This incident is reported." Fedora RHEL CentOS Debian Error

## Allows people in group wheel to run all commands
%wheel ALL=(ALL) ALL

If you find the above line without the # before% wheel ALL = (ALL) ALL, it means that sudo is already set up and enabled. If not, delete the # in front of% wheel, save and exit the editor.

Enable Sudo group [Debian & Based OS]

By default, Debian and base distributions have a user group called the “sudo” group.

Open a terminal, run this command in the terminal and log in as root.

su root

Next, enter the root password.

Then run this command and press Enter.

visudo

Press the down arrow key to scroll down the terminal text and find this line

## Allows people in group wheel to run all commands
%sudo ALL=(ALL) ALL

If you find the above line without the # before% sudo ALL = (ALL) ALL, it means that sudo is already set up and enabled. If not, remove the # in front of% sudo, save and exit the editor.

2. Add user to wheel or sudo group

In a terminal, run this command as root user. (Su root)

[Fedora, RHEL, CentOS & Based OS]

usermod -aG wheel USERNAME

Here you can replace USERNAME with your actual username. Manikandan for me

usermod -aG wheel manikandan

[Debian & Based OS]

usermod -aG sudo USERNAME

After adding the user to the wheel or sudo group, execute the following command to switch the user.

su USERNAME
su manikandan

Then run this command and confirm

groups

It looks like this:

Fixes and solutions are "not in the sudoers file. This incident is reported." Fedora RHEL CentOS Debian Error

Run now

sudo whoami

You will get the answer as root.

Fixes and solutions are "not in the sudoers file. This incident is reported." Fedora RHEL CentOS Debian Error

You have configured sudo correctly. You can now execute the command using sudo.

Note: This tutorial uses Fedora to correct this error.

.

Sidebar