From Fedora Project Wiki

(how to reset root password)
 
No edit summary
 
(34 intermediate revisions by 7 users not shown)
Line 1: Line 1:
Setting up root password is a mandatory part of a Fedora installation. If you forget your root password, there is a way to reset it. Note that if you have set a password for your boot loader and/or encrypted your hard disk as well during installation, it is more difficult to do so and this document doesn't cover that scenario.


Fedora uses run levels to determine the services being run when you start your system. Run level 1 is used as a recovery mode. Booting Linux under runlevel 1 or single user mode will allow you to reset your root password and you will directly get a root prompt on bootup. It is very easy to reset the password after that.  
{{Admon/warning|| This page is outdated and needs to be verified against current releases of Fedora.}}


== Entering run level 1 ==
Setting up a root password is a mandatory part of a Fedora installation. If you forget or otherwise lose your root password, there are procedures to reset it.
* If you have set a password for your boot loader, refer to [[#using-installation-cd-dvd | this section]].
* If you want to reset the boot loader password, refer to [[Reset_Bootloader_Password | these instructions]].
* If none of these scenarios apply to you, proceed to [[#Entering_Rescue_Mode | the next section]].


While you system is starting up, press escape to see the bootloader called GRUB. After you see the menu,
Fedora uses ''targets'' to determine the services being run when you start your system. Run level 1 can be used as a rescue mode. Booting Linux under run level 1, which is also called ''single user mode'', will display a root prompt on bootup, from which you can reset the root password.


    * use the arrows to select the boot entry you want to modify.
== Entering Rescue Mode ==
    * press e to edit the entry
=== Using GRUB2 ===
    * use the arrows to go to kernel line
{{Admon/note||GRUB2 has been the default boot loader since Fedora 16.}}
    * press a to append this entry
    * at the end of the line add the word single (or number 1)
    * press ESC to go back to the parent menu
    * press b to boot this kernel


You will see a series of text messages scroll by and you will get a root prompt with the text shell prompting for your commands(#).
While booting the system the GRUB2 menu will be displayed, to boot the system using bash follow these steps:
* Use the arrow keys to select the boot entry you want to edit
* Press '''e''' to start editing that entry
* Use the arrow keys to go to the line that starts with '''linux''' or '''linux16'''
** If you have a UEFI system it's the line that starts with '''linuxefi'''
* Go the the end of that line add a space then '''rw''' then another space and '''init=/bin/bash'''
** If your disk is encrypted, you may need to add '''plymouth.enable=0''' as well
* Press '''Ctrl-x''' or '''F10''' to boot that entry
 
 
{{admon/note | Encrypted partitions | Whichever GRUB version your system has, if you have an encrypted partition, you are prompted for the pass phrase before mounting the filesystems. If have more than one encrypted partition and they all share a global pass phrase, select the option for global pass phrase. Otherwise, enter the pass phrase separately for each partition.}}


== Changing root password ==
== Changing root password ==


As root, changing password does not ask for your old password. Run the command:
As root, changing password does not ask for your old password. Run the command:
<pre># passwd</pre>
Enter your new root password twice. Congratulations! You now have now reset your root password.
To make sure that selinux context of file which were now modified is restored properly after reboot, run:
<pre># touch /.autorelabel</pre>
You can than reboot the machine with
<pre># /sbin/reboot -f</pre>
{{Anchor|using-installation-cd-dvd}}
== Reset Password Using a Fedora CD/DVD ==
{{Admon/note|Usage cases|This method should work to reset the root password if the boot loader is password protected. Or if you have a Fedora 19 (or newer) installation where booting to the rescue mode (which now invokes /sbin/sulogin) will ask you for the root password to proceed.}}
=== Using any of the Fedora Live Media ===
* Boot the Live installation media
* After it finishes booting and starts the live session, open a terminal and switch to root (using <code>su</code>, it won't ask for a password)
* Create a directory where you can mount the filesystem of your installation:
<code>mkdir /mnt/sysimage</code>
* Mount the filesystem of your installation (/dev/sda1 is just an example, be sure to fill in the actual device node of your installation root '''/''' partition):
<code>mount /dev/sda1 /mnt/sysimage</code>
* chroot to your installation:
<code>chroot /mnt/sysimage/</code>
* Change the root password:
<code>passwd</code>
* Exit from the chroot:
<code>exit</code>
That's it, simply reboot your system and then boot the installation from the HDD as usual.
== Reset Password When BIOS is Password Protected ==


# passwd
If you cannot enter rescue mode because you forgot the BIOS password required to select an alternate boot device, you have three options:
* Refer to your computer's documentation for instructions on resetting the BIOS password in CMOS memory, usually by moving a physical jumper.
* Physically change the boot order.
* Temporarily move the system hard disk to another machine, and follow the procedures above to reset the root password.


Enter your new root password twice. Congratulations! You now have now reset your root password. You can type reboot and press enter to restart your system.
[[Category:How_to]]

Latest revision as of 18:20, 15 August 2015

Warning.png
This page is outdated and needs to be verified against current releases of Fedora.

Setting up a root password is a mandatory part of a Fedora installation. If you forget or otherwise lose your root password, there are procedures to reset it.

Fedora uses targets to determine the services being run when you start your system. Run level 1 can be used as a rescue mode. Booting Linux under run level 1, which is also called single user mode, will display a root prompt on bootup, from which you can reset the root password.

Entering Rescue Mode

Using GRUB2

Note.png
GRUB2 has been the default boot loader since Fedora 16.

While booting the system the GRUB2 menu will be displayed, to boot the system using bash follow these steps:

  • Use the arrow keys to select the boot entry you want to edit
  • Press e to start editing that entry
  • Use the arrow keys to go to the line that starts with linux or linux16
    • If you have a UEFI system it's the line that starts with linuxefi
  • Go the the end of that line add a space then rw then another space and init=/bin/bash
    • If your disk is encrypted, you may need to add plymouth.enable=0 as well
  • Press Ctrl-x or F10 to boot that entry


Note.png
Encrypted partitions
Whichever GRUB version your system has, if you have an encrypted partition, you are prompted for the pass phrase before mounting the filesystems. If have more than one encrypted partition and they all share a global pass phrase, select the option for global pass phrase. Otherwise, enter the pass phrase separately for each partition.

Changing root password

As root, changing password does not ask for your old password. Run the command:

# passwd

Enter your new root password twice. Congratulations! You now have now reset your root password.

To make sure that selinux context of file which were now modified is restored properly after reboot, run:

# touch /.autorelabel

You can than reboot the machine with

# /sbin/reboot -f

Reset Password Using a Fedora CD/DVD

Note.png
Usage cases
This method should work to reset the root password if the boot loader is password protected. Or if you have a Fedora 19 (or newer) installation where booting to the rescue mode (which now invokes /sbin/sulogin) will ask you for the root password to proceed.


Using any of the Fedora Live Media

  • Boot the Live installation media
  • After it finishes booting and starts the live session, open a terminal and switch to root (using su, it won't ask for a password)
  • Create a directory where you can mount the filesystem of your installation:

mkdir /mnt/sysimage

  • Mount the filesystem of your installation (/dev/sda1 is just an example, be sure to fill in the actual device node of your installation root / partition):

mount /dev/sda1 /mnt/sysimage

  • chroot to your installation:

chroot /mnt/sysimage/

  • Change the root password:

passwd

  • Exit from the chroot:

exit

That's it, simply reboot your system and then boot the installation from the HDD as usual.

Reset Password When BIOS is Password Protected

If you cannot enter rescue mode because you forgot the BIOS password required to select an alternate boot device, you have three options:

  • Refer to your computer's documentation for instructions on resetting the BIOS password in CMOS memory, usually by moving a physical jumper.
  • Physically change the boot order.
  • Temporarily move the system hard disk to another machine, and follow the procedures above to reset the root password.