HELP!!!! screwed up /etc/sudoers

long story short:

I edited /etc/sudoers and now it no longer works. I can't sudo anything, including editing /etc/sudoers.

Gives an error like:

sudo: parse error in /etc/sudoers near line 30
sudo: no valid sudoers sources found, quitting
sudo: unable to initialize policy plugin

I cannot run

pkexec visudo

because I do not have it installed, and i cannot install it because I cannot sudo anything.

And yes, this is a production server. Not a high volume of usage, but still…

Is there any way to edit sudoers, or gain root access or am I totally screwed?

4 Replies

You can boot the Linode into rescue mode and then edit the file from there.

Or if you know the root login, you can login on the lish console for the same effect.

1. Do you have root password, or is this Ubuntu or another such distro where root login is disabled?

2. You can try using the "reset root password" feature in Linode Manager (will reboot the server).

3. If that doesn't work, use the Rescue function to reboot the machine into Finnix, and edit /etc/passwd and/or /etc/sudoers to taste.

4. Starting from today, do not edit /etc/passwd, /etc/group, and /etc/sudoers manually. Use the "vipw", "vigr", and "visudo" commands respectively. Won't help for misconfiguration, but will at least protect you from syntax errors.

Ghan_04,

You are a lifesaver. Was able to use lish as root and avoid a reboot. THANK YOU!!!!

rsk,

Thank you for your response and the tips. I will learn those commands. It's actually amazing that I hadn't screwed up that file previously while editing.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct