fbpx
Skip to content

How to reset root password in Linux

Sometimes, it happens that you may forget or lose your root from your dedicated server or virtual server. You can solve this problem by reinstalling the system, but in this case you lose all your important data, so it is better to go for the tried and tested and working method of resetting your root password in your linux operating system.

Resetting the root password in Ubuntu

  1. Reboot the computer and go to the boot menu (grub).
  2. Select recovery mode and press Enter.
  3. Wait for the system to boot into recovery mode.
  4. Select the root shell option.
  5. Run the mount -o rw,remount / command to mount the root partition in read/write mode.
  6. Run the passwd root command to change the root password.
  7. Reboot the computer and log in with the new root password.

Resetting CentOS root password

  1. Reboot the computer and go to the boot menu (grub).
  2. Select rescue mode and press Enter.
  3. Wait for the system to boot into recovery mode.
  4. Select the root shell option.
  5. Run the chroot /mnt/sysimage command to mount the root file system.
  6. Run the passwd root command to change the root password.
  7. Reboot the computer and log in with the new root password.

Resetting the root password in Arch

  1. Reboot the computer and go to the boot menu (grub).
  2. Select Arch Linux and press “e” to edit the boot parameters.
  3. Add the parameter init=/bin/bash to the end of the line beginning with linux.
  4. Press Ctrl-X to boot into the root shell system.
  5. Run the mount -o remount,rw / command to mount the root partition in read/write mode.
  6. Run the passwd root command to change the root password.
  7. Reboot the computer and log in with the new root password.

These are the basic steps to reset the root password on different operating systems. Please note that following these steps may cause data loss or system malfunction. Be careful and make sure you follow the instructions correctly.