• Home
  • About
  • Contact
  • Store

IT from Scratch

Small Business IT from the ground up

What to Do When Sudo is Broken

May 2, 2013 By The New Guy 2 Comments

sudo crem

Sudo is broken — maybe you need some “sudo crem”?

Permissions and ownership is a perpetual learning process for beginner Linux administrators. There are quite a few things you need to use superuser privileges for in your everyday administration. But let’s say, for instance, you broke your /etc/sudoers file (like I did) and now sudo is broken. What do you do then?

Error When Sudo is Broken

If you try to use sudo when the /etc/sudoers file is broken, you’ll get an error like this:

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

This is not a pretty sight.

And because you can’t use sudo when the /etc/sudoers file is broken, that also means that you can’t fix the file with the normal command: sudo nano /etc/sudoers.

But thankfully, all hope is not lost. There is a relatively easy way to fix this.

What to Do When Sudo is Broken

Since you can’t use sudo nano, you’ll need to use a different command.

I’m not sure exactly why this works, but if you need to edit the /etc/sudoers file when sudo is broken, you can open it with this command:

pkexec visudo

You’ll get a response like this:

==== AUTHENTICATING FOR org.freedesktop.policykit.exec ===
Authentication is needed to run `/usr/sbin/visudo' as the super user
Authenticating as: Username,,, (username)
Password:

Enter your password there, and you’ll get this:

==== AUTHENTICATION COMPLETE ===

And then the /etc/sudoers/ file will open for you to edit.

Fix what ever problem you have, save the file, and you’re back in business.

Welcome back to the realm of administrator privileges.

Image credit Nadya Peek.

Filed Under: Scratch

Comments

  1. rene bolders says

    September 6, 2013 at 7:10 pm

    Hi New Guy,
    I worked in the visudo file to make my password visible (pwfeedback) but somewhere I got a X in the file and it wouldn’t let me get back in there no matter what I tried and ofcourse I lost my sudo privileges! Thanks to your article, I was able to get back in the visudo file and fix my mistake. I would never in a million years find the command: pkexec visudo anywhere !!!! Thanks a million for publishing this insider knowledge, you shure saved me from a lot of grief and timewasting. Once again Thanks ! Rene

    PS: I don’t think you are quite a “new” guy in the Linux world 🙂

    Reply
    • The New Guy says

      September 6, 2013 at 7:40 pm

      Thanks, Rene. I’m glad this helped you out. 🙂

      Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Click Here for 500 MB free VPN connection through Private Tunnel

Recent Posts

  • How to Get the macOS Catalina Installer, Post Big Sur
  • Mac: How to Get SHA1 Hash
  • iTunes error: “You do not have enough access privileges for this operation”
  • Is Websense Filtering My Internet Traffic?
  • How to Delete a Mac VPN Profile
  • Home
  • About
  • Contact
  • Store

Copyright © 2025 ·WP-Ubuntu