CentOS7忘记root用户密码破解

CentOS7忘记root用户密码破解

Scroll Down

1、方法一

具体步骤:(注意输入命令时的空格,上传之后就不明显了)

1) 启动时任意键暂停启动

2) 按 e 键进入编辑模式

image.png

3) 将光标移动到 linux16 开始的行,添加内核参数 rd.break

image.png

4) 按 Ctrl-x 启动进入系统的紧急救援模式

5) 依次输入以下命令

# mount -o remount,rw /sysroot
# chroot /sysroot
# passwd root
# touch /.autorelabel
# exit
# reboot

image.png

以下相差不多,就不在贴图了

2. 方法二

具体步骤:(注意输入命令时的空格,上传之后就不明显了)

1) 启动时按任意键暂停启动

2) 按 e 键进入编辑模式

3) 将光标移动到 linux16 开始的行,改为 rw init=/sysroot/bin/sh

4) 按 Ctrl-x 启动,进入系统的紧急救援模式

5) 依次输入以下命令

# chroot /sysroot
# passwd root
# touch /.autorelabel 
# exit
# reboot

3. 方法三

具体步骤:

1) 启动时按 e 键进入编辑模式

2) 在 linux16 这行的后面输入'init=/bin/sh'

3) 按 ctrl+x 进入系统的紧急求援模式

4) 依次输入以下命令:

# mount -o remount,rw /
# passwd (修改 root 密码)
# touch /.autorelabel
# exec /sbin/init