{"id":5528,"date":"2016-01-01T12:28:10","date_gmt":"2016-01-01T04:28:10","guid":{"rendered":"http:\/\/rmohan.com\/?p=5528"},"modified":"2016-01-01T12:28:10","modified_gmt":"2016-01-01T04:28:10","slug":"reset-your-forgotten-root-password-on-centos-7","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=5528","title":{"rendered":"Reset Your Forgotten Root Password On CentOS 7"},"content":{"rendered":"<h1 class=\"entry-title\">Reset Your Forgotten Root Password On CentOS 7<\/h1>\n<p>To get started, turn on the machine that you\u2019ve forgotten the root password on. 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<p>That 5 seconds is important, because allows for \u00a0admins to select different kernels or edit existing kernel parameters before booting.<\/p>\n<p>At the boot menu, press <strong>e<\/strong> to edit the existing kernel (Core) as shown below.<\/p>\n<p><a href=\"http:\/\/rmohan.com\/wp-content\/uploads\/2016\/01\/centos7-forgot-root-password.png\" rel=\"attachment wp-att-5529\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5529\" src=\"http:\/\/rmohan.com\/wp-content\/uploads\/2016\/01\/centos7-forgot-root-password.png\" alt=\"centos7-forgot-root-password\" width=\"721\" height=\"385\" srcset=\"https:\/\/mohan.sg\/wp-content\/uploads\/2016\/01\/centos7-forgot-root-password.png 721w, https:\/\/mohan.sg\/wp-content\/uploads\/2016\/01\/centos7-forgot-root-password-300x160.png 300w, https:\/\/mohan.sg\/wp-content\/uploads\/2016\/01\/centos7-forgot-root-password-150x80.png 150w, https:\/\/mohan.sg\/wp-content\/uploads\/2016\/01\/centos7-forgot-root-password-400x214.png 400w\" sizes=\"(max-width: 721px) 100vw, 721px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>Next, scroll down to the list until you see the line underlined below ( <strong>ro<\/strong> ) . What we need to do is change that ro to rw and start into a bash shell. It should look like this <strong>rw init=\/sysroot\/bin\/sh.<\/strong><\/p>\n<p><a href=\"http:\/\/rmohan.com\/wp-content\/uploads\/2016\/01\/centos7-forgot-root-password-1.png\" rel=\"attachment wp-att-5530\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5530\" src=\"http:\/\/rmohan.com\/wp-content\/uploads\/2016\/01\/centos7-forgot-root-password-1.png\" alt=\"centos7-forgot-root-password-1\" width=\"721\" height=\"400\" srcset=\"https:\/\/mohan.sg\/wp-content\/uploads\/2016\/01\/centos7-forgot-root-password-1.png 721w, https:\/\/mohan.sg\/wp-content\/uploads\/2016\/01\/centos7-forgot-root-password-1-300x166.png 300w, https:\/\/mohan.sg\/wp-content\/uploads\/2016\/01\/centos7-forgot-root-password-1-150x83.png 150w, https:\/\/mohan.sg\/wp-content\/uploads\/2016\/01\/centos7-forgot-root-password-1-400x222.png 400w\" sizes=\"(max-width: 721px) 100vw, 721px\" \/><\/a> <a href=\"http:\/\/rmohan.com\/wp-content\/uploads\/2016\/01\/centos7-forgot-root-password-2.png\" rel=\"attachment wp-att-5531\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5531\" src=\"http:\/\/rmohan.com\/wp-content\/uploads\/2016\/01\/centos7-forgot-root-password-2.png\" alt=\"centos7-forgot-root-password-2\" width=\"721\" height=\"400\" srcset=\"https:\/\/mohan.sg\/wp-content\/uploads\/2016\/01\/centos7-forgot-root-password-2.png 721w, https:\/\/mohan.sg\/wp-content\/uploads\/2016\/01\/centos7-forgot-root-password-2-300x166.png 300w, https:\/\/mohan.sg\/wp-content\/uploads\/2016\/01\/centos7-forgot-root-password-2-150x83.png 150w, https:\/\/mohan.sg\/wp-content\/uploads\/2016\/01\/centos7-forgot-root-password-2-400x222.png 400w\" sizes=\"(max-width: 721px) 100vw, 721px\" \/><\/a><\/p>\n<p>Change the <strong>ro<\/strong> line to <strong>rw<\/strong> and add <strong>init=\/sysroot\/bin\/sh<\/strong><\/p>\n<p><code>rw init=\/sysroot\/bin\/sh<\/code><\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"http:\/\/rmohan.com\/wp-content\/uploads\/2016\/01\/centos7-forgot-root-password-3.png\" rel=\"attachment wp-att-5532\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5532\" src=\"http:\/\/rmohan.com\/wp-content\/uploads\/2016\/01\/centos7-forgot-root-password-3.png\" alt=\"centos7-forgot-root-password-3\" width=\"721\" height=\"402\" srcset=\"https:\/\/mohan.sg\/wp-content\/uploads\/2016\/01\/centos7-forgot-root-password-3.png 721w, https:\/\/mohan.sg\/wp-content\/uploads\/2016\/01\/centos7-forgot-root-password-3-300x167.png 300w, https:\/\/mohan.sg\/wp-content\/uploads\/2016\/01\/centos7-forgot-root-password-3-150x84.png 150w, https:\/\/mohan.sg\/wp-content\/uploads\/2016\/01\/centos7-forgot-root-password-3-400x223.png 400w\" sizes=\"(max-width: 721px) 100vw, 721px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<header class=\"entry-header\">\n<h1 class=\"entry-title\"><\/h1>\n<\/header>\n<div class=\"entry-content\">\n<p>Sometimes you forget stuff. I do. I forget important passwords for important websites sometimes. Retrieving your forgotten passwords for most websites is easy, all one has to do remember few details that were used when signing up for the service to get a password reset for an account.<\/p>\n<p>The difference is forgetting a password to a system or device with no easy way to reset it while locked out. CentOS 7 is one such system. If you forget the root password to your CentOS 7 machine, it\u2019s almost virtually impossible to reset it while you\u2019re locked out.<\/p>\n<p>This brief tutorial is going to show you a simple trick that you can use to reset your forgotten root password for CentOS 7 servers. This will definitely come in handy for webmasters who are locked out of your CentOS machine and can\u2019t sign on.<\/p>\n<p>This tutorial will only work if you have direct access to the machine or serial terminal access with boot menu options. You can\u2019t reset the root password if you\u2019re remotely connected since you need boot menu access.<\/p>\n<p>To get started, turn on the machine that you\u2019ve forgotten the root password on. 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<p>That 5 seconds is important, because allows for \u00a0admins to select different kernels or edit existing kernel parameters before booting.<\/p>\n<p>At the boot menu, press <strong>e<\/strong> to edit the existing kernel (Core) as shown below.<\/p>\n<p><a href=\"http:\/\/www.liberiangeek.net\/wp-content\/uploads\/2014\/09\/centos7-forgot-root-password.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-31361\" src=\"http:\/\/www.liberiangeek.net\/wp-content\/uploads\/2014\/09\/centos7-forgot-root-password.png\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" srcset=\"http:\/\/www.liberiangeek.net\/wp-content\/uploads\/2014\/09\/centos7-forgot-root-password-150x80.png 150w, http:\/\/www.liberiangeek.net\/wp-content\/uploads\/2014\/09\/centos7-forgot-root-password-300x160.png 300w, http:\/\/www.liberiangeek.net\/wp-content\/uploads\/2014\/09\/centos7-forgot-root-password.png 721w\" alt=\"Changing root password on centos 7\" width=\"721\" height=\"385\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>Next, scroll down to the list until you see the line underlined below ( <strong>ro<\/strong> ) . What we need to do is change that ro to rw and start into a bash shell. It should look like this <strong>rw init=\/sysroot\/bin\/sh.<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"http:\/\/www.liberiangeek.net\/wp-content\/uploads\/2014\/09\/centos7-forgot-root-password-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-31362\" src=\"http:\/\/www.liberiangeek.net\/wp-content\/uploads\/2014\/09\/centos7-forgot-root-password-1.png\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" srcset=\"http:\/\/www.liberiangeek.net\/wp-content\/uploads\/2014\/09\/centos7-forgot-root-password-1-150x83.png 150w, http:\/\/www.liberiangeek.net\/wp-content\/uploads\/2014\/09\/centos7-forgot-root-password-1-300x166.png 300w, http:\/\/www.liberiangeek.net\/wp-content\/uploads\/2014\/09\/centos7-forgot-root-password-1.png 721w\" alt=\"forgotten root password on centos 7\" width=\"721\" height=\"400\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>Change the <strong>ro<\/strong> line to <strong>rw<\/strong> and add <strong>init=\/sysroot\/bin\/sh<\/strong><\/p>\n<p><code>rw init=\/sysroot\/bin\/sh<\/code><\/p>\n<p><a href=\"http:\/\/www.liberiangeek.net\/wp-content\/uploads\/2014\/09\/centos7-forgot-root-password-2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-31363\" src=\"http:\/\/www.liberiangeek.net\/wp-content\/uploads\/2014\/09\/centos7-forgot-root-password-2.png\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" srcset=\"http:\/\/www.liberiangeek.net\/wp-content\/uploads\/2014\/09\/centos7-forgot-root-password-2-150x83.png 150w, http:\/\/www.liberiangeek.net\/wp-content\/uploads\/2014\/09\/centos7-forgot-root-password-2-300x166.png 300w, http:\/\/www.liberiangeek.net\/wp-content\/uploads\/2014\/09\/centos7-forgot-root-password-2.png 721w\" alt=\"changing root password on centos\" width=\"721\" height=\"400\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>After changing that, press <strong>Control + X<\/strong> \u00a0or <strong>Ctrl + X<\/strong> \u00a0on 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<p>In the single user mode, run the command as shown below<\/p>\n<p><code>chroot \/sysroot<\/code><\/p>\n<\/div>\n<p><a href=\"http:\/\/rmohan.com\/wp-content\/uploads\/2016\/01\/centos7-forgot-root-password-4.png\" rel=\"attachment wp-att-5533\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5533\" src=\"http:\/\/rmohan.com\/wp-content\/uploads\/2016\/01\/centos7-forgot-root-password-4.png\" alt=\"centos7-forgot-root-password-4\" width=\"721\" height=\"98\" srcset=\"https:\/\/mohan.sg\/wp-content\/uploads\/2016\/01\/centos7-forgot-root-password-4.png 721w, https:\/\/mohan.sg\/wp-content\/uploads\/2016\/01\/centos7-forgot-root-password-4-300x41.png 300w, https:\/\/mohan.sg\/wp-content\/uploads\/2016\/01\/centos7-forgot-root-password-4-150x20.png 150w, https:\/\/mohan.sg\/wp-content\/uploads\/2016\/01\/centos7-forgot-root-password-4-400x54.png 400w\" sizes=\"(max-width: 721px) 100vw, 721px\" \/><\/a><\/p>\n<p>You\u2019ll be prompted to create and confirm a new password. \u00a0After creating the password, run the commands below to update SELinux parameters<\/p>\n<p><code>touch \/.autorelabel<\/code><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Reset Your Forgotten Root Password On CentOS 7 <\/p>\n<p>To get started, turn on the machine that you\u2019ve forgotten the root password on. 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<p>That 5 seconds is important, because allows for admins to select [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[73],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/5528"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5528"}],"version-history":[{"count":1,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/5528\/revisions"}],"predecessor-version":[{"id":5534,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/5528\/revisions\/5534"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5528"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5528"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5528"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}