Instructions to reset password using Single mode on Linux

Estimated reading: 3 minutes 317 views


In this article, We will reset password on Linux using Single mode. Sometimes you can forget your login password on Linux. You can use the following instructions to reset your VPS password

For CentOS

Access the Console screen (VNC), proceed to restart the VPS (depending on the system used, there are different ways to restart)

Step 1 : Reset the operating system and access GRUB mode by pressing any key while the machine is rebooting.

Press the “ e ” key to enter the edit with the following display:

Step 2 : Find the text rhgb quietand edit it to init=/bin/bash.

After finishing editing  ctrl + x , it will start to boot with the specified parameter. And will show  bash prompt .

Step 3: Check the status of the root partition with the following command:

#mount | grep root

Currently, the root partition is visible  ro(read-only). Need to edit read and write permissions on the root partition to change the root password.

#mount -o remount, rw /

Step 4 : Proceed to reset the password for the root user :

#passwd root

Enter the password you want to set for root.

Add command:

#touch /.autorelabel

Reboot the server with the following command:

# exec /sbin/init

Login with new Password to check again.

Wishing you success.

For CentOS Ubuntu/Debian

The implementation is entirely similar for versions of Ubuntu/Debian.

Order of steps

Step 1: Access the Console screen (VNC), proceed to restart the VPS (depending on the system used, there are different ways to restart)

Step 2:  Access the system  Grub boot menu . Usually the system will automatically display the Grub boot menu. If not, try restarting the VM and pressing the Shift key several times.

Grub boot menu interface

Step 3:  On the Grub boot menu select the running Kernel and press the  E key  to edit

Select the correct Kernel in use and press E to edit

Step 4:  Move to line linux /boot/vmlinuz..

Note: The interface and parameters between the Ubuntu versions outlined above may not be exactly the same. But completely similar.

Step 5:  Edit the parameter part  ro ... to rw init=/bin/bash

Change the parameter ro ... to rw init=/bin/bash

Step 6:  Press  Ctrl + X  or press  F10  to enter  Single Mode . Then execute the following commands:

# Change Password
passwd root
# Data synchronization
# Reboot the system
reboot -f
Change password

Step 7:  Login with new password and check

Sign in with your new password

Good luck!


Support 24/24h with coupon code: 1DOLLAROFF 10% discount. Click now! 👆

Leave a Comment