We've lost the root password from our file server from supermicro server.
I tried to follow the common instructions to reboot with left shift and drop to root shell as it is described in this answer.
When I choose root in this menu:
Ubuntu still asks for root password or propose to press Ctrl+D to return to Recovery menu.
Are there any other ways to reset root password?
Best Answer
Since you have physical access to the machine you can do this via an Live USB/CD.
Boot from your USB and chose 'Try Ubuntu' instead of 'Install Ubuntu'.
Open a terminal (Ctrl+Alt+T) and first look what device handle your machine disk has. You can do that with
lsblk
which should yield an output like this (I used a live CD for this since I am reproducing the steps in a VM):So in this case it would be
/dev/sda2
but this could differ for your installation.Now mount the partition in question with:
Now coming to the part where you can finally1
chroot
into it.You will see that your prompt has changed to something like
root@ubuntu:/#
and now the next steps are pretty straightforward.Change the password for your users with
passwd
:This should have done it already, but if that for whatever case setting passwords with the
passwd
command fails, you can go deep down the rabbit hole and change the/etc/shadow
file, but Beware: this is quite dangerous and you do this at your own risk.Exit the
chroot
by pressing Ctrl+D or type exit. Unmount the machine withsudo umount /mnt
and then reboot bysudo reboot
. You want to take the USB/CD out and make sure you're actually booting the machine in question.1 That
chroot
ing method is sufficient to reset passwords, or even to add and remove users from groups, but it does not allow you to fully use the installed system through the chroot. Many other commands, such asapt
, would fail if you ran them in a chroot set up that way.If you ever need to perform more extensive repairs on an installed system that you are accessing from a live CD/DVD/USB--for example by installing, removing, or updating software--then you would want to set up some additional mounts before
chroot
ing. You would do that by running these commands after runningsudo mount /dev/sda2 /mnt
but before runningsudo chroot /mnt
:If you have multiple partitions for the different parts of the OS, like for example a separate
/boot
partition, then you would want to mount them to the right positions. For example, wheresdX
is the device name for that particular drive andn
is the partition number:It is fine if you run those commands before
chroot
ing in to reset passwords with thepasswd
command. It is not necessary, though.