Linux centos7 accidentally moved the system file passwd, resulting in unable to enter the system processing method

Unable to enter the system because the system file passwd was moved accidentally. Insert picture description here
After logging in to the system, execute mv /etc/passwd /root/start.tomct (move the system passwd file to the root root directory and rename it).
Insert picture description hereAt this time, the passwd file has been moved To other locations, this is that after we execute the restart command, we cannot enter the system here.
After reboot, it will be stuck on the startup page and
Insert picture description herepress Esc to view the details and find an error
Insert picture description here

Solution:
We physically restart the server, and enter the edit mode when booting
Insert picture description here

Move the cursor down to
Insert picture description here
find the position at the beginning of ro ​​in this line,
Insert picture description here
Insert picture description here
modify it to rw init=/sysroot/bin/sh
Insert picture description here
ctrl+x to execute, enter the single-user mode interface,
Insert picture description here
execute chroot /sysroot Insert picture description here
CD to root and see the password file just moved, At this time, we execute the mobile code to move the password file back to
mv /root/start.tomct /etc/passwd
or
cp /root/start.tomct /etc
mv start.tomct passwd After
Insert picture description here
Insert picture description here
modifying the password, create the file
touch /.autorelabel

After execution, physically restart the server and exit the single user mode.
After entering the system again, you can log in to the system with the original password
Insert picture description here

Guess you like

Origin blog.csdn.net/zz891422822/article/details/109269558