3

I have a xubuntu pc at work, so I wanted to remove all users and create just one sudoer user with the name of the new person using the pc, so that he would be able to install programs etc. without having to disclose my admin password.

The steps I made were:

  • Created a new user: Jonathan, as administrator
  • Deleted all desktop users and its files
  • Logon as Jonathan
  • Deleted the only sudoer user

Basically, my mistake was that I created an administrator user which is not a root user.

So now when I am going to install a program, xubuntu asks me for a root password, which of course I don't have, I believe that root user is a kind of root default user for Xubuntu.

So before I format the pc, I wondering if there is any other way to fix this?

One option could be to reboot the machine, then open the console as root from the recovery mode on GRUB, create a new user, etc.. This could be great but unfortunately the screen says out of range when I try to start recovery mode, and in order to change the resolution for that screen I need to modify a file that requires root permissions. So basically I am stuck on a endless-loop. I could use another monitor with higher resolution and that might allow me to boot as recovery mode.

So how would you fix this issue, without swapping monitor, and formatting the pc? Is there a default password for that Xubuntu Root user?

This is not duplicated, as I cannot log into recovery mode or GRUB because of the resolution.

  • 1
    no is not, please read the whole question. I can't follow those steps. – peterpeterson Apr 12 '15 at 21:34
  • 1
    You should update your question as it is tl;dr . All you really need to say is you deleted your user with admin access and can not boot to recovery mode. You will have to fix this with a live CD and chroot into your xubuntu. – Panther Apr 20 '15 at 20:00

2 Answers2

5

Using grub2's recovery mode root shell

  1. While booting, hold Shift to access grub2's menu
  2. Select Advanced options for Ubuntu and hit Enter

grub2-1

  1. Select your current kernel's recovery mode (e.g. Ubuntu xx.xx x.xx.xx-xx-generic (recovery mode)) and hit Enter

grub2-2

  1. Select root - Drop to root shell prompt and hit Enter

Recovery menu

  1. Run mount -o remount,rw / to remount the root partition as read-write
  2. Run nano /etc/group
  3. Look for the sudo entry and add "jonathan" right at the end
  4. Hit Ctrl+x, y and then Enter to save the changes
  5. Run exit
  6. Select resume - Resume normal boot

Using a Live DVD

  1. Boot from a Live DVD
  2. Open a terminal with Ctrl+Alt+t
  3. Run lsblk to see to which block device your root partition on the drive is mapped to
  4. Mount the root partition: sudo mount /dev/<partition_block_device> /mnt (where <partition_block_device> = root partition's block device)
  5. Run sudo gedit /mnt/etc/group
  6. Look for the sudo entry and add "jonathan" right at the end
  7. Save
  8. Quit
  9. Run exit
  10. Reboot
kos
  • 35,891
0

My answer to How do I reset a lost password (using recovery mode requires me to type the password)? also contains instructions for the related task of making a user an administrator by booting from a live CD and chrooting into your system. One benefit of chrooting is that you don't have to edit any configuration files manually, and thus are somewhat less likely to make mistakes that worsen the situation.

Even if the original administrator was removed on your system (rather than merely being made no longer an administrator), since you have a working user account who you wish to make an administrator, this technique should do what you need.

  1. If you don't already have one, burn an Ubuntu live CD/DVD (on Ubuntu, Windows, or Mac OS X) or write an Ubuntu live USB flash drive (on Ubuntu, Windows, or Mac OS X).

  2. If you know the device name of the partition that contains your Ubuntu system's root filesystem, feel free to skip to step 5.

  3. In your Ubuntu system (not the live CD/DVD/USB system), run this command in the Terminal:

    mount | grep ' on / '
    

    You should include the spaces before on and after /.

  4. That command produces something like /dev/sda1 on / type ext4 (rw,errors=remount-ro,commit=0) as the output. The text before on (not including the space) is the device name of the partition that contains your Ubuntu system's root filesystem. Remember it (or write it down).

  5. Boot the computer from the live CD/DVD/USB and select Try Ubuntu without installing (not Install Ubuntu).

  6. Open up a Terminal window (Ctrl+Alt+T).

  7. Run this command:

    sudo mount /dev/sda1 /mnt

    Replace /dev/sda1 with the device name of the partition containing your Ubuntu system's root filesystem, if different.

  8. Run this command:

    sudo chroot /mnt
    
  1. Now that you have chrooted into the installed system, you can modify its configuration in essentially the same way as you would if booted into it.

    Add the desired user to the sudo group to give them the ability to perform actions as root via sudo and polkit:

    usermod -a -G sudo username
  1. Run these three commands:

    exit
    sudo umount /mnt
    exit
    

    The last of those commands quits the Terminal window.

Then reboot back into your installed Ubuntu system. Your administrative powers should be restored.

Eliah Kagan
  • 117,780