{"id":12416,"date":"2021-11-28T18:27:49","date_gmt":"2021-11-28T18:27:49","guid":{"rendered":"https:\/\/linuxways.net\/?p=12416"},"modified":"2021-11-28T18:27:49","modified_gmt":"2021-11-28T18:27:49","slug":"how-to-reset-root-password-on-rocky-linux","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/red-hat\/how-to-reset-root-password-on-rocky-linux\/","title":{"rendered":"How to Reset Root Password on Rocky Linux"},"content":{"rendered":"<p>If you need to log in as a root user on your Rocky Linux system after some time and can&#8217;t remember its password, the only method to recover is to reset it.<\/p>\n<p>In this article, we will guide you on how to reset your root password on Rocky Linux 8 from the GRUB menu. The GRUB menu is a boot loader and software that loads and transfers control to an operating system, such as Linux, when a computer is turned on.<\/p>\n<p>So, let&#8217;s dive into this step-by-step tutorial of resetting the root password<\/p>\n<h2><strong>Step 1: Reboot Rocky Linux <\/strong><\/h2>\n<p>First, restart Rocky Linux 8 and press \u2018<strong>e<\/strong> \u2018 on the keyboard as soon as the boot menu appears. This will display the Grub editing interface.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"722\" height=\"406\" class=\"wp-image-12417\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-488.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-488.png 722w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-488-300x169.png 300w\" sizes=\"auto, (max-width: 722px) 100vw, 722px\" \/><\/p>\n<h2><strong>Step 2: Edit Boot Grub Configuration<\/strong><\/h2>\n<p>Next, we need to edit the Grub boot configuration interface. Use arrow keys to navigate the interface. Locate the line beginning with <strong>linux <\/strong>and scroll to the end of the line using the arrow forward key.<\/p>\n<p>Then append the line <strong>rd.break enforcing=0 <\/strong>.<\/p>\n<p>Thereafter, initiate the booting process using Ctrl+X and start the Emergency mode scripting shell.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"724\" height=\"404\" class=\"wp-image-12418\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-489.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-489.png 724w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-489-300x167.png 300w\" sizes=\"auto, (max-width: 724px) 100vw, 724px\" \/><\/p>\n<h2><strong>Step 3: Mount Filesystem in \u201cread and write\u201d mode<\/strong><\/h2>\n<p>In order to reset the root password on Rocky Linux, we first need read and write access to the sysroot filesystem. Run the following command to mount the filesystem in \u2018read\u2019 and \u2018write \u2018 mode:<\/p>\n<pre><strong>$ mount -o remount,rw \/sysroot<\/strong><\/pre>\n<p>Next, navigate the directory to the sysroot directory using the command below:<\/p>\n<pre><strong>$ chroot \/sysroot<\/strong><\/pre>\n<h2><strong>Step 4: Reset password<\/strong><\/h2>\n<p>Finally, everything is in place, and we can now change the password of the available root user. Run the command shown:<\/p>\n<pre><strong>$ passwd root<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"801\" height=\"602\" class=\"wp-image-12419\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-490.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-490.png 801w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-490-300x225.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/11\/word-image-490-768x577.png 768w\" sizes=\"auto, (max-width: 801px) 100vw, 801px\" \/><\/strong><\/p>\n<p>The system will prompt you for a new password. Ensure to set a strong password with at least 8 characters, otherwise, you will be warned that the password is weak. If everything is correct, the password will be updated successfully. Press the Enter key to proceed. Next, exit the Sysroot directory using the exit command.<\/p>\n<p>To reset the root password, we changed the file system rights to read and write. We need to set it back to read only. Therefore, execute the command:<\/p>\n<pre><strong>$ mount -o remount,ro \/sysroot<\/strong><\/pre>\n<h2><strong>Step 5: Exit session and reboot<\/strong><\/h2>\n<p>Next, exit the switch root session and let your system restart.<\/p>\n<pre><strong>$ exit<\/strong><\/pre>\n<p>You can now log in to your root user with the new password.<\/p>\n<h2><strong>Step 6: Set SELinux enforcing modes<\/strong><\/h2>\n<p>According to the Redhat official guide of resetting system passwords, it is recommended to delete any residue entries from the <strong> \/etc\/shadow <\/strong>file that stores system passwords. So, once you have logged in execute the following command:<\/p>\n<pre><strong>$ restorecon \/etc\/shadow<\/strong><\/pre>\n<p>Next, enable policies of SELinux as shown:<\/p>\n<pre><strong>$ setenforce 1<\/strong><\/pre>\n<h2><strong>Conclusion<\/strong><\/h2>\n<p>Resetting the root password on Rocky Linux is a simple and straightforward process as demonstrated in this guide.<\/p>","protected":false},"excerpt":{"rendered":"<p>If you need to log in as a root user on your Rocky Linux system after some time and can&#8217;t remember its password, the only method to recover&hellip;<\/p>","protected":false},"author":1,"featured_media":12519,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[165],"tags":[215,411,697],"class_list":["post-12416","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-red-hat","tag-password","tag-rocky-linux","tag-root"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/12416","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=12416"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/12416\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/12519"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=12416"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=12416"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=12416"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}