{"id":14449,"date":"2023-01-04T11:36:16","date_gmt":"2023-01-04T11:36:16","guid":{"rendered":"https:\/\/www.shineservers.com\/?p=14197"},"modified":"2023-01-04T11:36:16","modified_gmt":"2023-01-04T11:36:16","slug":"root-password-recovery-for-rhel-centos-7-linux","status":"publish","type":"post","link":"https:\/\/www.shineservers.com\/2023\/01\/04\/root-password-recovery-for-rhel-centos-7-linux\/","title":{"rendered":"Root Password Recovery for RHEL, CentOS 7 Linux"},"content":{"rendered":"\n<p class=\"has-black-color has-light-green-cyan-background-color has-text-color has-background has-medium-font-size\">One of our client recently stumbled upon with a query that he forgot the root password and can&#8217;t loose any data even if he reinstall OS to gain access again. Our team however suggested a password reset for this Centos 7 system. Here&#8217;s all the steps we followed him to gain back access to his machine. <br><br><strong>OS: Centos 7 (Core 7), RHEL7<\/strong><br><\/p>\n\n\n\n<p class=\"has-medium-font-size\">We already have IPMI Access, so we accessed the server using KVM. <\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>The first step is to reboot the system and edit the grub2 boot parameters. Once you see the menu you can press arrow keys to hold the screen. Then you must press \u2018e\u2019.<br><img decoding=\"async\" class=\"wp-image-14198\" style=\"width: 500px;\" src=\"https:\/\/www.shineservers.com\/wp-content\/uploads\/2023\/01\/passwordstep1-500x425-1.png\" alt=\"\"><\/li>\n\n\n\n<li>Look for a line that mentions\u00a0<strong>linux16<\/strong>\u00a0(or\u00a0<strong>linuxefi<\/strong>\u00a0if you are using UEFI bios). You may need to use the arrow keys to scroll down.\u00a0 At the end of the linux16 or linuxefi line, find and replace the\u00a0<strong>rhgb<\/strong>\u00a0<strong>quiet<\/strong>\u00a0parameters with\u00a0<strong>rd.break<\/strong>\u00a0<strong>enforcing=0<\/strong><br><img decoding=\"async\" class=\"wp-image-14199\" style=\"width: 500px;\" src=\"https:\/\/www.shineservers.com\/wp-content\/uploads\/2023\/01\/Picture2-500x425-1.png\" alt=\"\"><\/li>\n\n\n\n<li>Once you have edited the parameters accordingly, hit CTRL-X to start the boot process with the new parameters. The system should boot into the root system.<br><img decoding=\"async\" class=\"wp-image-14200\" style=\"width: 500px;\" src=\"https:\/\/www.shineservers.com\/wp-content\/uploads\/2023\/01\/Picture5.png\" alt=\"\"><\/li>\n\n\n\n<li>Enter the following command to remount the sysroot filesystem as read\/write:\u00a0<br><strong>mount -o remount,rw \/sysroot<\/strong><br><img decoding=\"async\" class=\"wp-image-14201\" style=\"width: 500px;\" src=\"https:\/\/www.shineservers.com\/wp-content\/uploads\/2023\/01\/Picture6.png\" alt=\"\"><\/li>\n\n\n\n<li>Now we chroot into the sysroot, using the following command:\u00a0<strong>chroot \/sysroot<\/strong><br><img decoding=\"async\" class=\"wp-image-14202\" style=\"width: 500px;\" src=\"https:\/\/www.shineservers.com\/wp-content\/uploads\/2023\/01\/Picture7.png\" alt=\"\"><\/li>\n\n\n\n<li>We can use the\u00a0<strong>passwd<\/strong>\u00a0command to change the root password.<br><img decoding=\"async\" class=\"wp-image-14203\" style=\"width: 500px;\" src=\"https:\/\/www.shineservers.com\/wp-content\/uploads\/2023\/01\/Picture8.png\" alt=\"\"><\/li>\n\n\n\n<li>Issue the following command to bring us back to the switch_root:\/# prompt:\u00a0<strong>exit<\/strong><br><img decoding=\"async\" class=\"wp-image-14204\" style=\"width: 500px;\" src=\"https:\/\/www.shineservers.com\/wp-content\/uploads\/2023\/01\/Picture9.png\" alt=\"\"><\/li>\n\n\n\n<li>Enter the following command to remount the sysroot filesystem as read-only once again:\u00a0<br><strong>mount -o remount,ro \/sysroot<\/strong><br><img decoding=\"async\" class=\"wp-image-14205\" style=\"width: 500px;\" src=\"https:\/\/www.shineservers.com\/wp-content\/uploads\/2023\/01\/Picture10.png\" alt=\"\"><\/li>\n\n\n\n<li>Now we can exit the session and allow the system to reboot using the following command:\u00a0<strong>exit<\/strong><br><img decoding=\"async\" class=\"wp-image-14206\" style=\"width: 500px;\" src=\"https:\/\/www.shineservers.com\/wp-content\/uploads\/2023\/01\/Picture12.png\" alt=\"\"><\/li>\n\n\n\n<li>Allow the system to boot normally and login as root using the new password that you set in step 6.<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>One of our client recently stumbled upon with a query that he forgot the root password and can&#8217;t loose any data even if he reinstall OS to gain access again. Our team however suggested a password reset for this Centos 7 system. Here&#8217;s all the steps we followed him to gain back access to his [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":14214,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[60],"tags":[],"class_list":["post-14449","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux"],"acf":[],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/www.shineservers.com\/wp-content\/uploads\/2023\/08\/5172991_internet_lock_locked_padlock_password_icon.svg","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/posts\/14449","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/comments?post=14449"}],"version-history":[{"count":0,"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/posts\/14449\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/media\/14214"}],"wp:attachment":[{"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/media?parent=14449"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/categories?post=14449"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/tags?post=14449"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}