Mac essentials: Terminal, shutting down
Every Mac user should know how—and when—to turn to the Terminal. And he or she should also know how to shut down a truly recalcitrant app or a stubbornly frozen Mac.
Five Useful Terminal Commands
To be honest, many of the things you can do with Unix commands on the Terminal command line—such as copying or moving files, maneuvering through folders, or examining or killing the processes that are currently running—can be accomplished more easily in the OS X graphical user interface. But there are some command-line utilities that are genuinely useful, even if you aren't a Unix geek. Here are five of them; to find out more about using them, type
man lsof) from the Terminal command line:
lsof lists all open files and the processes that opened them. This is useful for troubleshooting, particularly when OS X tells you it can't do something because a file is in use; lsof will tell you which process is using the file, so you can shut it down.
open will open almost anything: a file (in its default application or any other you name); a folder; a URL (
open http://apod.nasa.gov); a screen-sharing session (
open vnc://184.108.40.206); a dictionary lookup (
open dict://inhibit will look up the word "inhibit" in Mac OS X's Dictionary); and more.
pbpaste let you copy and paste between the Terminal command line and the OS X Clipboard. So for example, if you were troubleshooting your system and wanted to send the output of that lsof command to someone by e-mail, you could type
lsof | pbcopy at the Terminal command line and then go to Mail and press Command-V in a message to paste in the output.
rm removes files. It's useful for deleting a bunch of files or folders at once. This one can be dangerous if you aren't careful; consider using
rm -i, which forces you to confirm each deletion. And hit up
man rm before you try it out.
Four Ways to Force-Quit
If the spinning pinwheel just won't go away, it's time to force-quit. Here are four ways to do so.
- Press Command-Option-Escape (Apple -> Force Quit), select the app, and click Force Quit.
- Control-Option-click on the Dock icon; choose Force Quit.
- Open Activity Monitor, find the app, and click on Quit Process; confirm by clicking Quit.
- In Terminal, type
appnameand press Return. If that doesn't work, try
PIDis the process ID (look in Activity Monitor).
Shut Down a Frozen Mac
If OS X freezes so hard that even the mouse and keyboard become unresponsive, press and hold your Mac's power button for at least five seconds. (Don't release too soon; depending on your Energy Saver preferences, a press-and-release might just put your Mac to sleep.) This will shut down your Mac completely; you can then press the power button again to turn it back on.—Joe Kissell
Senior Contributor Joe Kissell is the senior editor of TidBits and the author of Mac Security Bible (Wiley, 2010).