SUSE Support

Here When You Need Us

How To: Recover the Linux root password

This document (3003803) is provided subject to the disclaimer at the end of this document.

Environment

SUSE Linux Enterprise Server 15
SUSE Linux Enterprise Server 12
SUSE Linux Enterprise Server 11
SUSE Linux Enterprise Server 10
SUSE Linux Enterprise Server 9
SUSE Linux Enterprise Server 8
 

Situation

Lost or forgot the root password on Linux server

Resolution

  1. Boot server from the installation CD.
  2. Then select any installation method or Rescue System.
  3. At the first installation screen when selecting language, press ctrl-alt-f2 to open a virtual console.

    Note: If you selected Rescue System, select your keyboard language and then a Rescue Login prompt should appear. Login as root.

  4. Type
    fdisk -l
    to list the partitions. Locate the Linux root partition.
  5. Type
    mount /dev/sda4 /mnt
    (replace sda4 with the device name for the Linux root partition identified in the previous step or the respective LVM device name).
  6. Run
    mount -o bind /dev /mnt/dev
    to make the device files available (this is needed for access to the urandom device which may be used by the passwd command below).
  7. Enter
    chroot /mnt
  8. Now enter
    passwd root
    and reset the root password.
  9. Type
    exit
    to leave the chroot environment.
  10. Reboot the system.

Additional Information

The command "mount-rootfs-and-do-chroot.sh" has been added to the rescue system of later versions of SUSE Linux Enterprise to ease the process of mounting the root device as well as the proc, sys and dev directories. The script is used as follows below:
 

1.) mount-rootfs-and-do-chroot.sh <rootdevice>, e.g.:
    mount-rootfs-and-do-chroot.sh /dev/sda4 

or in case the root device resides on a LVM device:

    mount-rootfs-and-do-chroot.sh /dev/rootvg/root

2.) mount -a


The mount -a command inside the chroot environment ensures all other filesystems specified in /etc/fstab are mounted as well. 

Disclaimer

This Support Knowledgebase provides a valuable tool for SUSE customers and parties interested in our products and solutions to acquire information, ideas and learn from one another. Materials are provided for informational, personal or non-commercial use within your organization and are presented "AS IS" WITHOUT WARRANTY OF ANY KIND.

  • Document ID:3003803
  • Creation Date: 18-Jan-2007
  • Modified Date:16-Sep-2022
    • SUSE Linux Enterprise Server

< Back to Support Search

For questions or concerns with the SUSE Knowledgebase please contact: tidfeedback[at]suse.com

tick icon

SUSE Support Forums

Get your questions answered by experienced Sys Ops or interact with other SUSE community experts.

tick icon

Support Resources

Learn how to get the most from the technical support you receive with your SUSE Subscription, Premium Support, Academic Program, or Partner Program.

tick icon

Open an Incident

Open an incident with SUSE Technical Support, manage your subscriptions, download patches, or manage user access.