How to Reset your linux Password

It happens that the password of the system administrator is forgotten or the person who knows it is not available. It is possible to reset it if there is physical access to the server/computer or at least IP-KVM console.

Access to the grub operating system selection menu is required

When grub 2 is installed.

If the operating system selection menu appears when you boot your computer, you need to press the ‘e’ key – we will go into edit mode.You need to find the line that starts with ‘linux /vmlinux ….’. In this line at the end you need to add a space-separated string 'init=/bin/bash' .

This will instruct the kernel to use /bin/bash to initialize the system instead of the /bin/init image. After booting, you must put the root file system in write mode

mount -no remount,rw /

Now, to set a new password, just type the command

passwd username

where instead of username substitute the name of the desired user even ‘root’ superuser, and then


to restart the computer, or you can even type

exec /bin/init

to continue booting the OS as if nothing had happened.

When the GRUB operating system selection menu is not available.

If you have for one reason or another disabled the choice of operating systems at boot, the password can be reset using any LiveCD with Linux. To do this, you need to boot from the LiveCD, connect your root partition, and then set an empty password to the user by editing the /etc/shadow and /etc/shadow files – on this section, as described here. You can now reboot into your system and log in with an empty password.

Most importantly do not forget to write down in a secure location the new password to not to resort again to this procedure

Was this article helpful?

Related Articles

Leave A Comment?