Reset root password

From ArchWiki
Revision as of 16:40, 11 December 2011 by Strcat (Talk | contribs) (codeline -> ic)

Jump to: navigation, search

This template has only maintenance purposes. For linking to local translations please use interlanguage links, see Help:i18n#Interlanguage links.

Local languages: Català – Dansk – English – Español – Esperanto – Hrvatski – Indonesia – Italiano – Lietuviškai – Magyar – Nederlands – Norsk Bokmål – Polski – Português – Slovenský – Česky – Ελληνικά – Български – Русский – Српски – Українська – עברית – العربية – ไทย – 日本語 – 正體中文 – 简体中文 – 한국어

External languages (all articles in these languages should be moved to the external wiki): Deutsch – Français – Română – Suomi – Svenska – Tiếng Việt – Türkçe – فارسی

This guide will show you how to recover a forgotten root password. A several methods are available that can help you accomplish this.

Using a LiveCD

With a LiveCD a couple methods are available: change root and use the passwd command, or erase the password field entry. Any Linux capable LiveCD can be used, albeit to change root it much match your installed architecture type.

Change Root

  1. Boot the LiveCD, and change root.
  2. Use the passwd command to reset your root password.
  3. Exit change root.
  4. Reboot, and remember your password.

Password Erase

1. Boot the LiveCD, and mount your root (/) partition. For example:

mkdir /mnt/arch
mount /dev/sda2 /mnt/arch

2. Edit the password file with your editor. Example vim:

vim /mnt/arch/etc/shadow

3. Delete the second field on the root line (in vim this can be done by going to the first letter/symbol in the field and typing d/:/ then Enter):


4. Save the file (:x in vim).

5. Reboot and root login will not require a password.

Using GRUB to Invoke Bash

1. Select the appropriate boot entry in the GRUB menu and press e to edit the line.

2. Select the kernel line and press e again to edit it.

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

4. Press b to boot (this change is only temporary and will not be saved to your menu.lst). After booting you will be at the bash 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 create a new root password.

7. Reboot and do not lose your password again!

Note: Some keyboards may not be loaded properly by the init system with this method and you will not be able to type anything at the bash prompt. If this is the case, you will have to use another method.