View All Currently Running Processes


ps aux

Every once in a while a program you're running locks up and stops responding, requiring that you close it. Or you might want to know what programs a certain user is running. Or you might just want to know about the processes currently running on your machine. In any of those cases and many others, you want to use the ps command that lists open processes on your computer.

Unfortunately, ps has many versions, and they have different types of options. They can even have different meanings, depending on whether those options are preceded by a hyphen, so that u and -u mean completely different things. Up to now, this book has been pretty strict about preceding all options with a hyphen, but for ps, it's not, as it makes things a bit easier and more uniform.

To see all the processes that any user is running on your system, follow ps with these options: a (which means all users), u (user-oriented, or show the user who owns each process), and x (processes without controlling ttys, or terminal screens, another way of saying "show every process"). Be forewarned that a fairly long list is going to zoom by on your screen: 132 lines on this computer.

[View full width]

$ ps aux USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND scott 24224 4.1 4.2 1150440 44036 ? R 11:02 12:03 /home/scott/.cxoffice /bin/wine-preloader scott 5594 0.0 0.1 3432 1820 pts/6 S+ 12:14 0:00 ssh scott@humbug. machine.com scott 14957 0.3 7.5 171144 78628 ? Sl 13:01 0:35 /usr/lib/openoffice2 /program/soffice.bin -writer scott 12369 0.0 0.0 0 0 ? Z 15:43 0:00 [wine-preloader] <defunct> scott 14680 0.0 0.1 3860 1044 pts/5 R+ 15:55 0:00 ps aux


The ps command gives you a lot of information, including the user who owns the process, the unique process ID number (PID) that identifies the process, the percentage of the CPU (%CPU) and memory (%MEM) that the process is using, the current status (STAT) of the process, and the name of the process itself.

The STAT column can have different letters in it, with the following being the most important:

STAT Letter

Meaning

R

Running

S

Sleeping

T

Stopped

Z

Zombie


A Z is bad news because it means that the process has basically hung and cannot be stopped (fortunately, it does not mean that it will try to eat your brain). If you're having a problem with a program and ps indicates that it has a status of Z, you're probably going to have to reboot the machine to completely kill it.

Because ps aux provides you with a lot of data, it can be difficult to find the program for which you're searching.

Piping the output of ps aux to grep can be an easy way to limit the results to a particular command.

$ ps aux | grep [f]irefox scott  25205   0.0 0.0      4336      8   ?      S Feb08 0:00 /bin/sh /opt/firefox/firefox scott  25213   1.1 10.9   189092 113272   ?     Rl Feb08 29:42 /opt/firefox/firefox-bin 


Now you know just the instances of Firefox running on this machine, including who's running the program, how much of a load on the machine that program is, and how long that program has been running. Useful!

Tip

Why did you search for [f]irefox instead of firefox? To find the answer, take a look in Chapter 9, "Finding Stuff: Easy," in the "Search the Output of Other Commands for Specific Words" section.




Linux Phrasebook
Linux Phrasebook
ISBN: 0672328380
EAN: 2147483647
Year: 2007
Pages: 288

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net