0

I tried to do what I thought the comments in /etc/sudoers was telling me:

# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.

Then:

: ~ ; visudo --help
visudo - safely edit the sudoers file

usage: visudo [-chqsV] [-f sudoers] [-x file]

But I didn't read the bit after that more carefully, so I typed:

sudo visudo -x /etc/sudoers.d/dci

Instead of

sudo visudo -f /etc/sudoers.d/dci

Now, I'm stuck. Any command I try to do with sudo gives me:

>>> /etc/sudoers.d/dci: syntax error near line 1 <<<
>>> /etc/sudoers.d/dci: syntax error near line 1 <<<
>>> /etc/sudoers.d/dci: syntax error near line 2 <<<
…
>>> /etc/sudoers.d/dci: syntax error near line 58 <<<
sudo: parse error in /etc/sudoers.d/dci near line 1
sudo: no valid sudoers sources found, quitting
sudo: unable to initialize policy plugin

And without sudo, unsurprisingly:

: ~ ; rm /etc/sudoers.d/dci
rm: remove write-protected regular file ‘/etc/sudoers.d/dci’? y
rm: cannot remove ‘/etc/sudoers.d/dci’: Permission denied

How do I fix this?

Update:

After trying the solution from this question, I got the following result:

: ~ ; pkexec visudo
==== AUTHENTICATING FOR org.freedesktop.policykit.exec ===
Authentication is needed to run `/usr/sbin/visudo' as the super user
Authenticating as: DCi Admin,,, (dci)
Password: 
polkit-agent-helper-1: error response to PolicyKit daemon: GDBus.Error:org.freedesktop.PolicyKit1.Error.Failed: No session for cookie
==== AUTHENTICATION FAILED ===
Error executing command as another user: Not authorized

This incident has been reported.

I was guessing this was because I was supposed to be using root password, but that's possibly a wrong guess.

This solution then fixed that problem.

  • Thanks, Mark, that's definitely a possible duplicate. I'm trying to get that answer working for me. Sadly, I don't (yet) have the password for root itself (nor physical access), just sudo access. – Ben Hocking Nov 09 '18 at 15:10
  • Just use your user password . – mja Nov 09 '18 at 15:11
  • @MarkJ.Adams — that didn't work, but possibly I guessed incorrectly at the reason. I'll update my question with details. – Ben Hocking Nov 09 '18 at 15:23
  • 1
    There should be a button on your question that allows you to accept a suggested duplicate and close your question. Closing is better than deleting, as it can help people who would find your question on google etc. to get redirected to a solution. – Byte Commander Nov 09 '18 at 15:50

0 Answers0