How to fix and solve “is not in the sudoers file. This incident will be reported.” error on Fedora RHEL CentOS Debian

When you try to run any command with sudo in Fedora, RHEL, CentOS or Debian and some other linux distro, then you will get below error.

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

Here USERNAME is your current active logged in username. Here my system username is “manikandan” and my error message,

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

In Fedora, RHEL, CentOS or Debian and some other Linux distributions by default the regular user does not have an ability to execute commands with root privileges. In linux there are two common ways to execute commands as the root administrator privileges. You can do this by “su” and “sudo” commands. Here you can use the su with your root password. Like “su root”. But this is a not a good practice. But you can use the sudo command with your own user password. This can only be used by users who have been authorized by the administrator (root user). Using this you can access the system without sharing the password of the root user.

 

Solve or Fix “is not in the sudoers file.This incident will be reported.” error:

To fix this error you need to add the user to Sudoers or add user to sudo group or add user to wheel  group. You can use this solution for all Redhat based linux distributions.

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

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

Open your terminal, In terminal run this command to login as root.

su root

Then type your root password.

Then run this command and hit enter.

visudo

Scroll down the terminal text by pressing the down arrow key and find the lines in the file that grant sudo access to users in the group wheel when enabled.

Also Read:  How to Extract Deb Files in Ubuntu Linux

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

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

Enable the Sudo Group [Debian & Based OS]

By default, Debian and based distributions has a user group called the “sudo” group.

Open your terminal, In terminal run this command to login as root.

su root

Then type your root password.

Then run this command and hit enter.

visudo

Scroll down the terminal text by pressing the down arrow key and find this lines

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

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

2. Add user to the wheel or sudo group

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

[Fedora, RHEL, CentOS & Based OS]

usermod -aG wheel USERNAME

Here you can replace USERNAME with your actual username. For me its “manikandan”

usermod -aG wheel manikandan

[Debian & Based OS]

usermod -aG sudo USERNAME

After adding user to wheel or sudo group, then run below command to switch user.

su USERNAME
su manikandan

Then run this command to verify

groups

It will show like this.

Now run

sudo whoami

You will get answer as root.

That it you configured sudo correctly. Now you can run commands with sudo.

Note: In this tutorial i am using Fedora to fix this error.

If you liked this article, please subscribe to our YouTube Channel. You can also stay connected with us on X (Twitter) and Facebook.



Leave a Reply