OnWorks Linux and Windows Online WorkStations

Logo

Free Hosting Online for WorkStations

< Previous | Contents | Next >

Viewing Processes

The most commonly used command to view processes (there are several) is ps. The ps

program has a lot of options, but in its simplest form it is used like this:



[me@linuxbox ~]$ ps

PID TTY TIME CMD

5198 pts/1 00:00:00 bash

10129 pts/1 00:00:00 ps

[me@linuxbox ~]$ ps

PID TTY TIME CMD

5198 pts/1 00:00:00 bash

10129 pts/1 00:00:00 ps


The result in this example lists two processes, process 5198 and process 10129, which are bash and ps respectively. As we can see, by default, ps doesn't show us very much, just the processes associated with the current terminal session. To see more, we need to add some options, but before we do that, let's look at the other fields produced by ps. TTY is short for “Teletype,” and refers to the controlling terminal for the process. Unix is show- ing its age here. The TIME field is the amount of CPU time consumed by the process. As we can see, neither process makes the computer work very hard.

If we add an option, we can get a bigger picture of what the system is doing:


image

[me@linuxbox ~]$ ps x


PID

TTY

STAT

TIME

COMMAND

2799

?

Ssl

0:00

/usr/libexec/bonobo-activation-server –ac

2820

?

Sl

0:01

/usr/libexec/evolution-data-server-1.10 --

15647

?

Ss

0:00

/bin/sh /usr/bin/startkde

15751

?

Ss

0:00

/usr/bin/ssh-agent /usr/bin/dbus-launch --

15754

?

S

0:00

/usr/bin/dbus-launch --exit-with-session

15755

?

Ss

0:01

/bin/dbus-daemon --fork --print-pid 4 –pr

15774

?

Ss

0:02

/usr/bin/gpg-agent -s –daemon

15793

?

S

0:00

start_kdeinit --new-startup +kcminit_start

15794

?

Ss

0:00

kdeinit Running...

15797

?

S

0:00

dcopserver –nosid



and many more...


Adding the “x” option (note that there is no leading dash) tells ps to show all of our pro- cesses regardless of what terminal (if any) they are controlled by. The presence of a “?” in the TTY column indicates no controlling terminal. Using this option, we see a list of ev- ery process that we own.

Since the system is running a lot of processes, ps produces a long list. It is often helpful to pipe the output from ps into less for easier viewing. Some option combinations also produce long lines of output, so maximizing the terminal emulator window may be a good idea, too.

A new column titled STAT has been added to the output. STAT is short for “state” and re- veals the current status of the process:


Table 10-1: Process States


State Meaning

State Meaning

R Running. This means that the process is running or ready to run.


image

S Sleeping. The process is not running; rather, it is waiting for an event, such as a keystroke or network packet.


image

D Uninterruptible Sleep. Process is waiting for I/O such as a disk drive.


image

T Stopped. Process has been instructed to stop. More on this later.


image

Z A defunct or “zombie” process. This is a child process that has terminated, but has not been cleaned up by its parent.


image

< A high priority process. It's possible to grant more importance to a process, giving it more time on the CPU. This property of a process is called niceness. A process with high priority is said to be less nice because it's taking more of the CPU's time, which leaves less for everybody else.


image

N A low priority process. A process with low priority (a “nice” process) will only get processor time after other processes with higher priority have been serviced.


image


The process state may be followed by other characters. These indicate various exotic process characteristics. See the ps man page for more detail.

Another popular set of options is “aux” (without a leading dash). This gives us even more information:



image

[me@linuxbox ~]$ ps aux


USER

PID

%CPU

%MEM

VSZ

RSS

TTY

STAT

START

TIME

COMMAND

root

1

0.0

0.0

2136

644

?

Ss

Mar05

0:31

init

root

2

0.0

0.0

0

0

?

S<

Mar05

0:00

[kt]

root

3

0.0

0.0

0

0

?

S<

Mar05

0:00

[mi]

root

4

0.0

0.0

0

0

?

S<

Mar05

0:00

[ks]

root

5

0.0

0.0

0

0

?

S<

Mar05

0:06

[wa]

root

6

0.0

0.0

0

0

?

S<

Mar05

0:36

[ev]

root

7

0.0

0.0

0

0

?

S<

Mar05

0:00

[kh]



and many more...


This set of options displays the processes belonging to every user. Using the options without the leading dash invokes the command with “BSD style” behavior. The Linux version of ps can emulate the behavior of the ps program found in several different Unix implementations. With these options, we get these additional columns:


Table 10-2: BSD Style ps Column Headers


Header Meaning

Header Meaning

USER User ID. This is the owner of the process.


image

%CPU CPU usage in percent.


image

%MEM Memory usage in percent.


image

VSZ Virtual memory size.


image

RSS Resident Set Size. The amount of physical memory (RAM) the process is using in kilobytes.


image

START Time when the process started. For values over 24 hours, a date is used.


image


 

Top OS Cloud Computing at OnWorks: