{"id":1894,"date":"2018-10-28T10:12:41","date_gmt":"2018-10-28T10:12:41","guid":{"rendered":"https:\/\/www.appservgrid.com\/paw92\/?p=1894"},"modified":"2018-10-31T02:47:42","modified_gmt":"2018-10-31T02:47:42","slug":"recover-a-root-password-on-centos","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2018\/10\/28\/recover-a-root-password-on-centos\/","title":{"rendered":"Recover A Root Password On CentOS"},"content":{"rendered":"<p>To recover the root password on a linux system if you do not have it have misplaced it depends on the major release of the OS. This guide will cover both CentOS 6(and prior releases) and CentOS 7.<\/p>\n<h3>Recover a root password on CentOS 6 or older<\/h3>\n<p>You will need to boot into single user mode. When the system is powering on you will need to enter the grub configuration and append single to the end of the kernel line<\/p>\n<p>Once you are in the grub configuration editor you will need to type \u2018e\u2019 to edit the appropriate kernel. It will take you to another screen. Go down to the line that begins with kernel, you will need to append the following<\/p>\n<p>single<\/p>\n<p>Once you have done that you you can go ahead and type \u2018b\u2019 to boot the kernel.<\/p>\n<p>The OS will reboot into single user mode. This will give you a password less prompt which will allow you to reset the root password by typing the following:<\/p>\n<p>passwd<\/p>\n<p>Once you have entered the new password you can go ahead and reboot the machine which will then load into the default runlevel with the updated password.<\/p>\n<h3>Recover a root password on CentOS 7<\/h3>\n<p>To recover a root password on CentOS 7, you will again need to enter the grub menu and type \u2018e\u2019 to edit the appropriate kernel. Go to the line that begins with kernel and append the following to the end of the line<\/p>\n<p>init=sysroot\/bin\/sh<\/p>\n<p>Then type \u2018b\u2019 to boot this kernel. It will boot up and you will need to mount the file system in a read-write state:<\/p>\n<p>mount -o remount,rw \/sysroot<\/p>\n<p>You will then need to chroot to the mounted filesystem<\/p>\n<p>chroot \/sysroot<\/p>\n<p>Now you can successfully update the root password by typing<\/p>\n<p>passwd<\/p>\n<p>If you have SElinux enabled you will need to enable auto-relabel<\/p>\n<p>touch \/.autorelabel<\/p>\n<p>Now you can go ahead and reboot the system and it should load with the newly set password.<\/p>\n<p><a href=\"https:\/\/linuxadmin.io\/recover-root-password\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>To recover the root password on a linux system if you do not have it have misplaced it depends on the major release of the OS. This guide will cover both CentOS 6(and prior releases) and CentOS 7. Recover a root password on CentOS 6 or older You will need to boot into single user &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2018\/10\/28\/recover-a-root-password-on-centos\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Recover A Root Password On CentOS&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1894","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/1894","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=1894"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/1894\/revisions"}],"predecessor-version":[{"id":2015,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/1894\/revisions\/2015"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=1894"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=1894"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=1894"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}