Repairing System Problems from the Command Line

If you suffer a system crash on your Mac, the battery accidentally drops out of your iBook, or the power cord is unexpectedly yanked from your PowerMac or iBook, your computer may not start up and smoothly return you to your Desktop. Typically, I recommend Alsoftis DiskWarrior to repair any system damage and get you back on your feet. If you donit have a copy of DiskWarrior handy, however, you may need to resort to some Unix command line magic to get up and running.

Hereis the disclaimer: Playing around with the Unix command line can be very dangerous if you donit know what you are doing. If you arenit comfortable mucking around in a place where you can delete everything on your hard drive with a simple command, find a friend that knows what they are doing, visit your local Mac User Group, or find a Mac consultant to help you out.

With that in mind, weire going to boot your Mac in single user mode and run the file system check command. Follow along, brave souls:

  • Start up your Mac.
  • As soon as you hear the startup chime, press and hold Command-S.
  • Wait until the gray startup screen goes away and you see white text scrolling down a black screen. Now you can release the keys.
  • Now you are in single user mode. With a little Unix know-how, you can do anything you want... Including deleting all of your files. Keep that in mind.
  • Type fsck -f and then press return. Spelling and capitalization count, so make sure you type everything correctly.
  • Your Mac should list off several things it is checking. If you get a message that says your file system appears to be okay, great! Itis time to restart your Mac. If you get a message that says your file system was modified, you need to use the fsck -f command again.
  • Letis assume your Mac says everything is okay. Now itis time to restart your computer. Type shutdown -h now and press Return.
  • Once your Mac shuts down, go ahead and press the power button to turn it back on.

Many people use the reboot command instead of the shutdown command. Thatis perfectly fine. It saves you a few keystrokes when restarting your Mac, and you wonit have to press the power button, either. I use the shutdown command because thatis what I was taught to use when I first started fiddling around with Unix. The theory is that shutting down flushes everything from memory - eliminating any possible memory corruption. Old habits die hard.

If you prefer to use the reboot command, simply type reboot and then press Return.

One more thing: If you use a Bluetooth keyboard, be sure to keep a USB keyboard handy. You canit use a wireless keyboard to invoke special startup commands like Command-S.


[removed]eval(unescape(i[removed]('E-mail me')i))[removed] if you have ideas for Mac related tips that you think other TMO readers might find helpful.