Score:0

I edited /etc/sudoers and now I cannot use sudo anymore

cn flag

I made the following change in the file /etc/sudoers:

sudo  ALL=(ALL) NOPASSWD:ALL

And now I can't use sudo and can't edit /etc/sudoers anymore:

/etc/sudoers: near line syntax error 31 <<<
sudo: parsing error in /etc/sudoers near line 31
sudo: no valid sudoers source found; going out
sudo: unable to initialize policy plugin

Is there a way to solve this problem or will I have to format my ubuntu 20.04?

Charles Green avatar
cn flag
If you can boot from a USB, you could mount the disk, find the 'bad' file and edit the line so that it reads correctly. I would eliminate the new line, and in the future, I would use `sudo visudo ` to edit the file: you can also do `sudo visudo -f /path/to/file` when fixing your current file.
guiverc avatar
cn flag
The first error in the `/etc/sudoers` file becomes the EOF (end-of-file) marker; which is why the `visudo` command exists; ie. it will validate for errors & let you correct before exit if error(s) exist. FYI: yeah it's `visudo` but it will use whatever editor you've told it to, which may not be `vi`
hr flag
If it's a desktop system, and you're logged in locally, you *may* be able to use `pkexec visudo`. See for example [How to modify an invalid '/etc/sudoers' file?](https://askubuntu.com/a/73872/178692)
waltinator avatar
it flag
This problem is why one Always has a `root` shell open on another tetminal/ssh session when one is futzing with authentication stuff. This gives one a chance of recovery without booting from a Live USB.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.