当你忘记了centos7的root管理员账号的登录密码了怎么解决呢?CentOS 7 root密码的重置方式和CentOS 6完全不一样,下面以进入单用户模式修改root密码为例。
1、重启开机按esc,在第一行按e,进行编辑
2、编辑修改两处:ro改为rw,在LANG=en_US.UFT-8后面添加init=/bin/sh
3、按Ctrl+X重启,并修改密码
4、由于selinux开启着的需要执行以下命令更新系统信息,否则重启之后密码未生效
本处关闭selinux
# vi /etc/sysconfig/selinux
5、重启系统
# exec /sbin/init
补充:下面看下重置CentOS 7.2 ROOT密码的方法
说明:本文档已在CentOS 7.2 内核版本 3.10.0 系统中测试成功;
1、在启动GRUB菜单中选择编辑选项,按键 “e” 进入编辑;

2、大约在第16行找到 “ro” 将 “ro” 修改为 ” rw init=/sysroot/bin/bash “;

3、同时按下 ” ctrl + x “,进入单用户模式;

4、用 “chroot /sysroot ” 命令进入系统;

5、 ” passwd root ” 重置root密码;

6、用 ” touch /.autorelabel ” 更新SELinux信息;

7、输入 ” exit “退出 chroot ;

8、用 ” reboot -f ” 重启你的系统;

9、登陆系统测试;

参考文档: https://www.unixmen.com/reset-root-password-centos-7/
总结
以上就是CentOS7.2 忘记root密码的简单处理方法,希望对大家有所帮助。
评论前必须登录!
注册