{"id":195,"date":"2020-06-08T08:54:20","date_gmt":"2020-06-08T00:54:20","guid":{"rendered":"https:\/\/www.stusc.com\/?p=195"},"modified":"2020-06-08T08:54:20","modified_gmt":"2020-06-08T00:54:20","slug":"how-to-reset-forgotten-or-lost-root-password-in-fedora","status":"publish","type":"post","link":"https:\/\/www.stusc.com\/?p=195","title":{"rendered":"How to Reset Forgotten or Lost Root Password in Fedora"},"content":{"rendered":"\n<h6 class=\"has-text-align-right wp-block-heading\"> by\u00a0<a href=\"https:\/\/www.tecmint.com\/author\/admin\/\">Ravi Saive<\/a>\u00a0| Published: March 15, 2019 |\u00a0March 15, 2019 <\/h6>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>\u672c\u64cd\u4f5c\u5b8c\u5168\u62f7\u8d1d\u81ea <a href=\"https:\/\/www.tecmint.com\/\">https:\/\/www.tecmint.com\/<\/a> \uff0c\u76ee\u524d\u5c1a\u672a\u9a8c\u8bc1\uff0c\u7248\u6743\u5f52TecMint\u6240\u6709\u3002<\/p><\/blockquote>\n\n\n\n<p>A Linux system administrator can quickly reset a user forgotten password using&nbsp;<strong>passwd command<\/strong>, but what happens if the system administrator itself forgets the root password? In this article, we will explain how to reset a forgotten or lost root user password in Fedora Linux distribution.<\/p>\n\n\n\n<p>Note that to reset the lost root user password, you must have physical access to the Fedora machine in order to access Grub settings to reset and reboot the machine. Additionally, if your Fedora system is encrypted, you will also get to know the&nbsp;<a href=\"https:\/\/www.tecmint.com\/linux-hard-disk-encryption-using-luks\/\" target=\"_blank\" rel=\"noreferrer noopener\">LUKS passphrase<\/a>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Edit the Fedora GRUB Settings<\/h3>\n\n\n\n<p>To edit the Fedora Grub settings, you need to interrupt the boot process by restarting the Fedora machine and press&nbsp;<code>E<\/code>&nbsp;on your keyboard when you see the following GRUB menu:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2019\/03\/Fedora-Grub-Menu.png\"><img decoding=\"async\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2019\/03\/Fedora-Grub-Menu.png\" alt=\"Fedora Grub Menu\" class=\"wp-image-32129\" \/><\/a><\/figure>\n\n\n\n<p>Fedora Grub Menu<\/p>\n\n\n\n<p>After pressing&nbsp;<code>E<\/code>&nbsp;on your keyboard, you will get the following screen.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2019\/03\/Edit-Fedora-Grub-Settings.png\"><img decoding=\"async\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2019\/03\/Edit-Fedora-Grub-Settings.png\" alt=\"Edit Fedora Grub Settings\" class=\"wp-image-32131\" \/><\/a><\/figure>\n\n\n\n<p>Edit Fedora Grub Settings<\/p>\n\n\n\n<p>Use your keyboard arrow keys and go to the line&nbsp;<code>linux<\/code>&nbsp;as shown.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2019\/03\/Find-Linux-in-Grub-Settings.png\"><img decoding=\"async\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2019\/03\/Find-Linux-in-Grub-Settings.png\" alt=\"Go to the line Linux&quot; in Grub Settings\" class=\"wp-image-32132\" \/><\/a><\/figure>\n\n\n\n<p>Go to the line Linux\u201d in Grub Settings<\/p>\n\n\n\n<p>After finding the&nbsp;<code>linux<\/code>&nbsp;line, remove&nbsp;<code>rhgb quiet<\/code>&nbsp;and replace with the following.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">rd.break enforcing=0\n<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2019\/03\/Edit-Fedora-Grub-Boot-Settings.png\"><img decoding=\"async\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2019\/03\/Edit-Fedora-Grub-Boot-Settings.png\" alt=\"Edit Fedora Grub Boot Settings\" class=\"wp-image-32133\" \/><\/a><\/figure>\n\n\n\n<p>Edit Fedora Grub Boot Settings<\/p>\n\n\n\n<p>Once you have done with editing the line, press&nbsp;<code>Ctrl-x<\/code>&nbsp;to save and start the system.<\/p>\n\n\n\n<p><strong>Note<\/strong>: Adding&nbsp;<code>enforcing=0<\/code>, bypass performing an entire system SELinux relabeling. Once the system is restarted, restore the appropriate SELinux context for the&nbsp;<strong>\/etc\/shadow<\/strong>&nbsp;file as explained below in this article.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Mounting the Fedora Filesystem<\/h3>\n\n\n\n<p>Once the system started in emergency mode, you need to remount the hard drive with read-write permission using the following command on the terminal.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># mount -o remount,rw \/sysroot<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2019\/03\/Mount-Fedora-Drive-in-Read-Write-Access.png\"><img decoding=\"async\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2019\/03\/Mount-Fedora-Drive-in-Read-Write-Access.png\" alt=\"Mount Fedora Drive in Read &amp; Write Access\" class=\"wp-image-32134\" \/><\/a><\/figure>\n\n\n\n<p>Mount Fedora Drive in Read &amp; Write Access<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Set Forgotten Root Password in Fedora<\/h3>\n\n\n\n<p>Now run the following&nbsp;<code>chroot<\/code>&nbsp;command to access the Fedora system.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># chroot \/sysroot<\/pre>\n\n\n\n<p>You can now reset the forgotten or lost Fedora root user password using&nbsp;<strong>passwd command<\/strong>&nbsp;as shown.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># passwd<\/pre>\n\n\n\n<p>Enter the new root user password twice when asked. If you are successful, you should get a message that&nbsp;<strong>all authentication tokens updated successfully<\/strong>&nbsp;as shown.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2019\/03\/Reset-Fedora-Root-User-Password.png\"><img decoding=\"async\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2019\/03\/Reset-Fedora-Root-User-Password.png\" alt=\"Reset Fedora Root User Password\" class=\"wp-image-32135\" \/><\/a><\/figure>\n\n\n\n<p>Reset Fedora Root User Password<\/p>\n\n\n\n<p>Type&nbsp;<code>exit<\/code>, twice to reboot the system.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Set SELinux Context on Shadow File<\/h3>\n\n\n\n<p>Log in as root user and type the following command to restore the&nbsp;<strong>SELinux<\/strong>&nbsp;label on the&nbsp;<code>\/etc\/shadow<\/code>&nbsp;file.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># restorecon -v \/etc\/shadow<\/pre>\n\n\n\n<p>Turn&nbsp;<strong>SELinux<\/strong>&nbsp;back to enforcing mode.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># setenforce 1<\/pre>\n\n\n\n<p>That\u2019s all! If you face any issues while resetting forgotten or lost Fedora root user password, do ask in the comments section below.Sharing is Caring&#8230;\n\n<\/p>\n","protected":false},"excerpt":{"rendered":"<p>How to Reset Forgotten or Lost Root Password in Fedora<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[20,21,27,34,36],"class_list":{"0":"post-195","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"hentry","6":"category-tech","7":"tag-fedora","8":"tag-forgotten","9":"tag-lost","10":"tag-reset","11":"tag-root-password","12":"h-entry","14":"h-as-article"},"_links":{"self":[{"href":"https:\/\/www.stusc.com\/index.php?rest_route=\/wp\/v2\/posts\/195","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.stusc.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.stusc.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.stusc.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.stusc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=195"}],"version-history":[{"count":0,"href":"https:\/\/www.stusc.com\/index.php?rest_route=\/wp\/v2\/posts\/195\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.stusc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=195"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.stusc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=195"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.stusc.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=195"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}