1

i am very user of ubuntu, i have forgot my user & root's passwords now i am not able to login in my machine. I can login via guest user. please help me to reset password.

I tried to reset the password by recovery but after 3 steps. it starts asking me for "give root password for maintenance or press control-D".

I tried with another method by pressing "e" instead of "enter" by selecting ubuntu, with linux 4.4.0-140-generic (recovery mode). But the next window something very much different.

please help !

2 Answers2

1

1. Start your machine in recovery mode -> resume normal boot. You should get a prompt with root. You need follow this steps:

root@demo:~$ mount -o remount,rw /

root@demo:~$ passwd yourusername
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

root@demo:~$ reboot

2. You can use chroot. Start your machine with Live CD/DVD/USB

Start a terminal and mount your root disk like following steps

# check what is your disk 
ubuntu@demo:~$ sudo fdisk -l

Disk /dev/sda: 111,8 GiB, 120034123776 bytes, 234441648 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 083E1E28-FEE5-4BF0-B7CE-84520FB93B9D

Disposit.     Start     Final  Sectores  Size Tipo
/dev/sda1      2048    391167    389120  190M EFI System
/dev/sda2    391168  58660699  58269532 27,8G Linux filesystem
/dev/sda3  58660864 234440703 175779840 83,8G Linux filesystem

# in this case my root disk is /dev/sda2 
ubuntu@demo:~$ mkdir disk
ubuntu@demo:~$ sudo mount /dev/sda2 disk

# you can check the files for ensure is root partition
ubuntu@demo:~$ sudo ls disk 
bin    dev    home        lib     media  proc  sbin  sys  var
boot   initrd.img      lib64      mnt    root  snap  tmp  vmlinuz
cdrom  etc    initrd.img.old  lost+found  opt    run   srv   usr  vmlinuz.old

ubuntu@demo:~$ sudo chroot disk 


# passwd for your username
root@demo_chroot:~$ passwd yourusername
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully


#exit from chroot
root@demo_chroot:~$ exit

# finish umounting and reboot
ubuntu@demo:~$ sudo umount disk 
James S
  • 81
0

Boot from a USB (or CD/DVD if you have a system that old).

You can then mount the partition with /etc/shadow and put a new password hash in. The easiest way to do that is copy from an existing shadow file for the user (root in this case).

Ed King
  • 335