
How to reset password in Linux
- Transfer

Let's look at several ways to reset a system password on Linux. You probably know that the root user has rights to change the password of any user in the system. But what if you forgot the root password? This is what will be discussed in the article.
When recovering a password (root or any other user), two different situations occur that require a different approach.
When to use GRUB
If you have the GRUB bootloader installed and have access to edit the parameters for loading the selected line, then the task becomes very simple. Follow the further recommendations and get root rights as soon as possible. And as soon as you become a root, you can immediately do anything.
- In the GRUB bootloader window, select the line with the desired version of Linux for which you need to reset the password
- Press 'e' to edit. Select the kernel line. Add 'single' to the end of the line. Press 'b' to download. If the system continues to request the root password, add init = / bin / bash to the end of the line. Press 'b' again to boot


- After that, you will either see a prompt for the root, or a recovery menu where you need to select a line with the root. Use passwd <username> to change the password for any user
- Run the reboot command to reboot the system and then log in with a new password
It should also be noted that some distributions create a recovery mode during installation. If your GRUB menu has such an item, you do not need to perform all of the above actions, just select the recovery mode, and then the prompt for root in the subsequent dialog box.
When it is not possible to use GRUB
If you do not use GRUB for some reason, you can recover the password using the live CD (I will use the Ubuntu live CD, you can take any other). Just follow the instructions below:
- Boot from live CD
- Select “Try Ubuntu without any changes to your computer”
- When the system is ready, launch a terminal window and get ready to perform some actions on the command line
- Type sudo fdisk -l in the terminal window . As a result, we find out in which partition of the disk Linux is installed and the name of the hard drive itself, in the presented example, the partition we need is called / dev / sda1 . If you know the exact section you need, you can skip this step.
- Next, we need to mount the Linux partition. To do this, create a folder as a mount point using the command: sudo mkdir / media / linx_part
- Mount the Linux partition with the command sudo mount / dev / sda1 / media / linx_part
- Change the root in the mounted partition - sudo chroot / media / sda1
- Use passwd to change the current password to a new one
- Reboot the system using the reboot command
Perhaps you have your own password recovery methods? Share them.