0

After I open a terminal, I run sudo su. But it then gives me

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

I tried running su and then input the password but the terminal closes after a few seconds. What command do I use to become root? Also, I'm on Ubuntu 18.

4
  • Which Ubuntu are you using?
    – user68186
    Jan 3, 2021 at 23:24
  • I'm using Ubuntu 18.
    – GodUsopp
    Jan 3, 2021 at 23:26
  • 18.04 or 18.10?
    – user68186
    Jan 3, 2021 at 23:27
  • 1
    Also please explain what you did. Using visudo to edit sudoers has a check for invalid edits to prevent this from happening.
    – Rinzwind
    Jan 3, 2021 at 23:35

1 Answer 1

2

Boot from a live session, edit /etc/sudoers and fix the mistake.

An example on how to do that from a live session (change sda1 to what you need it to be and if you use another mount point also change below to what you used):

sudo mount -o rw,remount /dev/sda1 /mnt
sudo visudo -f /mnt/etc/sudoers

and then fix line 27.

2
  • Honest question: would a recovery mode root shell suffice for this?
    – Levente
    Jan 4, 2021 at 3:45
  • Yes but I consider that more difficult so opted for this method. I also assume we all always have a live session at hand ;-)
    – Rinzwind
    Jan 4, 2021 at 8:34

Not the answer you're looking for? Browse other questions tagged .