Skip to main content

Reset root password for Ubuntu - recovery mode asks for root password

To reset password for ubuntu server or desktop where recovery mode is asks for password you need to have a physical access to the machine.

Prepare ubuntu live cd

Get live cd with version same on the machine. Run from live cd and wait until live cd fully loaded. Choose 'Try Ubuntu' and wait until desktop ubuntu loaded.

Open Terminal

And then open new terminal with command ctrl + alt + t. and check with command lsblk.
$ lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 119,2G  0 disk 
├─sda1   8:2    0    16G  0 part [SWAP]
└─sda2   8:3    0 103,2G  0 part /
sr0     11:0    1  1024M  0 rom  /cdrom
in this case, we know that our macine is in /dev/sda2. if there is volume group whre machine installed, it will show also.

Mount the partision and chroot into it

We already know the partition where ubuntu installed, we mount it with command.
sudo mount /dev/sda2 /mnt
next we chroot to that mounted pastition with command.
sudo chroot /mnt
if nothing wrong we will see now the prompt on terminal like root@ubuntu:/#. We already in root mode in our forget password machine.

Change the Password

We can change the password then with command.
passwd root
set your new password for user root.

Exit chroot and Reboot

Exit from chroot with ctrl + d or you can type exit.
Unmount the machine with sudo umount /mnt and then reboot by sudo reboot

You want to take the cd out and make sure you're actually run from the machine not from live cd again.

Hope this help somebody, as helped me.

Source : Ask Ubuntu.


Comments

Popular posts from this blog

Server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none

I have got this error while try to clone repository from github through jenkins. jenkins cannot get the repo and got message in log. stderr: fatal: unable to access 'https://github.com/username/repo.git/': server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none How to resolve this error :  1. Get sslServer from github :  sudo keytool -printcert -rfc -sslServer github.com copy thus certificates shows. 2. add key shows to the ca-certificates.crt :  sudo vim /etc/ssl/certs/ca-certificates.crt add those key to the ca-certificates.crt. Don't remove it's content, just add new line.