Note: Mac OS X and Linux users have robust command line interfaces baked right into their systems. To get to them, head to Applications->Utilities->Terminal in Finder. It varies in Linux, depending on your distro and interface, but a “terminal” can usually be found in an “Accessories” or “Utilities” menu panel. Windows users are best served by installing and configuring Cygwin, a Unix emulator, which we’ve detailed in a three part series.
10. Customise your prompt
9. Force an action with
sudo !! (“bang bang”)
8. Create whole directory trees with
When it comes to organizing music, pictures, documents, or other media, nested folders become a necessary annoyance—as in right-clicking, choosing “New Folder” and then naming and clicking through each of “The Beatles->White Album->Disc 1.” It’s far easier from the terminal, as the Codejacked blog points out:
mkdir The Beatles\White Album\Disc 1
Some terminal users have to add a \ before spaces, but you get the idea. If you’re a Vista user who’s just not down with Cygwin, you can still pull this off with the md tool in command line.
7. Filter huge lists with
Some terminal commands spit back a bit too much information, and that’s where
grep comes in. Need to manually kill a faltering Thunderbird? Punch in
ps aux | grep bird, and you’ll get back the specific number to
kill. Need to know which files don’t have your company name in them?
grep -v DataCorp *.doc. Programmer Eric Wendelin explains
grep more in-depth.
6. RTFM with
man (and more)
5. Manage processes with
Most systems have a tool to view “tasks” or “running programs,” but they usually hide the true guts of what your system’s doing from you. The Hackszine blog points out that Mac and Linux users can harness the power of the built-in
top command to track and kill runaway processes making your system unstable. There’s also
ps -aux for a single-screen, non-updating look at what’s bugging your computer.
wget for powerful file-grabbing
3. Get way beyond system searching with
Once again, programmer Eric Wendelin offers real-world examples of how powerful a command line tool like
find can be in, well, finding files and directories that match the smallest criteria you can imagine. Want a list of every HTML file that references the hexidecimal colour #FF0000 (red)?
find can totally do that for you. As Wendelin points out,
find, by itself, is about as convenient and powerful as a total-system searcher like Google Desktop or Quicksilver, but piped into and out of other tools like
grep, it’s a powerhouse. For a more pared-down look at some of
find‘s powers, check out this tutorial at Debian/Ubuntu Tips & Tricks.
2. Set up powerful backups with
1. See your most-used commands with
history, make aliases
It will return a ranked list of your most commonly-entered commands using your command
history—and you can start creating aliases to shorten them and make them easy to remember. Or you could search through your recently-used commands with as-you-type results for quick-fire repeats.
While these 10 commands are generic and applicable on all systems with a Unix-like terminal, Mac OS X offers a few Mac-specific tools. Here are useful command line tricks for Mac users.
We’re love to have some CLI fun around here, and we know our savvier readers have tons of cool terminal hacks and tricks that are new to us. So, please—share the knowledge and spread the wealth in the comments.