Locked out of machine - please help

Pop Horea-Vasile pop.horea at lnxopensource.com
Thu Sep 29 18:04:39 UTC 2011


On 09/29/2011 07:21 PM, richardkimber at btinternet.com wrote:


    Resetting the root password when all privileged access is lost

Created at:
    Wed 12 Aug 2009, 16:36
Last updated at:
    Tue 5 Jul, 21:27

Categories:

        * 10.04 LTS (Lucid Lynx)
          <https://landscape.canonical.com/account/pophorea/kb/category/53>
        * 10.10 (Maverick Meerkat)
          <https://landscape.canonical.com/account/pophorea/kb/category/54>
        * 11.04 (Natty Narwhal)
          <https://landscape.canonical.com/account/pophorea/kb/category/63>
        * 6.06 LTS (Dapper Drake)
          <https://landscape.canonical.com/account/pophorea/kb/category/6>
        * 8.04 LTS (Hardy Heron)
          <https://landscape.canonical.com/account/pophorea/kb/category/14>
        * CLI
          <https://landscape.canonical.com/account/pophorea/kb/category/40>
        * Security
          <https://landscape.canonical.com/account/pophorea/kb/category/47>

Was this article helpful to you?

Imagine the following scenario:

a) A colleague has set a password for the root user
b) This colleague was the sole member of the admin group
c) This colleague has left the company

How do you regain administrator privileges? You do not have direct 
access to the root user because a password has been set. You also do not 
have indirect access (via sudo) because you are not a member of the 
admin group.

This article will present two ways to rectify these two issues.

*Solution #1*

1. Boot up with a Ubuntu live CD (normal Desktop install CD) and enter a 
live graphical session.
2. Mount the partitions containing both the / and /usr directories of 
your Ubuntu installation. 99.99% of the time they are on the same 
partition (say it's /dev/sda1 in this example):

$ sudo mount /dev/sda1 /mnt

The above can also be accomplished in GNOME by clicking on the partition 
(drive icon) under Places in the top menu (Panel).

3. Change the root password:

$ sudo chroot /mnt passwd root

Alternatively you can restore the Ubuntu default of not giving root a 
password at all:

$ sudo chroot /mnt usermod -p '!' root

And now put a user (peter in this example) in the admin group:

$ sudo chroot /mnt adduser peter admin

4. Boot normally (from the hard disk) and ensure that the user peter can 
gain root privileges via the sudo command.

As user peter:

$ sudo ls

And that your root password has been properly set:

$ su - root
# exit

*Solution #2*

Instead of booting with external media you can try booting into recovery 
mode with the following kernel boot option:

*init=/bin/bash*

This should give you a root shell. You would then continue with the 
commands:

# mount -o remount,rw /
# passwd root (or usermod -p '!' root)
# adduser peter admin


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20110929/8a0f8a9c/attachment.html>


More information about the ubuntu-users mailing list