Wednesday, February 10, 2010

Ubuntu/Mint: Restoring My Password

 A couple of weeks ago my office PC (Linux Mint Helena) abruptly decided not to believe my password. There are multiple possible causes for this, including user forgetfulness (not the case here), deletion/corruption of the file containing the authorized passwords (maybe but doubtful in my case), or a malware affliction (which was my best guess, although I never identified the source of the problem). In any event, the immediate concern was to regain access to my PC.

Members of the open source community, both developers and users, are typically very generous in sharing their knowledge. If you are one of the first to encounter a problem, you can pop onto various forums (or maybe IRC channels), post a question, and with reasonable certainty receive help (or attempts at help) within a day or so. I'm not typically the first to encounter any particular problem, though, so for me the mantra is "Google is my friend".

Unfortunately, a number of hurdles stand in your way of finding exactly the right bit of advice. Uncertainty about the terminology to use can be one issue. Variations in operating system, version, configuration etc. can lead to substantial numbers of unhelpful search hits, as can different problems with similar symptoms.

Cutting to the chase scene, I found a number of suggestions online, the seventh of which worked. On the chance that some other poor soul will be desperately googling for a way to restore his/her password, I'll post my results here. These apply to Mint Helena, which is built on Ubuntu Karmic Koala, but my guess is that they apply fairly broadly to Linux distributions using the Grub 2 boot loader.

I'll first note that one source of confusion was the shift from Grub (in earlier versions of Ubuntu/Mint) to Grub 2. If your boot sequence normally gives you a nice looking menu of Linux kernels from which to choose (including a recovery mode), I suspect you're looking at Grub 2. Online postings that refer to rebooting and beating on some unsuspecting key until you get to the Grub menu probably refer to the earlier version of Grub.

In case it's of any use to other people pounding on a search engine, during my attempts to hack into my own machine I repeatedly encountered a message "could not access PID file for nmbd" when in recovery mode.

Stuff that didn't work (all starting from the Grub menu):
  • running dpkg in recovery mode (it updated some things but didn't help with the password problem);
  • updating the boot loader (i.e. Grub itself);
  • selecting the current kernel, using 'c' to get a command prompt, then running 'password ' to reset the password, followed by a reboot; 
  • selecting the kernel, using 'e' to edit the line, changing 'quiet splash' to 'single', then ctrl-X to reboot.
What worked (sorry, I'd like to credit the source but I've lost track of it):
  • In the Grub menu, select the current kernel and type 'e' to edit the line;
  • change 'ro quiet splash' to 'rw init=/bin/bash' and continue the boot sequence;
  • in the root shell that comes up, run 'passwd ' to change the password for the account named (i.e., your account) back to what it should be;
  • cross your fingers (toes too if you're sufficiently dexterous) and reboot.
Something I learned by experience (and which would have lowered my stress level a bit had I known it up front) is that the 'e' option in Grub only edits the boot loader command for this one instance; it does not make permanent changes to the Grub menu.

No comments:

Post a Comment

Due to intermittent spamming, comments are being moderated. If this is your first time commenting on the blog, please read the Ground Rules for Comments. In particular, if you want to ask an operations research-related question not relevant to this post, consider asking it on Operations Research Stack Exchange.