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

Perhaps one of the scarier Unix and Linux warning messages for newcomers comes in the form of “____ is not in the sudoers file. This incident will be reported.” In the case of an actual error message, the underscores would be replaced with your username, which makes it sound like someone is going to hear about your mistake!

You don’t have to worry too much, though. The message about the incident being reported is just a note that it will go down in the system log, which at one point had to be looked at by a system administrator for possible exploits. If you’re on a single-user system, then you have nothing to worry about except using the following steps to fix this common problem. No one is going to see a report of what happened.

Method 1: Fixing sudo with the usermod app

Try reproducing the error by running sudo -i by itself. You’ll be asked to enter your password, and once you do you should have a root shell. If this is the case, then type exit to get out of it. At this point, you should be able to resume using sudo to run commands as root without any further playing around.

Assuming it didn’t, then you’ll need to get root access some other way. You can hold down Ctrl+Alt+F2 to get a virtual terminal and attempt to log into your system as the root user if you’re on a Debian, Arch, Fedora, CentOS or other machine that gives you the authority to do so.

Once you’re there, run usermod -aG sudo,adm ____, replacing the underscores with your actual user name. You probably won’t see any output at all. Exit out of the root prompt and then push Ctrl+Alt+F7 to head back to your graphical desktop.

Now you’ll be able to use sudo like normal because you’ll be in the sudo group. To check and make sure that you are, run getent group sudo as a regular user.

You should find your name listed there. Now run id by itself and it should also list you in the sudo group.

Method 2: Resetting an Ubuntu Password

That process is easy enough except for the fact that Ubuntu, and it’s other spins like Xubuntu, Kubuntu and Lubuntu, block you out of the root account. This generally helps to reduce the risk of “This incident will be reported” type error messages, but if you’re seeing this then something irregular happened with multiple user accounts and you might no longer have access to the account you created when you installed whatever *buntu system you’re running. Only do the following if you don’t recall the password.

If this is the case and you’ve lost the password, then save all your work and close anything you have open. Reboot the system and after the BIOS or UEFI logo flashes, quickly push the shift key. Select “Advanced options for Ubuntu” and then select the recovery mode.

Scroll down to root prompt and then run mount -o rw,remount / followed by passwd ____, replacing the underscores with the name of the account your originally created. Enter a new password and then restart. Some users are surprised at how easy it can be to replace this password, but this shouldn’t be an issue as long as you’re sure to never give up physical access to your system.

Regardless of if you just reset it or if you remembered it, then open up a terminal and run sudo usermod -aG sudo,adm ____, having once more replaced the blank with the name of the account you first created. You’ll be prompted for your password. As soon as you’ve done so, then you’ll be able to use the sudo command like normal from this account again.

You may wish to check that the changes stuck. Try running getent group sudo followed by id, as we had done before, to make sure that everything is working correctly.

Assuming that you see sudo somewhere in the output of both of these commands, you should be all set. You won’t have to manually edit the sudoers file using visudo or do any of the other steps that you might be familiar with if you’ve ever done any troubleshooting with this problem in the past, provided that these two commands have cleared properly.

ABOUT THE AUTHOR

Kevin Arrows


Kevin Arrows is a highly experienced and knowledgeable technology specialist with over a decade of industry experience. He holds a Microsoft Certified Technology Specialist (MCTS) certification and has a deep passion for staying up-to-date on the latest tech developments. Kevin has written extensively on a wide range of tech-related topics, showcasing his expertise and knowledge in areas such as software development, cybersecurity, and cloud computing. His contributions to the tech field have been widely recognized and respected by his peers, and he is highly regarded for his ability to explain complex technical concepts in a clear and concise manner.