CentOS 7 / RHEL 7 : 重置root密码

星期四, 2015-11-26 | Author: Lee | linux | 4,829 views

以前装了centos7的虚拟机为了玩Docker,无奈忘记了当初设置的密码了,网上弄了一圈重置密码信息,记录下.
只知道按e可以进入单个用户模式,无奈centos7启动了grub2模式 要加对应的启动才行

1.第一步重启系统按 e进入编辑模式 GRUB 2

2.第二步 在 rhgb and quiet 的后面添加

init=/bin/sh
selinux=0

root-passwd-2
root-password-3

3.第三步 Remount / root partition , reset root password and autorelable
使用passwd root 修改密码

1
2
mount -o remount, rw /
passwd root

NICE 如图成功:
vbox-6
NOTE: In case system is not writable, the passwd tool fails with the following error:
Authentication token manipulation error

Now run the below given command for relabeling the SELINUX

如果前面设置了 selinux=0 这里就不会出现上面错误了
如果有错误继续执行:

1
touch /.autorelabel

下面重启服务即可

1
exec /sbin/init

OR

1
2
exec /sbin/init
exec /sbin/reboot

参考blog 英文版本写的很详细易懂: http://sharadchhetri.com/2014/10/11/centos-7-rhel-7-reset-recover-forgotten-root-password/

Tags: , ,

文章作者: Lee

本文地址: https://www.pomelolee.com/1518.html

除非注明,Pomelo Lee文章均为原创,转载请以链接形式标明本文地址

No comments yet.

Leave a comment

Search

文章分类

Links

Meta