Recreate Linux root password

From Thomas-Krenn-Wiki
Jump to navigation Jump to search

If the root password of a Linux system has been forgotten, a new password with different methods can be set. In this article, we explain how to set a new password with these methods.

Method 1: start /bin/bash

A Bash-Shell is immediately started with the following method. We have tested this process with Debian 8:

Method 2: start from a installation medium

Alternatively, you can start the affected computer with an installation medium and boot the rescue system from there.

Information on this can be found here for SLES:

Method 3: start single user mode

The Single User Mode is an opportunity. The system is started in runlevel S[1]. This method functions for older Linux distributions (fWith newer Linux distributions, the current root password must be entered for single-user mode—this method will not work in this case).

A Linux computer with GRUB bootloader is started with the following steps in single user mode:

  1. Select the desired boot entry (this is usually the one that is automatically preselected) in GRUB with the help of the [arrow keys]
  2. Click on [e] to edit the entry
  3. Use [arrow key] to select the kernel line (kernel)
  4. Click on [e] to edit the kernel line
  5. Add the word single on the end of this line (separated by a space before the preceding parameter)
  6. Click on [Esc] to get to the main menu
  7. Click on [e] to boot the changed entry
  8. When starting in single user mode, you are automatically taken to a root shell. A new root password can be set with the passwd command.

Methods für CentOS / RHEL

Information on resetting the root password under CentOS or RHEL can be found in the following article:

References

  1. Runlevel - Beispiel Linux (de.wikipedia.org)


Author: Werner Fischer

Werner Fischer, working in the Knowledge Transfer team at Thomas-Krenn, completed his studies of Computer and Media Security at FH Hagenberg in Austria. He is a regular speaker at many conferences like LinuxTag, OSMC, OSDC, LinuxCon, and author for various IT magazines. In his spare time he enjoys playing the piano and training for a good result at the annual Linz marathon relay.


Translator: Alina Ranzinger

Alina has been working at Thomas-Krenn.AG since 2024. After her training as multilingual business assistant, she got her job as assistant of the Product Management and is responsible for the translation of texts and for the organisation of the department.


Related articles

Archive under Linux (tar, gz, bz2, zip)
DRBD information
SSD firmware update with storcli