{"id":6851,"date":"2017-01-09T14:50:46","date_gmt":"2017-01-09T06:50:46","guid":{"rendered":"https:\/\/webhostinggeeks.com\/howto\/?p=6851"},"modified":"2023-04-28T09:47:04","modified_gmt":"2023-04-28T09:47:04","slug":"reset-forgotten-root-password-on-linux","status":"publish","type":"post","link":"https:\/\/webhostinggeeks.com\/howto\/reset-forgotten-root-password-on-linux\/","title":{"rendered":"How to Reset Forgotten Root Password on Linux RHEL 7 \/ CentOS 7"},"content":{"rendered":"<p><img decoding=\"async\" class=\"alignnone wp-image-6857 img-fluid lazyload\" data-src=\"https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2017\/01\/How-to-Reset-Forgotten-Root-Password-on-Linux-RHEL-7-an-CentOS-7.jpg\" alt=\"Reset Forgotten Root Password\" width=\"800\" height=\"500\" data-srcset=\"https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2017\/01\/How-to-Reset-Forgotten-Root-Password-on-Linux-RHEL-7-an-CentOS-7.jpg 800w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2017\/01\/How-to-Reset-Forgotten-Root-Password-on-Linux-RHEL-7-an-CentOS-7-300x188.jpg 300w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2017\/01\/How-to-Reset-Forgotten-Root-Password-on-Linux-RHEL-7-an-CentOS-7-768x480.jpg 768w\" data-sizes=\"(max-width: 800px) 100vw, 800px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 800px; --smush-placeholder-aspect-ratio: 800\/500;\" \/><\/p>\n<p>This short howto will explain the steps to reset a lost root password or to reset a forgotten root password on Linux RHEL 7 or CentOS 7.<\/p>\n<p>Basically, we will add a &#8220;<strong>rd.break<\/strong>&#8221; to the end of the line with kernel parameters in Grub to stop the start-up process before the regular root filesystem is mounted, hence the necessity to chroot into sysroot.<!--more--><\/p>\n<p>This will allow you to break into your Linux system and reset the root password back to your own.<\/p>\n<p>Please note that in below steps, you will use &#8220;<strong>rd.break<\/strong>&#8221; instead of alternative method &#8220;<strong><a href=\"https:\/\/linoxide.com\/reset-forgotten-root-password-rhel-centos-7\/\" target=\"_blank\" rel=\"nofollow noopener\">init=\/bin\/sh<\/a><\/strong>&#8221; to recover your lost root password.<\/p>\n<h2>Steps to Reset Forgotten Root Password on Linux RHEL 7\/CentOS 7<\/h2>\n<p>1. Reboot your system and interrupt the countdown in the boot loader menu.<\/p>\n<p>In order to interrupt the countdown, you need to press any key when the boot loader menu appears.<\/p>\n<p>2. Edit the default boot loader entry to abort the boot process just after all file systems have been mounted, but before control is handed over to systemd, then boot.<\/p>\n<p>Use the cursor keys to highlight the default boot loader entry. On the GRUB 2 boot screen, press e to edit the current entry.<\/p>\n<p><img decoding=\"async\" class=\"alignnone wp-image-6852 ig-fluid lazyload\" data-src=\"https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2017\/01\/linux16-0.png\" alt=\"Reset Forgotten Root Password\" width=\"804\" height=\"508\" data-srcset=\"https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2017\/01\/linux16-0.png 804w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2017\/01\/linux16-0-300x190.png 300w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2017\/01\/linux16-0-768x485.png 768w\" data-sizes=\"(max-width: 804px) 100vw, 804px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 804px; --smush-placeholder-aspect-ratio: 804\/508;\" \/><\/p>\n<p>3. Using the cursor keys, navigate to the line that starts with <strong>linux16<\/strong> if you are using on x86-64 BIOS-based systems and navigate to the line that starts with Linux line on 64-Bit IBM Power Series.<\/p>\n<p>Press End to move the cursor to the end of the line.<\/p>\n<p><img decoding=\"async\" class=\"alignnone wp-image-6854 img-fluid lazyload\" data-src=\"https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2017\/01\/linux16-1.png\" alt=\"recover a lost Root Password\" width=\"724\" height=\"403\" data-srcset=\"https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2017\/01\/linux16-1.png 724w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2017\/01\/linux16-1-300x167.png 300w\" data-sizes=\"(max-width: 724px) 100vw, 724px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 724px; --smush-placeholder-aspect-ratio: 724\/403;\" \/><\/p>\n<p>4. Append &#8220;<strong>rd.break<\/strong>&#8221; or &#8220;<strong>rd.break enforcing=0<\/strong>&#8221; to the end of the line. Both gives the same result.<\/p>\n<pre># rd.break\r\n<\/pre>\n<p>or<\/p>\n<pre># rd.break enforcing=0\r\n<\/pre>\n<p>Use option &#8220;<strong>rd.break<\/strong>&#8221;<\/p>\n<p><img decoding=\"async\" class=\"alignnone wp-image-6855 img-fluid lazyload\" data-src=\"https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2017\/01\/linux16-2.png\" alt=\"recover Forgotten Root Password\" width=\"723\" height=\"406\" data-srcset=\"https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2017\/01\/linux16-2.png 723w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2017\/01\/linux16-2-300x168.png 300w\" data-sizes=\"(max-width: 723px) 100vw, 723px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 723px; --smush-placeholder-aspect-ratio: 723\/406;\" \/><\/p>\n<p>Use option &#8220;<strong>rd.break enforcing=0<\/strong>&#8221;<\/p>\n<p><img decoding=\"async\" class=\"alignnone wp-image-6853 size-full lazyload\" data-src=\"https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2017\/01\/linux16-3.png\" alt=\"Reset Forgotten Root Password\" width=\"726\" height=\"402\" data-srcset=\"https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2017\/01\/linux16-3.png 726w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2017\/01\/linux16-3-300x166.png 300w\" data-sizes=\"(max-width: 726px) 100vw, 726px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 726px; --smush-placeholder-aspect-ratio: 726\/402;\" \/><\/p>\n<p><strong>Note<\/strong>: Adding <strong>enforcing=0<\/strong> puts the system into SELinux Permissive mode. This option enables omitting the time-consuming SELinux relabeling process and allows you to complete the boot process despite having mislabeled files.<\/p>\n<p>5. Press <strong>Ctrl+x<\/strong> to boot using the modified config.<\/p>\n<p>6. The file system is mounted read-only on \/sysroot\/. You will not be allowed to change the password if the file system is not writable. Run the following command to remount the root filesystem in read-write mode:<\/p>\n<pre># mount -oremount,rw \/sysroot\r\n<\/pre>\n<p>7. Then use chroot to go into a chroot jail at <strong>\/<\/strong>sysroot. Change the file system&#8217;s root as follows:<\/p>\n<pre># chroot \/sysroot\r\n<\/pre>\n<p>8. Change the root password to your own password.<\/p>\n<pre># passwd root\r\n<\/pre>\n<p>9. Configure the system to automatically perform a full SELinux relabel after boot. This is necessary since the passwd tool re-created the \/etc\/shadow file without an SELinux context.<\/p>\n<pre># touch \/ .autorelabel\r\n<\/pre>\n<p>10. Type exit twice to continue booting your system as normal. The system will run an SELinux relabel, then reboot again by itself.<\/p>\n<p><img decoding=\"async\" class=\"alignnone wp-image-6856 \u0448\u044c\u043f-\u0430\u0434\u0433\u0448\u0432 lazyload\" data-src=\"https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2017\/01\/linux16-4.png\" alt=\"Reset Forgotten Root Password\" width=\"789\" height=\"490\" data-srcset=\"https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2017\/01\/linux16-4.png 789w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2017\/01\/linux16-4-300x186.png 300w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2017\/01\/linux16-4-768x477.png 768w\" data-sizes=\"(max-width: 789px) 100vw, 789px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 789px; --smush-placeholder-aspect-ratio: 789\/490;\" \/><\/p>\n<p>I hope this article gives you some ideas and essential guidance on how to reset forgotten root passwords on Linux RHEL 7 and CentOS 7.<\/p>\n<p><strong>Resources:<\/strong><\/p>\n<ul>\n<li><a href=\"https:\/\/access.redhat.com\/solutions\/1192\" target=\"_blank\" rel=\"nofollow noopener\">https:\/\/access.redhat.com\/solutions\/918283<\/a><\/li>\n<li><a href=\"https:\/\/www.certdepot.net\/rhel7-interrupt-boot-gain-access-system\/\" target=\"_blank\" rel=\"nofollow noopener\">https:\/\/www.certdepot.net\/rhel7-interrupt-boot-gain-access-system\/<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>This short howto will explain the steps to reset a lost root password or to reset a forgotten root password on Linux RHEL 7 or CentOS 7. Basically, we will&#8230;<\/p>\n","protected":false},"author":6,"featured_media":6857,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"wds_primary_category":0,"footnotes":""},"categories":[2055,2058],"tags":[1258,1717],"class_list":["post-6851","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-centos","category-rhel","tag-centos-7","tag-rhel-7"],"_links":{"self":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/6851","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/comments?post=6851"}],"version-history":[{"count":0,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/6851\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media\/6857"}],"wp:attachment":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media?parent=6851"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/categories?post=6851"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/tags?post=6851"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}