Location>code7788 >text

Linux system password forgotten

Popularity:922 ℃/2024-10-01 14:58:42

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

83b4718c7e96702d5e0528ac09f6336f

image-20240930210745366

image-20240930211340598

image-20240930211541795

image-20240930211739495

image-20240930211817975

image-20240930212314458

systems

Reboot Linux, press and hold the shift key during the reboot process and the following screen will appear

image-20240930213900344

image-20240930214106384

image-20240930214314499

203beae9b4411fbb0fd9ccf76d26fbe2