{"id":30,"date":"2019-04-16T17:32:57","date_gmt":"2019-04-16T17:32:57","guid":{"rendered":"https:\/\/serverhub.com\/kb\/?p=30"},"modified":"2019-04-16T17:32:57","modified_gmt":"2019-04-16T17:32:57","slug":"how-to-reset-your-root-password-on-centos-7-servers","status":"publish","type":"post","link":"https:\/\/serverhub.com\/kb\/how-to-reset-your-root-password-on-centos-7-servers\/","title":{"rendered":"How To Reset Your Root Password On CentOS 7 Servers"},"content":{"rendered":"\n<p>This tutorial is going to show you a simple trick that you can use to reset your forgotten root password for CentOS 7 servers. Sometimes things happen and you totally forget your password. It happens to the best of us.<br><br>This tutorial will only work if you have direct access to the machine (example: You are next to the machine or have KVM\/IPMI) <br><br> You can\u2019t reset the root password if you\u2019re remotely connected since you need boot menu access.<br><br>If you have a ServerHub Bare Metal Server this shouldn&#8217;t be an issue as we offer IPMI completely free with every server we sell. <br><br><\/p>\n\n\n\n<p><strong>To get started, turn on the machine that you\u2019ve forgotten the root password on. <\/strong>For CentOS 7 devices, you\u2019ll be given 5 seconds at the boot menu to select the operating system kernel to boot into.<\/p>\n\n\n\n<p><em>That 5 seconds is important, because allows for \u00a0admins to select different kernels or edit existing kernel parameters before booting.<\/em><\/p>\n\n\n\n<p>At the boot menu, press\u00a0<strong>e<\/strong>\u00a0to edit the existing kernel (Core)<\/p>\n\n\n\n<p>Next, scroll down to the list until you see the line underlined below (\u00a0<strong><g class=\"gr_ gr_5 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace\" id=\"5\" data-gr-id=\"5\">ro<\/g><\/strong>\u00a0<g class=\"gr_ gr_9 gr-alert gr_gramm gr_inline_cards gr_run_anim Style multiReplace\" id=\"9\" data-gr-id=\"9\">) .<\/g> What we need to do is change that <g class=\"gr_ gr_6 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace\" id=\"6\" data-gr-id=\"6\">ro<\/g> to <g class=\"gr_ gr_7 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace\" id=\"7\" data-gr-id=\"7\">rw<\/g> and start into a bash shell. It should look like this\u00a0<strong><g class=\"gr_ gr_8 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling\" id=\"8\" data-gr-id=\"8\">rw<\/g> init=\/sysroot\/bin\/sh.<\/strong><\/p>\n\n\n\n<p>Change the&nbsp;<strong>ro<\/strong>&nbsp;line to&nbsp;<strong>rw<\/strong>&nbsp;and add&nbsp;<strong>init=\/sysroot\/bin\/sh<\/strong><\/p>\n\n\n\n<p><code>rw init=\/sysroot\/bin\/sh<\/code><\/p>\n\n\n\n<p>After changing that, press&nbsp;<strong>Control + X<\/strong>&nbsp;&nbsp;or&nbsp;<strong>Ctrl + X<\/strong>&nbsp;&nbsp;on your keyboard to start into single user mode using the bash shell specified above. In this mode, we\u2019re going to change the root password.<\/p>\n\n\n\n<p>In the single user mode, run the command as shown below<\/p>\n\n\n\n<p><code>chroot \/sysroot<\/code><\/p>\n\n\n\n<p>Finally, run the commands below to change the root password.<\/p>\n\n\n\n<p>You\u2019ll be prompted to create and confirm a new password. &nbsp;After creating the password, run the commands below to update SELinux parameters<\/p>\n\n\n\n<p><code>touch \/.autorelabel<\/code><\/p>\n\n\n\n<p>Exit and reboot your system. Your password should now be successfully reset!<\/p>\n\n\n\n<p><br><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial is going to show you a simple trick that you can use to reset your forgotten root password for CentOS 7 servers. Sometimes things happen and you totally forget your password. It happens to the best of us. This tutorial will only work if you have direct access to the machine (example: You &#8230; <a title=\"How To Reset Your Root Password On CentOS 7 Servers\" class=\"read-more\" href=\"https:\/\/serverhub.com\/kb\/how-to-reset-your-root-password-on-centos-7-servers\/\" aria-label=\"More on How To Reset Your Root Password On CentOS 7 Servers\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"om_disable_all_campaigns":false,"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[7],"tags":[12,8,11],"class_list":["post-30","post","type-post","status-publish","format-standard","hentry","category-linux-administration","tag-centos-password-reset","tag-linux","tag-password-reset"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/serverhub.com\/kb\/wp-json\/wp\/v2\/posts\/30","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/serverhub.com\/kb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/serverhub.com\/kb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/serverhub.com\/kb\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/serverhub.com\/kb\/wp-json\/wp\/v2\/comments?post=30"}],"version-history":[{"count":0,"href":"https:\/\/serverhub.com\/kb\/wp-json\/wp\/v2\/posts\/30\/revisions"}],"wp:attachment":[{"href":"https:\/\/serverhub.com\/kb\/wp-json\/wp\/v2\/media?parent=30"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/serverhub.com\/kb\/wp-json\/wp\/v2\/categories?post=30"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/serverhub.com\/kb\/wp-json\/wp\/v2\/tags?post=30"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}