Endpoint Security

Reset Linux OS password from boot/GRUB boot loader

This guide details the steps to reset a forgotten Linux OS password using the GRUB boot loader. It explains how to access the boot loader, modify the boot parameters, and set a new password without requiring previous credentials. This procedure is crucial for system administrators to regain access to locked systems while maintaining endpoint security.

4 min read
Reset Debian and Redhat Based Destro Passwords from GRUB Boot Loader

How to reset Linux OS password from boot/GRUB boot loader

Debian Based System

To reset the password on a Debian or Ubuntu-based system, you need to have access to the system’s console. Here’s the step by step process:

  1. Boot your computer into GRUB boot loader.
  2. Select the boot option for the kernel you want to boot, and press the e key to edit the boot options.
  3. Go to the line that starts with linux, and add init=/bin/bash to the end of that line.
  4. Press Ctrl + X or F10 to boot the system using these modified settings.
  5. The system will boot into a single-user mode with root privileges.
  6. Run the following command to remount the file system as read-write: mount -o remount,rw /
  7. Run the following command to change the password for the user: passwd USERNAME, where USERNAME is the name of the user whose password you want to change.
  8. After you have successfully changed the password, type reboot to restart the system.

This should allow you to reset the password on a Debian or Ubuntu-based system. Note that you need to have physical access to the system’s console to perform these steps.


Redhat Based System

To reset the password on a Red Hat-based system, you need to have access to the system’s console. Here’s the step by step process:

  1. Boot your computer into the GRUB boot loader.
  2. Select the boot option for the kernel you want to boot, and press the e key to edit the boot options.
  3. Go to the line that starts with linux16, and add rd.break to the end of that line.
  4. Press Ctrl + X or F10 to boot the system using these modified settings.
  5. The system will boot into emergency mode, giving you root access to the file system.
  6. Run the following command to mount the file system as read-write: mount -o remount,rw /
  7. Run the following command to change the password for the user: passwd USERNAME, where USERNAME is the name of the user whose password you want to change.
  8. After you have successfully changed the password, type reboot to restart the system.

This should allow you to reset the password on a Red Hat-based system. Note that you need to have physical access to the system’s console to perform these steps.


Tips to Secure Your Linux Password that can’t be changed from grub boot loader

There are several ways to protect a Linux password from being reset through the GRUB boot loader:

  1. Enable Full Disk Encryption: Encrypting the entire disk will protect the password and other sensitive information, as the boot loader and file system will both be encrypted.
  2. Use Secure Boot: Secure Boot is a feature that verifies the digital signatures of boot loaders and other low-level system components, making it more difficult for an attacker to modify the boot process.
  3. Disable Single User Mode: Single user mode is a boot option that allows the system to start up with only a root shell, bypassing normal authentication and authorization procedures. Disabling this option will prevent an attacker from resetting the password in this way.
  4. Use BIOS password protection: Setting a password on the BIOS can prevent an attacker from accessing the boot menu and modifying the boot options.
  5. Enable audit logging: Audit logging tracks changes to system files, including changes to the boot process, which can help you detect unauthorized changes and respond accordingly.
  6. Keep your system up-to-date: Regularly updating your system to apply security patches and upgrades can help protect against known vulnerabilities that could be exploited to reset the password.

These steps can help protect your Linux password from being reset through the GRUB boot loader. However, it’s important to keep in mind that no security measures are foolproof, so it’s always a good idea to have a backup plan in case your password is compromised.

Subscribe to my newsletter

Receive my case study and the latest articles on my WhatsApp Channel.