Datasheet

690
UNIX Cadillac Commands
Like top, another handy command for examining process info is ps (short
for process status). Most often, you’ll want to append a few flags to the ps
command to get the information that you desire. For example, try the follow-
ing command:
ps –aux
The man page for ps explains what each flag means. (Read more about using
the man command in the earlier section “Help is on the way!”)
UNIX Cadillac Commands
Besides working with files and processes, the command line has all kinds
of sophisticated commands. For example, with the command line, you have
instant access to a variety of tools for finding files or even stringing together
commands.
Finding files
The command line gives you a number of ways to search for files on your
hard drive. The two most commonly used commands are find and locate.
To use find, specify a starting point for the search followed by the name of
the file or folder that you want to find. For example, to find the Fonts folder
that belongs to your user, enter the command like this:
find ~/ -name “Fonts”
You should see at least one result of the find command.
/Users/markchambers/Library/Fonts
One great feature of the find command is that you can look for a file or
folder in more than one location. Suppose you want to find a file named
MyDocument that you know resides either in your Documents folder or on
your Desktop. For this kind of search, use the find command like this:
find ~/Documents ~/Desktop -name “MyDocument”
In this example, you are telling the find command which folders it should
search when looking for the file named MyDocument.
Using pipes
Nearly all UNIX commands can take on greater abilities by using a construct
called the pipe. A pipe (|) is represented by that funny little vertical line that
shows up when you press Shift+\. The pipe routes data from one command
55_9781118022061-bk08ch01.indd 69055_9781118022061-bk08ch01.indd 690 8/10/11 9:39 AM8/10/11 9:39 AM