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,100
  • 1
    "ran a few commands", what commands? Problably you've replaced your group membership list with only "docker". – Eric Carvalho Jan 06 '15 at 19:57
  • @EricCarvalho, the question you've linked involves dropping into the root shell, I can't do that, it does not accept my password. And I'm sorry but I wish I knew the commands, I had tried a number of commands, and then because my RAM keeled over upon reboot this issue is there. – Projjol Jan 06 '15 at 20:08
  • The maintenance password is the root account's password, not your password. Did you, at any time, run sudo passwd? – muru Jan 06 '15 at 20:22
  • I was about to ask the same thing. Your "regular password" is the password for user dorsatum. Don't you remember setting a password for user root? – Eric Carvalho Jan 06 '15 at 20:25
  • @muru,@EricCarvalho, haven't set a root password. I have a liveusb, running visudo from it and adding my account, would that be a viable option? I.e. is this possible? – Projjol Jan 06 '15 at 20:37
  • 1
    @Projjol Certainly. You could also edit /etc/group and add yourself back to the sudo group. – muru Jan 06 '15 at 20:44

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
  • Setting a root password is unnecessary and could be a security risk. If you are going to reboot using the recovery cd, you might as well just edit the group file and add yourself there, as per my answer. – Aaron D Jan 07 '15 at 01:05
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