{"id":440,"date":"2018-03-09T09:58:53","date_gmt":"2018-03-09T09:58:53","guid":{"rendered":"http:\/\/shijuvarghese.com\/?p=440"},"modified":"2018-03-09T10:00:56","modified_gmt":"2018-03-09T10:00:56","slug":"recover-a-redhat-7-centos-7-root-password","status":"publish","type":"post","link":"http:\/\/shijuvarghese.com\/?p=440","title":{"rendered":"Recover a Redhat 7 or CentOS 7 root password"},"content":{"rendered":"<p>There can be instances where you would had lost your root user&#8217;s passwords and thus cannot perform certain activities allowed only to the root user. The process of recovering the root password in Redhat\/CentOS 7 is different than the previous versions of the OS.<\/p>\n<p>The procedure to recover the Linux root user password in a Redhat 7 or CentOS 7 system is as follows:<\/p>\n<ul>\n<li>Boot the system and once the Grub screen appears, press any key so that the system halts to receive further commands, instead of continuing to boot.<\/li>\n<li>In a CentOS system, the screen should appears with lines, including one that starts with &#8220;<strong>CentOS Linux, with Linux &lt;version&gt;&#8230;<\/strong>&#8220;<\/li>\n<li>Select the above line, and press &#8220;<strong>e<\/strong>&#8221; to edit the configuration.<\/li>\n<li>Find the line that looks like &#8220;<strong>linux16 \/vmlinuz-&lt;version&gt; root=UUID&#8230;<\/strong>&#8220;<\/li>\n<li>Delete the words &#8220;<strong>rhgb<\/strong>&#8221; and &#8220;<strong>quiet<\/strong>&#8221; from the above mentioned line.<\/li>\n<li>In the same line, append the following statement &#8220;<strong>init=\/bin\/sh<\/strong>&#8221; at the end of the line.<\/li>\n<li>Press <strong>CTRL+X<\/strong> to save and reboot the host<\/li>\n<li>You will get to the shell prompt, bypassing the login screen<\/li>\n<li>Enter the following set of commands:<\/li>\n<li>Enter &#8220;<strong>\/usr\/sbin\/load_policy -i<\/strong>&#8221; to load the installed SELinux policy<\/li>\n<li>Type &#8220;<strong>mount -o remount,rw \/<\/strong>&#8221; to remount root file system in read\/write mode<\/li>\n<li>Issue the command &#8220;<strong>passwd<\/strong>&#8221; to set a password for the present user.<\/li>\n<li>Type &#8220;<strong>mount -o remount,ro \/<\/strong>&#8221; to remount the root filesystem in Read Only mode.<\/li>\n<li>Enter the command &#8220;<strong>exec \/sbin\/init 6<\/strong>&#8221; to reboot the host<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<div class=\"mh-excerpt\"><p>There can be instances where you would had lost your root user&#8217;s passwords and thus cannot perform certain activities allowed only to the root user. <a class=\"mh-excerpt-more\" href=\"http:\/\/shijuvarghese.com\/?p=440\" title=\"Recover a Redhat 7 or CentOS 7 root password\">[&#8230;]<\/a><\/p>\n<\/div>","protected":false},"author":1,"featured_media":260,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,14],"tags":[],"class_list":["post-440","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","category-security"],"_links":{"self":[{"href":"http:\/\/shijuvarghese.com\/index.php?rest_route=\/wp\/v2\/posts\/440","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/shijuvarghese.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/shijuvarghese.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/shijuvarghese.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/shijuvarghese.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=440"}],"version-history":[{"count":4,"href":"http:\/\/shijuvarghese.com\/index.php?rest_route=\/wp\/v2\/posts\/440\/revisions"}],"predecessor-version":[{"id":444,"href":"http:\/\/shijuvarghese.com\/index.php?rest_route=\/wp\/v2\/posts\/440\/revisions\/444"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/shijuvarghese.com\/index.php?rest_route=\/wp\/v2\/media\/260"}],"wp:attachment":[{"href":"http:\/\/shijuvarghese.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=440"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/shijuvarghese.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=440"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/shijuvarghese.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=440"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}