{"id":175,"date":"2021-11-05T11:54:07","date_gmt":"2021-11-05T11:54:07","guid":{"rendered":"http:\/\/webhostingpune.co.in\/blog\/?p=175"},"modified":"2024-01-09T12:57:03","modified_gmt":"2024-01-09T12:57:03","slug":"how-to-reset-root-password-on-centos-7","status":"publish","type":"post","link":"https:\/\/webhostingpune.co.in\/blog\/how-to-reset-root-password-on-centos-7\/","title":{"rendered":"How To Reset Root Password On CentOS 7"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Have you ever encountered a situation when you missed your user account password on a Linux System? If you forget user password, you can easily reset it using root account.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">What if you forget your root password? You cannot reset root account password using user account. Since user account is not permitted to perform such task in general.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"> So I planned to boot into single user mode.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>As the system boots, press\u00a0<kbd>ESC<\/kbd>\u00a0to bring up the GRUB boot prompt. The prompt happens early in the boot process. If you miss the prompt, you need to restart the server from the control panel and try again.<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"729\" height=\"391\" src=\"http:\/\/webhostingpune.co.in\/blog\/wp-content\/uploads\/2021\/11\/reb.png\" alt=\"\" class=\"wp-image-176\" srcset=\"https:\/\/webhostingpune.co.in\/blog\/wp-content\/uploads\/2021\/11\/reb.png 729w, https:\/\/webhostingpune.co.in\/blog\/wp-content\/uploads\/2021\/11\/reb-300x161.png 300w\" sizes=\"auto, (max-width: 729px) 100vw, 729px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\"><li>At the GRUB boot prompt, press\u00a0<kbd>E<\/kbd>\u00a0to edit the first boot option.<\/li><li>Find the kernel line starting with\u00a0<strong>linux16<\/strong>.<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"710\" height=\"317\" src=\"http:\/\/webhostingpune.co.in\/blog\/wp-content\/uploads\/2021\/11\/reb1.png\" alt=\"\" class=\"wp-image-177\" srcset=\"https:\/\/webhostingpune.co.in\/blog\/wp-content\/uploads\/2021\/11\/reb1.png 710w, https:\/\/webhostingpune.co.in\/blog\/wp-content\/uploads\/2021\/11\/reb1-300x134.png 300w\" sizes=\"auto, (max-width: 710px) 100vw, 710px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\"><li>Change\u00a0<code>ro<\/code>\u00a0to\u00a0<code>rw init=\/sysroot\/bin\/sh<\/code>.<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"698\" height=\"322\" src=\"http:\/\/webhostingpune.co.in\/blog\/wp-content\/uploads\/2021\/11\/reb2.png\" alt=\"\" class=\"wp-image-178\" srcset=\"https:\/\/webhostingpune.co.in\/blog\/wp-content\/uploads\/2021\/11\/reb2.png 698w, https:\/\/webhostingpune.co.in\/blog\/wp-content\/uploads\/2021\/11\/reb2-300x138.png 300w\" sizes=\"auto, (max-width: 698px) 100vw, 698px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\"><li>Press\u00a0<kbd>CTRL<\/kbd>+<kbd>X<\/kbd>\u00a0or\u00a0<kbd>F10<\/kbd>\u00a0to boot into single user mode.<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/webhostingpune.co.in\/blog\/wp-content\/uploads\/2021\/11\/reb3.png\" alt=\"\" class=\"wp-image-179\" width=\"684\" height=\"448\" srcset=\"https:\/\/webhostingpune.co.in\/blog\/wp-content\/uploads\/2021\/11\/reb3.png 569w, https:\/\/webhostingpune.co.in\/blog\/wp-content\/uploads\/2021\/11\/reb3-300x197.png 300w\" sizes=\"auto, (max-width: 684px) 100vw, 684px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\"><li>Access the system with the command:\u00a0<code>chroot \/sysroot<\/code><\/li><li>Type\u00a0<code>passwd<\/code>\u00a0and follow the prompts to change the root password.<\/li><li>Run\u00a0<code>touch \/.autorelabel<\/code>\u00a0to force file system relabeling. This is required for systems with SELinux. When you reboot the system, it will relabel the filesystem for SElinux. The reboot may take extra time during this process.<\/li><li>Run\u00a0<code>reboot -f<\/code>\u00a0to reboot the server.<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>That\u2019s it. Hope this blog is helpful.<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Have you ever encountered a situation when you missed your user account password on a Linux System? If you forget user password, you can easily reset it using root account. What if you forget your root password? You cannot reset root account password using user account. Since user account is not permitted to perform such task in general. So I planned to boot into single user mode. As the system boots, press\u00a0ESC\u00a0to bring up the GRUB boot prompt. The prompt happens early in the boot process. If you miss the prompt, you need to restart the server from the control panel and try again. At the GRUB boot prompt, press\u00a0E\u00a0to edit the first boot option. Find the kernel line starting with\u00a0linux16. Change\u00a0ro\u00a0to\u00a0rw init=\/sysroot\/bin\/sh. Press\u00a0CTRL+X\u00a0or\u00a0F10\u00a0to boot into single user mode. Access the system with the command:\u00a0chroot \/sysroot Type\u00a0passwd\u00a0and follow the prompts to change the root password. Run\u00a0touch \/.autorelabel\u00a0to force file system relabeling. This is required for systems with SELinux. When you reboot the system, it will relabel the filesystem for SElinux. The reboot may take extra time during this process. Run\u00a0reboot -f\u00a0to reboot the server. That\u2019s it. Hope this blog is helpful.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","footnotes":""},"categories":[1],"tags":[],"class_list":["post-175","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/webhostingpune.co.in\/blog\/wp-json\/wp\/v2\/posts\/175","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webhostingpune.co.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webhostingpune.co.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webhostingpune.co.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/webhostingpune.co.in\/blog\/wp-json\/wp\/v2\/comments?post=175"}],"version-history":[{"count":1,"href":"https:\/\/webhostingpune.co.in\/blog\/wp-json\/wp\/v2\/posts\/175\/revisions"}],"predecessor-version":[{"id":180,"href":"https:\/\/webhostingpune.co.in\/blog\/wp-json\/wp\/v2\/posts\/175\/revisions\/180"}],"wp:attachment":[{"href":"https:\/\/webhostingpune.co.in\/blog\/wp-json\/wp\/v2\/media?parent=175"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webhostingpune.co.in\/blog\/wp-json\/wp\/v2\/categories?post=175"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webhostingpune.co.in\/blog\/wp-json\/wp\/v2\/tags?post=175"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}