Search This Blog

Saturday, July 4, 2009

Ubuntu Crisis: Recovering From the Unthinkable

In the wee hours of last night I was trying to resolve a particularly tricky issue. So in browsing around I found a poster who sounded like he or she knew what they were doing (and this is after I tried a half dozen other prescriptions to resolve the problem).

So I changed a system file, thinking it was no big deal. The problem I was encountering didn't get resolved so I did what is always a last resort and that is, I restarted the system.

My heart dropped when the system arrived at the login and decided to throw an error message. The system just froze. Sometimes completely shutting down the system and rebooting resolves the issue.

No luck. Disaster. I was locked out of Gnome and therefore locked out of Ubuntu!

But my boot loader is grub (and this may apply to other bootloaders as well) and like a Windows system grub comes up with a number of booting options, the second one on the list being to load in safe mode.

So choosing safe mode then offers another set of menu items, the last (on my system) being to start in Root command line mode.

Before we go too far let's just enumerate how to recover from a crisis.

Step 1.) Whenever changing a protected file or files, write down on a slip of paper what you've changed. Too often, users assume that because an editor remembers the last files changed that the editor will always be there! That becomes a real problem when the system dies and you have no tangible breadcrumbs to return by.

Step 2.) Try rebooting and restarting the machine assuming you don't have hardware issues in play (bad motherboard or snap-in components going bad). Maybe this resolves your issue.

If not continue.

Step 3.) Reboot the machine and when you encounter the grub menu of loading options, load using safe mode. Usually this is one menu item below your normal booting choice.

Step 4.) From the safe mode menu, choose to login using the command line. This is a choice that you must sometimes scroll down to find. Your mouse may not work at times but the directional arrow keys should work otherwise you have problems (generally spaeking) that have nothing to do with Ubuntu per se.

Step 5. ) Login from the command line. In this exercise we're assuming that a lost, forgotten, or corrupted password is not the issue (that's a solution well documented in Ubuntu's help guides). you're be prompted for username and password and then be logged in at the command line (usually in the home directory).

Step 6.) This final step is a software engineering exercise (see my short rant on this at the end of this post). From the command line start up the terminal editor called Nano. You'll want to open the very last file you changed back to its original condition. The command to do so is:

sudo nano /whateverDirectoryThatFileIsIn/whateverSubdirectoryThatFileIsIn/corruptedFileName

For example: sudo nano /etc/uhoh/screwedUpFile

To edit the file, you need to only navigate to the lines that were changed using the arrow keys.

Add previously deleted lines by typing them in the appropriate place. Delete lines by placing the cursor next to the text to be deleted and using the delete key. When you are done fixing the file, hold the control key down while pressing the 'X' key. This will allow you to save the changes.

A nice tutorial on nano is available here.

Step 7.) restart the system in normal mode and hope this resolves the immediate issue of getting back into the Ubuntu and Gnome or KDE environments. If not repeat steps 3 -6 incrementally working backwards correcting changes you made (see rant below).

Captain Obvious Observation: If, in the course of 'fixing' you misspell text, you are still screwed.

If you corrupt the file with bad information, you are still screwed.

Be precise! Nothing else will help.

Software Engineering Rant:

Like a medical doctor, a software engineer must also 'do no harm" but in a different way.

generally speaking, doctors eliminate all or as much of the offending matter as they can to heal a subject. A software engineer approaches the problem incrementally by reverse engineering the very last thing that changed back to an original state.

The system is then retried for stability. If the problem still manifests itself, the software engineer will incrementally reverse-engineer one more unit of change back and so on.

Unlike the human body, computer systems evolve in real-time and have very eccentric possibilities. Fixing a system is very different from healing a human body.

Rant: So why aren't we paid like doctors given the complexity of the task?

Secondly, Joseph Campbell in speaking of the cacophony of dysfunctional religious practice having to do with interpretations of god(s) is quoted as saying (and I'm paraphrasing), "It just goes to show that there's a lot of ways of getting it wrong."

I use the term 'fix' in a very qualified way. There is an ocean or two of working, 'fixed', dysfunctional software out there.

The fact that something 'runs' is no guarantee that it, in fact, works.

The treatment of software professionals in America borders on criminal neglect in pay and in respect! As artificial intelligence solutions flood our lives, citizens should be just as concerned about who wrote their software as about who is their doctor.

It matters.

End of rant.

No comments:

Post a Comment