Rocky Linux重置root密码

1. 重启系统,在GRUB引导界面,选择Rocky Linux启动项

2. 按E键编辑启动参数,找到以linux开头的行,在行尾追加 rd.break(或init=/bin/bash)

3. 按 Ctrl+X 启动系统

# 重新挂载根分区为可写
mount -o remount,rw /sysroot
chroot /sysroot

# 修改root密码
passwd root
New password: [输入新密码]
Retype new password: [确认新密码]

# 更新 SELinux 上下文(非必要)
touch /.autorelabel

# 退出并重启
exit
reboot