How To Reset Password Linux – Root Password Recovery Steps

Stuck on a forgotten Linux password? A live USB boot gives you direct access to the system files needed to change it. Knowing how to reset password linux is a critical skill for any user, whether you are a beginner or a seasoned administrator. This guide walks you through several reliable methods to regain access to your system without reinstalling the operating system.

Forgetting your password can feel like a dead end, but Linux offers multiple recovery paths. The most common approach involves booting from a live USB, mounting your hard drive, and editing key system files. This method works on almost all distributions, including Ubuntu, Fedora, and Debian.

Before we start, you need a second computer to create a live USB if you do not have one handy. You will also need a few minutes of uninterrupted time. Let us dive into the step-by-step process.

Why You Might Need To Reset A Linux Password

There are several reasons you might find yourself locked out. Maybe you typed a complex password months ago and forgot it. Perhaps a colleague changed it and did not share the new one. Or you inherited a system from someone who left.

Whatever the reason, the solution is straightforward. Linux stores user passwords in a file called /etc/shadow. By accessing this file from a live environment, you can clear or change the password hash. This effectively resets the password to blank or a new one you choose.

Another scenario is when the root password is lost. Many Linux systems use sudo for administrative tasks, but if you need direct root access and cannot get it, the same live USB method applies. The process is nearly identical for both user and root accounts.

How To Reset Password Linux Using A Live USB

This is the most universal and reliable method. It works on any Linux distribution that uses standard file systems like ext4, Btrfs, or XFS. Follow these steps carefully.

Step 1: Create A Live USB

You need a bootable USB drive with a Linux distribution. Ubuntu is a popular choice because it is user-friendly. Download the ISO file from the official website and use a tool like Rufus (Windows) or dd (Linux) to write it to a USB stick.

  • Download the ISO for your preferred distribution.
  • Insert a USB drive with at least 4GB of space.
  • Use Rufus, Etcher, or the dd command to create the bootable drive.
  • Ensure the USB is bootable by checking your BIOS settings.

Step 2: Boot From The Live USB

Restart your computer and enter the boot menu. This is usually done by pressing F12, F2, Esc, or Del during startup. Select the USB drive as the boot device. The system will load the live environment.

Once the desktop appears, do not install anything. You are running the OS from the USB. Open a terminal window. You can usually find it in the applications menu or press Ctrl+Alt+T.

Step 3: Identify Your Hard Drive

In the terminal, type lsblk to list all block devices. Look for your main hard drive. It is often labeled /dev/sda or /dev/nvme0n1. The partitions will be listed below, like /dev/sda1 or /dev/sda2.

You need to find the partition that contains the root filesystem. It is usually the largest partition and might be labeled as / in the mount point column. If you are unsure, check the size and filesystem type.

Step 4: Mount The Root Partition

Create a mount point directory: sudo mkdir /mnt/root. Then mount your root partition. For example, if your root partition is /dev/sda2, type: sudo mount /dev/sda2 /mnt/root.

If you have a separate boot partition, mount that too: sudo mount /dev/sda1 /mnt/root/boot. This is not always necessary, but it ensures everything is accessible.

Step 5: Chroot Into The System

Chroot changes the root directory to your mounted partition. This lets you interact with the system as if you booted normally. Type: sudo chroot /mnt/root. Your terminal prompt will change, indicating you are now inside the installed system.

Step 6: Reset The Password

Now you can change the password for any user. To reset the password for your main user, type: passwd username. Replace “username” with the actual account name. If you do not know the username, type ls /home to see the home directories.

You will be prompted to enter a new password twice. Type it carefully; the characters will not show on screen. Once done, you will see a success message like “password updated successfully”.

Step 7: Exit And Reboot

Type exit to leave the chroot environment. Then unmount the partitions: sudo umount /mnt/root/boot and sudo umount /mnt/root. Finally, reboot with sudo reboot. Remove the USB drive when prompted.

Your system will boot normally. Log in with the new password you just set. This method is safe and does not affect your files or installed applications.

How To Reset Password Linux Using Recovery Mode

Many Linux distributions include a recovery mode in the GRUB bootloader. This is faster than using a live USB, but it requires you to have access to the boot menu at startup.

Step 1: Access GRUB Menu

Restart your computer. As soon as the BIOS screen disappears, press and hold the Shift key (for BIOS systems) or press Esc (for UEFI systems). This brings up the GRUB menu. If you see a list of kernels, you are in the right place.

Step 2: Select Recovery Mode

