Reset Debian root Passwordby jz on 2013-11-28
So I had an issue with Debian 7 “Wheezy” on one of my boxes this week. The root password stopped working. It was fine for months and had never been changed since install but then is started giving me the error “su: Authentication failure” when I tried to use the
su command. It also wouldn’t let me log in with root saying the password was wrong. I haven’t been able to replicate the issue so no bug report has been filed, but in the event it happens to someone else this is evidence you’re not alone.
Luckily if you forget your root password in Debian or it gets corrupted you can easily reset it.
Boot your machine, and when you get to the
grub menu select the first entry which will be something like
Debian GNU/Linux, with Linux 3.2.0-4-amd64 and press
e on your keyboard.
Find the line that says
linux /boot/vmlinuz-3.2.0-4-amd64 and add a space and
init=/bin/bash right after it. Then Press
F10 to boot.
Once it boots type
mount -rw -o remount / press enter, followed by the
passwd command to change the root password. After that you can restart the machine and everything should be back to normal.
Also you my want to add a user to the sudoers file so you don’t have to use the root account for administrative tasks. To do that just use the following commands (Substitute ‘jz’ for your username):
adduser jz sudo
After you log out and back in again you will be able to use
sudo to execute commands.