0

I'm having an issue on a Ubuntu 20.04 server.

I accidentally commented out all lines in /etc/sudoers.d/username after reading this thread: https://superuser.com/a/1311042 because I recently noticed that I was able to run sudo apt-get update without being prompt for the password! Which was super strange for me, because it always asked for the password before. But before what? Before I actually play around with ansible stuff, which apparently let it manage this file for running commands without being prompt for a password... something like that (I'm not an expert with that tool, I'm learning how it works actually).

But then by commenting out all lines in the /etc/sudoers.d/username file, I can no more use any sudo <something> command! Indeed, it now always says, e.g.:

$ sudo apt-get update
[sudo] password for username: ******
username is not in the sudoers file.  This incident will be reported.

How could I get back to the normal behaviour on my Ubuntu user?

s.k
  • 1,280

1 Answers1

3

First, NEVER make changes to your system without understanding what they do. Sometimes the Internet is in error.

Second, if you're messing with any part of user authentication, always have a spare root (sudo bash) terminal session open, before you begin. I've recovered from all sorts of mistakes with this!

Now, that it's too late for these, boot from a Live USB (or your install medium, with "Try Ubuntu") and fix it from there.

Alternatively, boot into single user mode (that single user is root).

Finally, if it's a remote server managed by a company or an institution, kindly ask their customer service / IT department to undo the changes (it may take some time). They should normally have access to another super user or tools for such operation.

s.k
  • 1,280
waltinator
  • 36,399