Difference between revisions of "Reset root password"

From ArchWiki
Jump to: navigation, search
(Removed section on single-user mode, since entering single-user mode requires the root password.)
Line 1: Line 1:
If you have been locked out of your root account for whatever reason, you can use this procedure to reset your root password and regain access to your system.
+
=Introduction=
 
+
Below are several methods one can use to reset the system's root password should it be forgotten or corrupted.
 +
=Method 1 - Using the Arch Live CD=
 
1. Boot the Arch Live CD and mount your root partition to <code>/mnt</code>.
 
1. Boot the Arch Live CD and mount your root partition to <code>/mnt</code>.
  
 
2. Bind mount the <code>/dev</code>, <code>/sys</code>, and <code>/proc</code> special mount points into your <code>/mnt</code>:
 
2. Bind mount the <code>/dev</code>, <code>/sys</code>, and <code>/proc</code> special mount points into your <code>/mnt</code>:
  
  mount --bind /dev /mnt/dev
+
  # mount --bind /dev /mnt/dev
  mount --bind /sys /mnt/sys
+
  # mount --bind /sys /mnt/sys
  mount --bind /proc /mnt/proc
+
  # mount --bind /proc /mnt/proc
  
 
3. <code>chroot</code> into your installation:
 
3. <code>chroot</code> into your installation:
  
  chroot /mnt /bin/bash
+
  # chroot /mnt /bin/bash
  
 
4. Use the <code>passwd</code> command to reset your root password.
 
4. Use the <code>passwd</code> command to reset your root password.
 +
5. Reboot and don't lose your password again!
 +
 +
=Method 2 - Using GRUB's Boot Menu=
 +
1. Select the appropriate entry in the GRUB menu and press {{Keypress|e}} to edit the line.
 +
 +
2. Select the kernel ... line and press {{Keypress|e}} again to edit it.
 +
 +
3. Append '''init=/bin/bash''' at the end of line.
 +
 +
4. Press {{Keypress|b}} to boot (don't worry, this change is only temporary and will not be saved to your menu.lst).
  
5. Reboot and don't lose your password again!
+
Once you boot you should be at a (#) prompt.
 +
 
 +
5. Your root file system should be mounted as readonly so remount it as read/write:
 +
# mount -n -o remount,rw /
 +
 
 +
6. Use the <code>passwd</code> command to reset your root password.
 +
 
 +
7. Reboot and don't lose your password again!

Revision as of 10:55, 17 October 2009

Introduction

Below are several methods one can use to reset the system's root password should it be forgotten or corrupted.

Method 1 - Using the Arch Live CD

1. Boot the Arch Live CD and mount your root partition to /mnt.

2. Bind mount the /dev, /sys, and /proc special mount points into your /mnt:

# mount --bind /dev /mnt/dev
# mount --bind /sys /mnt/sys
# mount --bind /proc /mnt/proc

3. chroot into your installation:

# chroot /mnt /bin/bash

4. Use the passwd command to reset your root password. 5. Reboot and don't lose your password again!

Method 2 - Using GRUB's Boot Menu

1. Select the appropriate entry in the GRUB menu and press Template:Keypress to edit the line.

2. Select the kernel ... line and press Template:Keypress again to edit it.

3. Append init=/bin/bash at the end of line.

4. Press Template:Keypress to boot (don't worry, this change is only temporary and will not be saved to your menu.lst).

Once you boot you should be at a (#) prompt.

5. Your root file system should be mounted as readonly so remount it as read/write:

# mount -n -o remount,rw /

6. Use the passwd command to reset your root password.

7. Reboot and don't lose your password again!