jueves, 10 de octubre de 2019

How to Reset the Root Password in Linux Ubuntu

https://www.maketecheasier.com/reset-root-password-linux/


How to Reset the Root Password in Linux


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.
grub-advanced-options
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.
grub-edit-kernel-loading-menu
4. Press F10. This will display a screen with a prompt.
grub-boot-bash-screen
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:
grub-bash-screen-reset-password
Once you are done, type:
to exit the prompt and reboot the computer.

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.
ubuntu-live-cd-try-ubuntu
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:
ubuntu-livecd-mount-partition
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.

Conclusion

Changing the root password in Linux is easy, though it requires you to venture into the dark realm of the command line. Do note that anyone who has access to your computer can use this method to reset your superuser or root password. One precaution you can take is to encrypt the whole hard disk so it can’t be booted or mounted so easily.

No hay comentarios:

Publicar un comentario