Boot parameters

Gain access on lost password

Boot system to grub and edit your default boot entry.
Add the following:

init=/bin/bash

Now boot this entry.
You will get a system that has / mounted as RO filesystem so, remount it before doing anything.
After that, set a password.

bash# mount -o remount,rw /
bash#
bash# whoami
root
bash# passwd
New password:
Retype new password:
bash# 

If you have apparmor or SELinux running on that system, you need to understand that you mislabled the /etc/shadow file while running the passwd command end editing the shadow file.
So booting the system normally will result in failing logins, as SELinux (in my case) will prevent the usage of the mislabled shadow file.

Boot to grub and edit your default entry again.
This time add the following

enforcing=0

or to completely disable SELinux

selinux=0

For AppArmor add

apparmor=0

Boot modified entry and login.
Re-Lable at least the shadow file or better /etc

restorecon -Rv /etc

Reboot!

Leave a Reply