Commands fall into two categories: Some commands are built into the shell you are using (for example, the cd command), while most are separate programs.
To see a list of basic Unix commands:
 user-vc8f9gd:~ vanilla$  ls /bin  [           df                 launchctl       pwd      tcsh bash        domainname         link            rcp      test cat         echo               ln              rm       unlink chmod       ed                 ls              rmdir    wait4path cp          expr               mkdir           sh       zsh csh         hostname           mv              sleep    zsh-4.2.3 date        kill               pax             stty dd          ksh                ps              sync user-vc8f9gd:~ vanilla$   
 Tip 
Other places that contain Unix commands are /usr/bin , /sbin , and /usr/sbin . (The bin is short for binary , as most Unix commands are binary files. Not all commands are binary files; some are executable text files, or scripts .)
Every time you issue a command that is not already built into a shell, you are starting what Unix calls a process or a job . You will encounter both terms in Unix literature.
Every process is assigned an identification number when it starts up, called the PID (for process ID ), as well as its own slice of memory space (this is one of the reasons why Unix is so stableeach process has its own inviolable memory space). At any given moment, there are dozens of processes running on your computer.
To see all the processes you own:
 user-vc8f9gd:~ vanilla$  ps -U vanilla  PID         TT        STAT     TIME    COMMAND  104        ??        Ss       0:04.54 /System/Library/Frameworks/ApplicationServices.framew  394        ??        Ss       0:04.05 /System/Library/CoreServices/loginwindow.app/Contents  404        ??        S        0:06.27 /System/Library/CoreServices/RemoteManagement/ARDAgen  934        ??        Ss       0:00.75 /System/Library/CoreServices/pbs  939        ??        S        0:01.90 /System/Library/CoreServices/Dock.app/Contents/MacOS/  941        ??        S        0:10.61 /System/Library/CoreServices/SystemUIServer.app/Conte  942        ??        S        0:21.78 /System/Library/CoreServices/Finder.app/Contents/MacO  945        ??        S        1:13.69 /Applications/Utilities/Terminal.app/Contents/MacOS/T 2302        ??        R        0:05.97 /Applications/iTunes.app/Contents/MacOS/iTunes -psn_0 2303        ??        Ss       0:07.00 /Applications/Firefox.app/Contents/MacOS/firefox-bin 2305        ??        SNs      0:00.63 /System/Library/Frameworks/CoreServices.framework/Ver 2307        ??        S        0:00.92 /System/Library/CoreServices/System Events.app/Conten 2309        ??        S        0:00.08 /Applications/iTunes.app/Contents/Resources/iTunesHel  949        p1        S        0:00.19 -bash 2282        p2        S+       0:00.03 -bash user-vc8f9gd:~ vanilla$  To see all the processes on the system:
|     1.     |      ps -aux    Figure 2.28 shows typical output from using the -aux options to ps (for processes ). Figure 2.28. Using the -aux options to ps gives you this typical output. user-vc8f9gd:~ vanilla$  ps -aux  USER      PID     %CPU    %MEM   VSZ    RS     STT   STAT    STARTED    TIME      COMMAND nobody    405     5.0    0.2    61748   1600  ??      R      Thu11AM    3:28.91   /System/Li vanilla   945     1.3    3.3   123960  21452  ??      S      Sat09AM    1:16.86   /Applicati windowse  396     1.0    3.2   112992  20716  ??      Ss     Thu11AM    1:50.25   /System/Li vanilla  2303     0.4    4.7   281760  30512  ??      Ss      5:46PM    0:12.13   /Applicati vanilla  2302     0.3    5.0   121472  33012  ??      S       5:46PM    0:06.91   /Applicati root       54     0.0    0.2    27768   1088  ??      Ss     Wed10PM    0:00.94   /usr/sbin/ root       81     0.0    0.0    27212    192  ??      Ss     Wed10PM    0:00.00   /usr/libex root       96     0.0    0.8    54792   5104  ??      Ss     Wed10PM    0:30.57   /System/Li vanilla   104     0.0    0.6   179148   3908  ??      Ss     Wed10PM    0:04.56   /System/Li root      105     0.0    0.2    27360   1604  ??      Ss     Wed10PM    0:00.03   xinetd -do root      134     0.0    0.0    29268    176  ??      Ss     Wed10PM    0:00.00   nfsiod -n root      148     0.0    0.7    37864   4912  ??      Ss     Wed10PM    0:22.84   /usr/sbin/ root      154     0.0    0.0    27268    184  ??      Ss     Wed10PM    0:00.00   rpc.lockd root      158     0.0    0.1    27468    360  ??      Ss     Wed10PM    0:33.01   ntpd -f /v root      174     0.0    0.2    29368    988  ??      Ss     Wed10PM    0:00.05   /usr/sbin/ root      179     0.0    0.2    28472   1500  ??      Ss     Wed10PM    0:01.55   /usr/sbin/ root      314     0.0    0.2    29216   1216  ??      Ss     Thu11AM    0:15.23   /usr/sbin/ vanilla   394     0.0    0.6    74868   3792  ??      Ss     Thu11AM    0:04.07   /System/Li vanilla   939     0.0    2.2    98924  14100  ??      S      Sat09AM    0:01.91   /System/Li root      947     0.0    0.2    27420   1620  p1      Ss     Sat09AM    0:00.04   login -pf vanilla   949     0.0    0.1    27772    852  p1      S      Sat09AM    0:00.22   -bash root     2280     0.0    0.3    27420   1668  p2      Ss      5:33PM    0:00.04   login -pf vanilla  2282     0.0    0.1    27772    832  p2      S+      5:33PM    0:00.03   -bash vanilla  2307     0.0    1.5    82732   9744  ??      S       5:47PM    0:00.93   /System/Li vanilla  2309     0.0    0.9    44832   5692  ??      S       5:47PM    0:00.12   /Applicati root      247     0.0    0.0        0      0  ??      Z      31Dec69    0:00.00   (LAServer) root     2317     0.0    0.1    27248    388  p1      R+      5:53PM    0:00.01   ps -aux root        1     0.0    0.1    28300    524  ??      S<s    Wed10PM    0:01.44   /sbin/laun root       25     0.0    0.0    27224    160  ??      Ss     Wed10PM    0:00.00   /sbin/dyna root       29     0.0    0.1    28176    936  ??      Ss     Wed10PM    0:03.01   kextd user-vc8f9gd:~ vanilla$   |  ||||||||||||
|     2.     |      ps -auxw    Figure 2.29 shows output when using the -auxw options. The w makes the output wider (wide enough that the lines will wrap around in the Terminal window). Figure 2.29. Using the -auxw options to ps gives you this partial output; adding the w gives you a wider output. [View full width]   user-vc8f9gd:~ vanilla$ ps -auxw USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND vanilla 945 8.3 4.1 130136 27092 ?? S Sat09AM 1:23.99 /Applications/Utilities/Terminal.app/Contents/MacOS/Terminal - root 2327 1.4 0.1 27248 388 p1 R+ 5:59PM 0:00.01 ps -auxw windowse 396 1.2 3.5 116484 23252 ?? Us Thu11AM 1:55.65 /System/Library/Frameworks/ApplicationServices.framework/Frame vanilla 942 0.8 3.4 108676 21964 ?? S Sat09AM 0:21.99 /System/Library/CoreServices/Finder.app/Contents/MacOS/Finder vanilla 949 0.5 0.1 27772 860 p1 S Sat09AM 0:00.26 -bash vanilla 2303 0.3 4.7 282832 30792 ?? Ss 5:46PM 0:28.74 /Applications/Firefox.app/Contents/MacOS/firefox-bin -psn_0_19 vanilla 2302 0.1 5.0 121472 32876 ?? S 5:46PM 0:08.04 /Applications/iTunes.app/Contents/MacOS/iTunes -psn_0_2228225 root 56 0.0 0.2 28772 1460 ?? Ss Wed10PM 0:01.69 /usr/sbin/securityd root 57 0.0 0.1 27824 436 ?? Ss Wed10PM 0:03.79 /usr/sbin/notifyd root 58 0.0 0.3 31008 2036 ?? Ss Wed10PM 0:03.07 /usr/sbin Table 2.2 shows the common options for the ps command. Use man ps for the complete list. Table 2.2. Common Options for ps
  |  
 
 Tips 
You can use two w 's to make the output even widerfor example, ps -auxww . In fact, using two w 's whenever you use the ps command can be considered a "best practice."
Combine the -U option with the -aux options to show a particular user's processes: ps -aux -U username .
To see a constantly updated list of the top processes:
|     1.     |      top    The top command displays a frequently updated list of processes, sorted by how much processing power each one is usingthat is, which one is at the top of the list of resource usage ( Figure 2.30 ). (The reason they're at 0% is that most processes, at any given time, aren't using that much processor time.) Figure 2.30. The top command displays a frequently updated list of processes, sorted by how much processing power each one is using.  top runs until you stop it by typing the following command:  |  
|     2.     |      q    This stops the top command and returns you to a shell prompt.  |  
 
 Tip 
If you want to save the output of top to a file (such as using the > redirect operator), then use the -l switch and specify how many samples you want. For example, to get three samples, use
top -l3 > toplog
 The Danger of a Space MisplacedA bug in the installation software for an early version of iTunes could cause the erasure of an entire hard drive if the first character in the drive's name was a space. The installation script did not allow for that possibility and neglected to use quotes where it should have. Even professional programmers occasionally have trouble dealing with spaces in filenames on Unix systems.  |