Recovering Root Password

On most Linux systems from the console if you press CTRL-ALT-DEL the command shutdown -r now will be executed and cause a reboot of the system. If your init scripts are setup properly this should result in a safe restart. You could modify your inittab to make CTRL-ALT-DEL do whatever you want including switch into single user mode. Once your are rebooted you can use a livecd, boot to single user mode or whatever you like. You should test in advance if the root password is required to enter single user mode on your system. On some system it is not (Ubuntu/Debian when the root password is disabled) on others it is required.

If your system uses init then /etc/inittab

# What to do when CTRL-ALT-DEL is pressed.
ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now

For systems with upstart then check the file /etc/event.d/control-alt-delete

# control-alt-delete - emergency keypress handling
#
# This task is run whenever the Control-Alt-Delete key combination is
# pressed.  Usually used to shut down the machine.

start on control-alt-delete

exec /sbin/shutdown -r now "Control-Alt-Delete pressed"

Tags:

Linux