{"id":449,"date":"2016-04-25T09:07:44","date_gmt":"2016-04-25T13:07:44","guid":{"rendered":"http:\/\/easy-admin.ca\/?p=449"},"modified":"2016-07-12T15:15:02","modified_gmt":"2016-07-12T19:15:02","slug":"how-to-reset-your-forgotten-root-password-on-centos-7-servers","status":"publish","type":"post","link":"https:\/\/easy-admin.ca\/index.php\/2016\/04\/25\/how-to-reset-your-forgotten-root-password-on-centos-7-servers\/","title":{"rendered":"How To Reset Your Forgotten Root Password On CentOS 7 Servers"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-450\" src=\"http:\/\/easy-admin.ca\/my_uploads\/2016\/04\/reset-root-password-centos7-00a.png\" alt=\"reset-root-password-centos7-00a\" width=\"721\" height=\"402\" srcset=\"https:\/\/easy-admin.ca\/wp-content\/uploads\/2016\/04\/reset-root-password-centos7-00a.png 721w, https:\/\/easy-admin.ca\/wp-content\/uploads\/2016\/04\/reset-root-password-centos7-00a-300x167.png 300w\" sizes=\"auto, (max-width: 721px) 100vw, 721px\" \/><\/p>\n<p><em><strong>Sometimes you forget stuff.<\/strong><\/em> &#8220;I do&#8221;. <em>I forget important passwords for important websites sometimes!!!<\/em><\/p>\n<p>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.<strong> CentOS 7<\/strong> is one such system. If you forget the root password to your <strong>CentOS 7<\/strong> 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 <strong>CentOS 7<\/strong> 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 <strong>CentOS 7<\/strong> devices, <strong>you\u2019ll be given 5 seconds at the boot menu to select the operating system kernel to boot into.<\/strong><\/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><span style=\"color: #ff0000;\">At the boot menu, press <em><strong>e<\/strong><\/em> to edit the existing kernel (Core) as shown below.<\/span><\/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 <em><strong>rw init=\/sysroot\/bin\/sh<\/strong><\/em><\/p>\n<p><a href=\"http:\/\/easy-admin.ca\/my_uploads\/2016\/04\/reset-root-password-centos7-01.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-451 size-full\" src=\"http:\/\/easy-admin.ca\/my_uploads\/2016\/04\/reset-root-password-centos7-01.png\" alt=\"reset-root-password-centos7-01\" width=\"721\" height=\"400\" srcset=\"https:\/\/easy-admin.ca\/wp-content\/uploads\/2016\/04\/reset-root-password-centos7-01.png 721w, https:\/\/easy-admin.ca\/wp-content\/uploads\/2016\/04\/reset-root-password-centos7-01-300x166.png 300w\" sizes=\"auto, (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><em><strong>rw init=\/sysroot\/bin\/sh<\/strong><\/em><\/p>\n<p><a href=\"http:\/\/easy-admin.ca\/my_uploads\/2016\/04\/reset-root-password-centos7-02.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-452 size-full\" src=\"http:\/\/easy-admin.ca\/my_uploads\/2016\/04\/reset-root-password-centos7-02.png\" alt=\"reset-root-password-centos7-02\" width=\"721\" height=\"400\" srcset=\"https:\/\/easy-admin.ca\/wp-content\/uploads\/2016\/04\/reset-root-password-centos7-02.png 721w, https:\/\/easy-admin.ca\/wp-content\/uploads\/2016\/04\/reset-root-password-centos7-02-300x166.png 300w\" sizes=\"auto, (max-width: 721px) 100vw, 721px\" \/><\/a><\/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><em><strong>chroot \/sysroot<\/strong><\/em><\/p>\n<p><a href=\"http:\/\/easy-admin.ca\/my_uploads\/2016\/04\/reset-root-password-centos7-03.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-453 size-full\" src=\"http:\/\/easy-admin.ca\/my_uploads\/2016\/04\/reset-root-password-centos7-03.png\" alt=\"reset-root-password-centos7-03\" width=\"721\" height=\"402\" srcset=\"https:\/\/easy-admin.ca\/wp-content\/uploads\/2016\/04\/reset-root-password-centos7-03.png 721w, https:\/\/easy-admin.ca\/wp-content\/uploads\/2016\/04\/reset-root-password-centos7-03-300x167.png 300w\" sizes=\"auto, (max-width: 721px) 100vw, 721px\" \/><\/a><\/p>\n<p>Finally, run the commands below to change the root password.<\/p>\n<p><a href=\"http:\/\/easy-admin.ca\/my_uploads\/2016\/04\/reset-root-password-centos7-04.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-454 size-full\" src=\"http:\/\/easy-admin.ca\/my_uploads\/2016\/04\/reset-root-password-centos7-04.png\" alt=\"reset-root-password-centos7-04\" width=\"721\" height=\"98\" srcset=\"https:\/\/easy-admin.ca\/wp-content\/uploads\/2016\/04\/reset-root-password-centos7-04.png 721w, https:\/\/easy-admin.ca\/wp-content\/uploads\/2016\/04\/reset-root-password-centos7-04-300x41.png 300w\" sizes=\"auto, (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 <em><strong><span style=\"color: #ff0000;\">SELinux<\/span><\/strong><\/em> parameters<\/p>\n<p><em><strong>touch \/.autorelabel<\/strong><\/em><\/p>\n<p>Exit and reboot your system. You should be able to sign on and use the system with the new password you created. This is how you change the root password on <em><strong>CentOS 7<\/strong><\/em>.<\/p>\n<p><strong>Note:<\/strong> If you have multiple users on your <strong>CentOS 7<\/strong> you will need to be very careful about running those commands!<\/p>\n<p><em><strong>Tested &amp; Working good<\/strong><\/em> ?<\/p>\n<p><em>Enjoy!<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes you forget stuff. &#8220;I do&#8221;. 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. The difference is forgetting a password to &hellip; <a href=\"https:\/\/easy-admin.ca\/index.php\/2016\/04\/25\/how-to-reset-your-forgotten-root-password-on-centos-7-servers\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">How To Reset Your Forgotten Root Password On CentOS 7 Servers<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-449","post","type-post","status-publish","format-standard","hentry","category-general"],"_links":{"self":[{"href":"https:\/\/easy-admin.ca\/index.php\/wp-json\/wp\/v2\/posts\/449","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/easy-admin.ca\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/easy-admin.ca\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/easy-admin.ca\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/easy-admin.ca\/index.php\/wp-json\/wp\/v2\/comments?post=449"}],"version-history":[{"count":0,"href":"https:\/\/easy-admin.ca\/index.php\/wp-json\/wp\/v2\/posts\/449\/revisions"}],"wp:attachment":[{"href":"https:\/\/easy-admin.ca\/index.php\/wp-json\/wp\/v2\/media?parent=449"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/easy-admin.ca\/index.php\/wp-json\/wp\/v2\/categories?post=449"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/easy-admin.ca\/index.php\/wp-json\/wp\/v2\/tags?post=449"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}