It happens more often than anyone admits. You inherit a server from a colleague who left the company. You spin up an old VM you haven’t touched in two years. You buy a second-hand machine with Linux already on it. Or you simply forgot — because you set it up at midnight and never wrote it down.
Whatever the reason, you’re staring at a login prompt and you don’t know the password.
The instinct for many people is to reinstall. Don’t. There’s a much simpler way, and it takes about two minutes.
The same trick applies in another situation that catches a lot of newcomers off guard: on many Linux distributions, the root account isn’t unlocked by default. Ubuntu, for example, doesn’t give root a password at all — you’re expected to use sudo. But if you ever need to get into single-user mode, recover from a broken sudo configuration, or simply reset your own user password without being able to log in, you need another way in.
That way in is GRUB.
By making a small, temporary edit to your boot entry — changing one word and adding one line — you can boot directly into a Bash shell with full root privileges, set a new password, and reboot as if nothing happened. No reinstall. No data loss. No drama.
The full walkthrough is on the forum: Recover your Linux password — GRUB method
Comments