Look for an entry that says “Advanced options for Ubuntu” or similar. Select it. Then choose a kernel version that includes “(recovery mode)” at the end. Press Enter to boot into recovery mode.

Step 3: Drop To Root Shell

You will see a recovery menu with several options. Choose “Drop to root shell prompt”. This gives you a root terminal without needing a password. The filesystem is mounted as read-only initially.

Step 4: Remount Filesystem As Read-Write

Type: mount -o remount,rw /. This makes the root filesystem writable. Now you can change passwords. Type passwd username and enter a new password twice.

Step 5: Reboot Normally

After the password is updated, type reboot. The system will restart and you can log in with the new password. This method is quick but only works if GRUB is accessible and recovery mode is enabled.

How To Reset Password Linux Using Single User Mode

Single user mode is similar to recovery mode but is often used on servers or minimal installations. It boots into a root shell with minimal services running.

Step 1: Edit GRUB Entry

At the GRUB menu, highlight the normal boot entry and press ‘e’ to edit it. Look for the line that starts with “linux” or “linux16”. This line contains kernel parameters.

Step 2: Add Init Parameter

At the end of that line, add init=/bin/bash. This tells the kernel to start a bash shell instead of the normal init system. Press Ctrl+X or F10 to boot with these changes.

Step 3: Remount Root

The system will boot to a bash prompt. The root filesystem is mounted as read-only. Type: mount -o remount,rw / to make it writable.

Step 4: Reset The Password

Now type passwd username and set a new password. If you want to reset the root password, just type passwd without a username.

Step 5: Reboot

Type exec /sbin/init to restart the normal boot process, or simply press Ctrl+Alt+Del. The system will boot normally with the new password in place.

Common Issues And Troubleshooting

Sometimes the process does not go as planned. Here are a few problems you might encounter and how to fix them.

Filesystem Is Read-Only

If you forget to remount the filesystem as read-write, the password change will fail. Always run mount -o remount,rw / before using passwd. Check the mount output with mount | grep " / " to confirm.

Wrong Partition Mounted

If you mount the wrong partition, you might end up in the live USB’s filesystem. Use lsblk and df -h to verify you are on the correct drive. The root partition usually has a size matching your main disk.

User Account Does Not Exist

If you type passwd for a user that does not exist, you will get an error. List users with cat /etc/passwd or check home directories with ls /home. The username is case-sensitive.

SELinux Or AppArmor Interference

Some systems have additional security modules. If you reset the password but still cannot log in, try booting with selinux=0 or apparmor=0 added to the kernel parameters. This is rare but can happen on hardened distributions.

Preventing Future Lockouts

Once you are back in, take steps to avoid this situation again. Set a password you can remember, or use a password manager. Enable automatic login if security is not a concern for your specific use case.

You can also create a recovery user with sudo privileges. This user can reset passwords for others if needed. Keep a live USB handy for emergencies. Write down the root password and store it securely.

Another tip is to set a password hint. Some Linux desktops support hints during login. This can jog your memory without compromising security too much.

Frequently Asked Questions

Can I Reset A Linux Password Without A Live USB?

Yes, if you have access to GRUB recovery mode or single user mode. These methods do not require an external drive. However, they depend on the bootloader being accessible and not password-protected.

Will Resetting The Password Delete My Files?

No, resetting the password only changes the authentication hash. Your documents, settings, and applications remain untouched. The process is non-destructive.

What If I Cannot Access GRUB At All?

If GRUB is missing or corrupted, you will need a live USB to repair the bootloader first. After that, you can use the recovery mode or the live USB method to reset the password.

Is There A Command To Reset Password From The Terminal?

Yes, the passwd command is the standard tool. You can also use chpasswd to set passwords in batch or from a script. Both require root privileges.

Can I Reset The Password For Another User Remotely?

If you have SSH access with root or sudo privileges, you can run passwd username remotely. This works over a secure shell connection. Without existing access, you need physical or live USB access.

Final Thoughts On Password Recovery

Knowing how to reset password linux is a fundamental skill that saves time and frustration. The live USB method is the most robust and works across all distributions. Recovery mode and single user mode are faster alternatives when available.

Always test your new password before logging out of the recovery environment. If you make a typo, you will have to repeat the process. Double-check the username and the password confirmation.

Linux gives you full control over your system, including the ability to recover from a forgotten password. This flexibility is one of its greatest strengths. With these techniques, you will never be locked out for long.

Keep this guide bookmarked or printed. Share it with colleagues who might need it. A little preparation goes a long way in maintaining access to your systems.