0

I naively ran a few commands with sudo while trying to get docker working on my machine. Now upon trying sudo, I get this error:

dorsatum is not in the sudoers file. This incident will be reported.

Output of id is : gid=1000(dorsatum) groups=1000(dorsatum),999(docker)

Output of groups is : dorsatum docker

I've tried editing it via grub, it did not work. A number of questions were solved by dropping to the root shell in the recovery mode shell. I'm asked for the maintainance password, which does not accept my regular password, leaving ctrl+d to be the only viable option.

Projjol
  • 1,120

2 Answers2

1

This is a little nasty but it's worked for me in the past and has the added advantage of re-setting your root password. It wasn't an Ubuntu system I did this with but the principle remains the same.

Boot off of a live CD, I assume this will mount your existing linux partitions. If not you'll need to mount them manually.

From the shell

$ cp /PathToRootOfMountedDrive/etc/shadow /PathToRootOfMountedDrive/etc/shadow.bak

$ nano /PathToRootOfMountedDrive/etc/shadow

There will be a line like this:

root:The Hashed Root Password:15841:0:99999:7:::

The bit we are concerned with is the hashed root password. If you replace this with an asterisk (*) and save, you should be able to re-boot off of your install and log in as root without a password. Your amended line should look something like this:

root:*:15841:0:99999:7:::

You can then add yourself back to the sudoers file with $ useradd dorsatum sudo It goes without saying that you should set a root password once you are done!

There is a nice explanation of /etc/shadow here

tth
  • 21
  • 3
1

You will need to boot off your installation media again to fix this problem. You need to gain root write access to the partition containing your Ubuntu install, so boot off the installation media (CD or USB) and mount your ubuntu partition temporarily.

$ sudo bash
# mkdir /mnt/ubuntu-main
# mount /dev/sda1 /mnt/ubuntu-main

Of course, replace /dev/sda1 with your Ubuntu install's root partition.

# nano /mnt/ubuntu-main/etc/group

Find the line containing the group sudo (on my system it says sudo:x:27:<username>) and make sure your username dorsatum is listed next to it.

Finally, unmount your drive and reboot into Ubuntu. Your user should now be a part of the sudo group again.

Aaron D
  • 639