I received the dreaded <username> is not in the sudoers file. This incident will be reported
error. Somehow my user was removed from /etc/sudoers
.
This is how I fixed it.
- Reboot your computer and when you see the prompt to hit
<esc>
for the boot menu do it. - Press the number which represents your boot drive (usually 1)
- You will be taken to a Grub menu, highlight the entry for PureOS and press
e
to edit. - Find the line that starts with
linux
and somewhere where it saysro quiet
, addsingle
in there so that it looks likero single quiet
and at the end of that line addinit=/bin/bash
(these changes will not persist) - Press
Ctrl-X
to boot into single user mode. - You will be at a bash prompt but the filesystem is read only so remount it read-write with:
mount -o remount,rw /
- Type
visudo
to edit /etc/sudoers and add this entry:<username> ALL=(ALL:ALL) ALL
- Reboot your computer and sudo will have been restored.