Linux system password forgotten
1. Failure background
Deleting or modifying /etc/passwd by mistake prevents remote login.
Disable root remote login, no normal user added, can't login remotely.
Forgot root password, can't log in remotely.
linux won't start.
2. Solutions
Root passwords, restoring system files with backups, all require a system reboot to enter rescue mode.
prescription | application scenario |
---|---|
The system comes with a rescue mode. | The system is working fine, the damage is not too bad. The system is not booting. |
The system on the USB flash drive (CD-ROM) enters the USB flash drive rescue mode. | The system is unavailable and will not boot properly. |
snapshotting | Virtual Machines (Virtualization, Hyperconverged), Cloud Servers |
3. Enter the rescue mode that comes with the system ⭐⭐⭐⭐⭐
selinux shutdown.
sudo setenforce 0 # Temporarily disable selinux.
Reboot Linux
In the GRUB menu, select #1 and press e to edit. root username,Kylin123123
Find the line in Linux where you changed ro to rw and add init=/bin/bash at the end of the line.
When you are done, press ctrl+x to enter rescue mode (fewer commands).
To do this, modify /etc/passwd to remove the x from root, and reboot.
Enter the system as root and set a new password for root with the passwd command.
4. Kylin system
systems
Reboot Linux, press and hold the shift key during the reboot process and the following screen will appear