It's not uncommon for users to forget their root password. This happens especially when you stay for prolonged periods without using logging in or switching to root user. In case you have forgotten your root password, fret not. You can reset it in a few simple steps.
Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to perform related Linux system Management queries.
In this context, we shall look into how you can reset a forgotten root password in Debian 10 or 11.
Once you have accessed the single-user shell, mount the root filesystem with read and write access with the below attribute:
# mount -o remount,rw /
Therefore, reset the root password by typing the command:
# passwd
Enter your preferred root password and confirm. While at it, ensure that you provide a strong root password to avoid easily falling victim of bruteforce or dictionary attacks.
To effect the changes, exit the single-user mode and reboot by typing CTRL + ALT + DEL on the keyboard.
NOTE: The fact that you can change the root user password implies that someone else who might have physical access to your PC or server can do the same and compromise your system. To prevent this, you can enable a BIOS password or alternatively, encrypt your filesystem with a password so that no one else can access the system without the password.
This article covers how to reset your root password in Debian 11 Linux system. In fact, you can now use the newly created password to log in or switch to your root user account.