1

Not sure if this is the place for troubleshooting, but I am gonna give it a shot.

I was trying to make my computer turn off without needing sudo, and I must have done something wrong because I get a syntax error when trying to use sudo. I added an empty file in /etc/sudoers.d and added the following line:

user ALL=NOPASSWD: /sbin/reboot, /sbin/poweroff

I have done some web browsing and I think I have ruled out some possible solutions.

Cannot boot into Live CD because I can't mount a USB without sudo access.

Do not have a Super User.

I do not have pkexec installed either.

From what I have researched, I think I need to enter 'recovery mode' or somthing along those lines. I am now wondering if anyone could write a quick step-by-step guide on the process of that, since I have not found a good guide online. Or perhaps their is another solution that I have missed.

Thanks is advanced!

EDIT: Exact error referring to the file I added a line in.

>>> /etc/sudoers.d/config: syntax error near line 1 <<<
sudo: parse error in /etc/sudoers.d/config near line 1
sudo: no valid sudoers sources found, quitting
sudo: unable to initialize policy plugin
misas
  • 11
  • What is the error exactly? Why can't you boot a Live CD again? – mikewhatever May 02 '20 at 23:35
  • Because I need to manually mount any external drives, which only works using sudo. – misas May 02 '20 at 23:50
  • 1
    You don't need to "manually mount" anything to boot from a LiveCD/USB. The recovery mode will also have sudo broken. – mikewhatever May 02 '20 at 23:53
  • 1
    @mikewhatever is right. you could also use a live CD/USB like this and you'll be able to fix your system like recovery mode. – Raffa May 02 '20 at 23:58
  • Local users don't need sudo to turn the computer off or reboot. Only remote users running SSH usually need sudo for those steps. Also NOPASSWD doesn't mean that you don't need to still type in sudo. The only user that doesn't need to type in sudo is the root user. – Terrance May 03 '20 at 00:01
  • @mikewhatever Yes, you are right I forgot about that, it was very late sorry. Will give it a shot. – misas May 03 '20 at 10:31
  • @Terrance What I was trying to do is remove the need to type in the password after writing e.g 'sudo reboot'. – misas May 03 '20 at 10:32
  • It confused me when you stated "I was trying to make my computer turn off without needing sudo" – Terrance May 03 '20 at 14:44

1 Answers1

0

I fixed the issue. Thanks for all the help.

SOLUTION FOR ME:

  1. Go to sleep and wake up refreshed.

  2. Flash "Ubuntu Dekstop" onto a USB drive from you mothers PC without her permission (do at your own risk)

  3. Boot, and select "Try Ubuntu without installing".

  4. Find the directory (I went to 'Places' and selected my hard drive)

  5. Open the directory in the terminal.

  6. Remove the file causing the issue, i.e sudo rm config. (password was not necessary)

  7. Power off (when prompted to remove the USB, do it.)

  8. Power on and it was fixed for me (the file causing the problem is gone and sudo now works).

  9. Make sure you edit files with visudo in the future, to avoid syntax errors, or at least have a root account.

misas
  • 11