How To: Recover the Linux root password

SuSE Operating System
User avatar
daniel
Site Admin
Posts: 238
Joined: Tue Jan 09, 2007 9:54 pm
Contact:

How To: Recover the Linux root password

Postby daniel » Thu Apr 22, 2021 9:23 pm

Orginal Link https://www.suse.com/support/kb/doc/?id=000015925 but still valid for latest versions :D

Situation
Lost or forgot the root password on Linux server

Resolution

Boot server from the installation CD.
Then select any installation method or Rescue System.
At the first installation screen when selecting language, press ctrl-alt-f2 to open a virtual console.
Note: If you selected Rescue System, select your keyboard language and then a Rescue Login prompt should appear. Login as root.
Type

Code: Select all

fdisk -l

to list the partitions. Locate the Linux root partition.
Type

Code: Select all

mount /dev/sda4 /mnt

(replace sda4 with the device name for the Linux root partition identified in the previous step).
Run

Code: Select all

mount -o bind /dev /mnt/dev

to make the device files available (this is needed for access to the urandom device which may be used by the passwd command below).
Enter

Code: Select all

chroot /mnt

Now enter

Code: Select all

passwd root

and reset the root password.
Type

Code: Select all

exit

to leave the chroot environment.
Reboot the system.

Return to “SuSE”

Who is online

Users browsing this forum: No registered users and 1 guest