Useful Process Related utilities
ps(1) - display process status
pstree(1) - display a tree of processes
top(1) - display the top cpu processes
kill(1) - Send a signal(7) to a process by ProcessID
killall(1) - Send a signal(7) to a process by name
killall5(8) - Send a signal(7) to all running processes
pidof(8) - Tells you the pid(s) of a process by name
fuser(8)? - Tells you which processes are using a resource, and optionally send them a signal(7)
lsof(8) - Similar to fuser
Oi! You were supposed to discuss these utilities too. Like what sets of arguments to ps are the most useful, how to display arguments to commands in top, what is wchan and why is it useful. how nice works, what the various states of a task mean ("S","SW","R","D","<" etc), what RSS is, running time, how this interacts with ulimit(3). what does all the summary information that top displays mean, what other utilities (such as vmstat(8)) are useful for diagnosing problems e tc :P
I'm going to, these things take time ;) -- CraigMckenna
the reason for this is that the latter example will also find the "foo" in the grep command line, where as the first one can't.
if your program says "Segmentation fault" (or similar), then you can retrieve information about the process when it crashed. first type
ulimit -c unlimited
this removes the limit on dumping core files (so it should dump core now), see builtins(1) and ulimit(3) for more information about this. then run the program again. this time when it says "Segmentation fault" it will leave a file called "core" which contains the state of the program when it died. this file can be inspected by gdb programname corefilename. To find out where it crashed try "bt full" at the prompt. you can also print variables to find out what they currently hold, for example "print argc" will tell you the contents of argc. of course, "quit" or C-d will exit gdb. For more information about the gnu debugger see gdb(1).
ps -auxww
is probably the most useful ps(1) command imho
if you want to unmount a filesystem but its in use you can use
ps -auxwwe |grep mountpoint
to locate any processes that are using the filesystem. CraigBox prefers
lsof | grep mountpoint
lsof stands for list of open files.
PerryLorier prefers
fuser -vm mountpoint
4 pages link to ProcessNotes: