0

I've gotten myself into a bit of a unique situation. Somehow my main user got removed from the admin group and no longer has sudo privileges. However, sometime in the past I also set my grub_timeout to 0 and so I can't get to grub to boot in recovery mode and fix the group problem. What should I do? Is there some way to use a live CD to get a root prompt (somehow this doesn't sound too secure and so I don't think so).

Thanks

2 Answers 2

1

Hold down the left Shift key before your system boots to Ubuntu and it should bring you to the grub menu.

After you get to Recovery Mode with root access, you need to mount the drive in Read / Write to make any changes.

mount -o remount,rw /

then you can check was groups the user is part of:

groups username

then to add the user to group sudo

usermod -a -G sudo username

to add the user to the adm group

usermod -a -G adm username

Hope this helps.

3
  • Unfortunately the shift key trick doesn't work when grub_timeout is 0. Thanks, though!
    – dasizeman
    Jul 25, 2015 at 21:29
  • @sizeman I set mine to GRUB_TIMEOUT=0 to test it, and it worked. It is all about timing. But there are always alternatives to solve problems, and I am glad you were able to get yours fixed. =)
    – Terrance
    Jul 25, 2015 at 21:49
  • @sizeman One more thing I think I figured out. GRUB-TIMEOUT=0 I was able to work around. GRUB-TIMEOUT=0.0 disabled the shift key from working all together. Just thought I would pass that on.
    – Terrance
    Jul 26, 2015 at 2:09
0

If you cannot get Terrance's solution to work, you can use the live environment from a cd. You will want to mount your / (root) partition, chroot into it, and use the normal tools to fix your user account.

Detailed guide

Reminder

Never blindly run commands you find on the internet, especially not while you have root access. Some commands can cripple or even destroy your system. If you do not know what a command or its arguments do, look it up in the man pages first, and only run it once you understand what the command will do. If you do not know how to use the man pages, see http://linux.die.net/man/1/man or $ man man

Set up live environment

Boot into your live environment and open up a terminal (konsole, gnome-terminal, etc), and switch to the root user if you're not already.

Find your root partition in /dev. Running # lsblk may help you identify it, especially if you know its size. From here, I'll assume your root partition is on /dev/sda1.

Now mount your root partition with # mount /dev/sda1 /mnt. Technically, you don't have to mount it to /mnt, so if you prefer, mount it somewhere else that is empty. If you're not sure that you mounted the right device, do # ls /mnt. If it's the right device, you should see folders like home, etc, usr, var, etc.

If it's the wrong device, make sure you're not in /mnt, then run # umount /mnt.

Once you have your root partition mounted to /mnt, chroot into it with # chroot /mnt. You should now be working with your installed system.

Fix your user account

Assuming your admin group is called wheel, you can add yourself back to it with # usermod -aG wheel your-user-name-here. At this point, you may also want to double-check your sudo config, provided you know how to use visudo.

When you're done fixing up your system, run # exit to leave the chroot environment, and unmount the partition with # umount /mnt. You can now reboot back to your normal system, and check that your access has been restored.

2
  • Worked like a charm, just what I was looking for. Thanks!
    – dasizeman
    Jul 25, 2015 at 21:28
  • Glad to hear it, sizeman!
    – KDØBPV
    Jul 25, 2015 at 23:53

You must log in to answer this question.

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