Linux 系统重置 root 密码

前言

该方法适用于 RHEL 7/8,CentOS 7/8

开机后,在内核引导页面,敲击键盘上的【e】;

1571149871273510

在linux16参数的这行后面追加"rd.break"参数,按下【Ctrl+X】运行修改后的内核;

1571149992615165

进入到系统的紧急救援模式后依此输入以下命令:

1571150426129471

命令附下:

switch_root:/# mount -o remount,rw /sysroot 
switch_root:/# chroot /sysroot 
sh-4.2:/# echo "redhat" | passwd --stdin root   //redhat 为重置后的密码 
sh-4.2:/# touch /.autorelabel 
sh-4.2:/# exit 
switch_root:/# reboot

 


THE END