3

I think I made a big mistake.
I did usermod -aG docker $USER to run docker without sudo.
After run above command, my account status like below

joont@joont-ununtu:~$ id
uid=1000(joont) gid=1000(joont) groups=1000(joont),999(docker)

Now I can't use sudo command through this user....
I didn't set root password after installing ubuntu.
So I don't know my root password now.
How can I recover it..?

JoonT
  • 153

1 Answers1

3

To add your username back to the sudo group, please follow the steps below:

  1. Reboot your machine and hold the Shift key as soon as you pass the BIOS logo to access the GRUB boot menu. You might need to repeat this a few times until you succeed and see the boot menu.

  2. Select advanced options and hit Enter.

  3. Select the second option with (recovery mode) in front of it and hit Enter.

  4. Wait until the machine boots and another menu appears. Choose the option with drop to root shell prompt in it and hit Enter.

  5. Press Enter when it says press Enter for maintenance.

  6. Once you are presented with a command prompt, write the following command and hit Enter (this will give you read and write access to your system):

    mount -o rw,remount /

  7. Write the following command ( where joont is your username ) and hit Enter:

    sudo usermod -a -G sudo joont

    or

    sudo adduser joont sudo

  8. Reboot your system.

Raffa
  • 32,237