centos7 忘记root密码解决方法

centos7相比centos6对于root密码重置的方案略有不同。

1:开机ESC后按e键进入编辑模式

2:将linux16这一行的ro改为rw,在这一行末尾 "LANG=zh_CN.UTF-8" 后面加空格 init=/bin/sh

     如果不修改ro,进入系统后需要执行 " mount -o remount.rw  /  "

  修改后 ctrl+x 启动系统

3:paawd root 修改密码。如果系统开启了selinux,需要执行 touch  /.autorelabel

4:exec /sbin/init 正常启动,或者exec /sbin/reboot重启系统。

原文地址:https://www.cnblogs.com/sunny18/p/8539280.html