https://www.maketecheasier.com/reset-root-password-linux
In Linux, regular users and superusers are allowed to access services via password authentication. In the case a regular user can’t remember his/her password, a superuser can reset the password of a regular user right from the terminal. However, what if the superuser (or root user) loses his/her password?
To recover the lost password of a superuser (or root user), it is done quite differently. Nonetheless, this method of recovering a lost password allows any malicious user with physical access to your Linux host to gain complete ownership.
In this article we will look at how to recover a lost root password in Linux two different ways.
2 . Once the GRUB page appears, quickly select the “*Advanced options for GNU/Linux” option by pressing the down arrow key and Enter button.
3. Now press e to edit the commands.
You need to modify it or change it from “read-only” mode to “read-write” mode. Find the line beginning with “Linux.” After, look for “ro,” and change it “rw.” Add
4. Press F10. This will display a screen with a prompt.
5. Mount your root filesystem in read-write mode:
6. You can now reset your lost root password by using the following command:
Alternatively, you can change the password of the super user with the command:
Once you are done, type:
to exit the prompt and reboot the computer.
1. Download the latest version of Ubuntu, and create a bootable Live CD/USB from it. Boot your system from it.
2. On the display screen select “Try Ubuntu.” This will bring you to the Live CD desktop.
3. Open the terminal, and type the following command to become root:
4. Next, we need to find out the location of the hard disk partition. Use the following command:
In most cases it will be “/dev/sda1,” though it can differ depending on how your hard disk is partitioned.
5. Mount the hard disk partition of the system to be recovered using the following command:
6. At this point we need to jail ourselves in the “mnt/recovery” directory. What this means is that we are pretending to be on the regular Linux filesystem. This is simply known as chrooting.
7. Use the following command to reset your root password:
or us:
to reset the password of a superuser.
8. Once completed, exit from the chroot shell:
9. Unmount the root partition:
and exit your root:
10. Lastly, remove the Live CD and reboot into your Linux system.
In Linux, regular users and superusers are allowed to access services via password authentication. In the case a regular user can’t remember his/her password, a superuser can reset the password of a regular user right from the terminal. However, what if the superuser (or root user) loses his/her password?
To recover the lost password of a superuser (or root user), it is done quite differently. Nonetheless, this method of recovering a lost password allows any malicious user with physical access to your Linux host to gain complete ownership.
Note:
the method of resetting a root password is similar for most distros. In
this article we are using Ubuntu. Also, we will be using “root
password” throughout the tutorial, but it can refer to a superuser’s
password, too.</>
1. Reset Lost Root Password from the Grub Menu
1. First and foremost, to recover a lost root password, we need to restart the Linux host, assuming you can’t remember the password for root (or superuser).2 . Once the GRUB page appears, quickly select the “*Advanced options for GNU/Linux” option by pressing the down arrow key and Enter button.
3. Now press e to edit the commands.
You need to modify it or change it from “read-only” mode to “read-write” mode. Find the line beginning with “Linux.” After, look for “ro,” and change it “rw.” Add
init=/bin/bash
at the end of the line.4. Press F10. This will display a screen with a prompt.
5. Mount your root filesystem in read-write mode:
mount -n -o remount,rw /
passwd root
passwd username
Once you are done, type:
exec /sbin/init
2. Reset Lost Root Password Using Live CD
If you have a Linux Live CD (or USB), then you can boot into it and use it to reset the root password, too. In our example we will use a Ubuntu Live CD.1. Download the latest version of Ubuntu, and create a bootable Live CD/USB from it. Boot your system from it.
2. On the display screen select “Try Ubuntu.” This will bring you to the Live CD desktop.
3. Open the terminal, and type the following command to become root:
sudo su
fdisk -l
5. Mount the hard disk partition of the system to be recovered using the following command:
mkdir /mnt/recover mount /dev/sda1 /mnt/recover
6. At this point we need to jail ourselves in the “mnt/recovery” directory. What this means is that we are pretending to be on the regular Linux filesystem. This is simply known as chrooting.
chroot /mnt/recover
passwd root
passwd username
8. Once completed, exit from the chroot shell:
exit
umount /mnt/recover
exit
No comments:
Post a Comment