码迷,mamicode.com
首页 > 其他好文 > 详细

CentOS 7 / RHEL 7 : Reset / Recover forgotten root password

时间:2015-08-02 23:40:24      阅读:628      评论:0      收藏:0      [点我收藏+]

标签:difference   password   latest   method   linux   

CentOS 7 / RHEL 7 : Reset / Recover forgotten root password

In this post we will learn, how to reset / recover forgotten root password on CentOS 7 / RHEL 7 (Red Hat Enterprise Linux 7). On RHEL 5/6 or CentOS 5/6 series , the method of resetting forgotten root password was same. In latest RHEL 7 / CentOS 7 this time we have found some difference in steps to reset the forgotten root password.

技术分享技术分享

Earlier, root password were used to recover from runlevel in case the boot loader password is not set.

Reset / Recover forgotten root password on CentOS 7 / RHEL 7

Follow the given below procedure to reset forgotten root password.

Step 1: Reboot or start the system, edit grub2

Restart/start the system and on getting GRUB 2 boot screen, first press ESC key so that screen get stopped. Then press e key for editing.

技术分享

Step 2: Initialize the /bin/sh

Now in next screen, scroll down with the help of arrow key and search for any of these two keyword linux16 or linuxefi on UEFI systems.In our case, we have linux16.

Disable rhgb and quiet parameters in order to enable system messages.

In first screenshot you can see, we first scrolldown to line starting with keyword calledlinux16 . Now remove the parameter rhgb and quiet .

技术分享

In second screenshot you can see, we have removed the rhgb and quiet parameter
Add the below given parameter at the end of line, to initialize the sh shell.

init=/bin/sh

Now press CTRL with x keyword to boot the system.

技术分享

Step 3: Remount / root partition , reset root password and autorelable

The filesystem will be in read only mode, hence run the below given command so that you can write on filesystem

mount -o remount, rw /

Now reset root password with given below command

passwd root

Reconfirm the root password.

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

touch /.autorelabel

Now restart the system. You can use any one of the command.

exec /sbin/init

OR

exec /sbin/reboot

技术分享

You will see the system is going to reboot and stuck for a short time. Just wait for a few seconds or minute. Keep pay attention that the screen is stopped when SELIUX relabeling info message appeared on screen.
After a few moment, you will see at the bottom of screen some numerical percentage is running. It states about the completion of selinux relabeling in percentage. After completing 100% , the system will be rebooted.

技术分享

After successful booting, you can use your new root password for login into system.

技术分享


本文出自 “vincent” 博客,谢绝转载!

CentOS 7 / RHEL 7 : Reset / Recover forgotten root password

标签:difference   password   latest   method   linux   

原文地址:http://qiu521119.blog.51cto.com/1575387/1681001

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!