Saturday, June 21, 2008

Linux Recovery Single User Mode

I recently found myself not knowing the root password on a Linux server I have in my house (it is temporarily relocated until a new hosting location is ready).

I had tried very successfully to forget all of my years of mucking with Linux servers, so it took me a bit to remember how to pull off resetting the root password. I'm throwing it on here in case I forget again in the future.

Since I had local keyboard and monitor access, this was really rather trivial. This was an older server still running Slackware. Slackware was the distro I first learned Linux with, and where I really polished my Linux skills. That said, I'll never use it again. I'm just not interested in the mucking any longer, Ubuntu server is the way to go for me.

Since this was an older Slackware box, it was still using Lilo. So, I stopped the boot process at the Lilo prompt by holding shift. I then used the following command line:
linux rw 1 init=/bin/sh

Now to explain a bit. "linux" was the name of my kernel image, "rw" says that I want to mount the root filesystem read/write, "1" is how I signal to drop to runlevel 1. All of that would be sufficient for simple troubleshooting. However, I needed to startup as root in order to reset the root password. Setting init to /bin/sh takes care of that nicely.

No comments: