How to Reset the root password on Ubuntu 22.04 if you forget it

To reset the root password on Ubuntu 22.04, you can follow these steps:

  1. Reboot your system and wait for the GRUB menu to appear.
  2. Once the menu appears, select the “Advanced options for Ubuntu” entry and press Enter.
  3. Select the kernel you want to boot and press “e” to edit its boot parameters.
  4. Find the line that starts with “linux” and add the following text to the end of the line: “init=/bin/bash”. This should look like “linux /boot/vmlinuz-5.16.0-rc6 root=/dev/sda1 ro init=/bin/bash”.
  5. Press Ctrl+X or F10 to boot with the modified parameters.
  6. Your system should boot into a root shell with a command prompt. Enter the following command to remount the root filesystem in read-write mode:
mount -o remount,rw /
  1. Now, you can use the following command to change the root password:
passwd root
  1. Follow the prompts to set a new password.
  2. After changing the root password, you should run the following command to restart the system:
reboot -f
  1. Once the system restarts, you should be able to log in as root with your new password.

Note that resetting the root password in this way can be a security risk if someone gains physical access to your system. It is recommended to use other security measures, such as encryption and strong passwords, to protect your data.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top