summaryrefslogtreecommitdiff
path: root/misc/slackbook/html/process-control-ps.html
diff options
context:
space:
mode:
Diffstat (limited to 'misc/slackbook/html/process-control-ps.html')
-rw-r--r--misc/slackbook/html/process-control-ps.html243
1 files changed, 243 insertions, 0 deletions
diff --git a/misc/slackbook/html/process-control-ps.html b/misc/slackbook/html/process-control-ps.html
new file mode 100644
index 00000000..27b84268
--- /dev/null
+++ b/misc/slackbook/html/process-control-ps.html
@@ -0,0 +1,243 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta name="generator" content="HTML Tidy, see www.w3.org" />
+<title>ps</title>
+<meta name="GENERATOR" content="Modular DocBook HTML Stylesheet Version 1.7" />
+<link rel="HOME" title="Slackware Linux Essentials" href="index.html" />
+<link rel="UP" title="Process Control" href="process-control.html" />
+<link rel="PREVIOUS" title="Foregrounding" href="process-control-foregrounding.html" />
+<link rel="NEXT" title="kill" href="process-control-kill.html" />
+<link rel="STYLESHEET" type="text/css" href="docbook.css" />
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
+</head>
+<body class="SECT1" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#840084"
+alink="#0000FF">
+<div class="NAVHEADER">
+<table summary="Header navigation table" width="100%" border="0" cellpadding="0"
+cellspacing="0">
+<tr>
+<th colspan="3" align="center">Slackware Linux Essentials</th>
+</tr>
+
+<tr>
+<td width="10%" align="left" valign="bottom"><a href="process-control-foregrounding.html"
+accesskey="P">Prev</a></td>
+<td width="80%" align="center" valign="bottom">Chapter 11 Process Control</td>
+<td width="10%" align="right" valign="bottom"><a href="process-control-kill.html"
+accesskey="N">Next</a></td>
+</tr>
+</table>
+
+<hr align="LEFT" width="100%" />
+</div>
+
+<div class="SECT1">
+<h1 class="SECT1"><a id="PROCESS-CONTROL-PS" name="PROCESS-CONTROL-PS">11.3 <tt
+class="COMMAND">ps</tt></a></h1>
+
+<p>So now you know how to switch back and forth between several processes that you've
+started from the command line. And you also know that there are lots of processes running
+all the time. So how do you list all of these programs? Well, you make use of the <tt
+class="COMMAND">ps</tt>(1) command. This command has a lot of options, so we'll only
+cover the most important ones here. For a complete listing, see the man page for ps. Man
+pages are covered in-depth in <a href="help.html#HELP-SYSTEM-MAN">Section 2.1.1</a>.</p>
+
+<p>Simply typing <tt class="COMMAND">ps</tt> will get you a listing of the programs
+running on your terminal. This incudes the foreground processes (which include whatever
+shell you are using, and of course, <tt class="COMMAND">ps</tt> itself). Also listed are
+backgrounded processes you may have running. Many times, that will be a very short
+listing:</p>
+
+<div class="FIGURE"><a id="FIG-PROCESS-CONTROL-PS-SHORT"
+name="FIG-PROCESS-CONTROL-PS-SHORT"></a>
+<p><b>Figure 11-1. Basic <tt class="COMMAND">ps</tt> output</b></p>
+
+<table border="0" bgcolor="#E0E0E0" width="100%">
+<tr>
+<td>
+<pre class="SCREEN">
+<samp class="PROMPT">%</samp> <kbd class="USERINPUT">ps</kbd>
+ PID TTY TIME CMD
+ 7923 ttyp0 00:00:00 bash
+ 8059 ttyp0 00:00:00 ps
+</pre>
+</td>
+</tr>
+</table>
+</div>
+
+<p>Even though this is not a lot of processes, the information is very typical. You'll
+get the same columns using regular ps no matter how many processes are running. So what
+does it all mean?</p>
+
+<p>Well, the <var class="LITERAL">PID</var> is the <span class="emphasis"><i
+class="EMPHASIS">process ID</i></span>. All running processes are given a unique
+identifier which ranges between 1 and 32767. Each process is assigned the next free PID.
+When a process quits (or is killed, as you will see in the next section), it gives up its
+PID. When the max PID is reached, the next free one will wrap back around to the lowest
+free one.</p>
+
+<p>The <var class="LITERAL">TTY</var> column indicates which terminal the process is
+running on. Doing a plain <tt class="COMMAND">ps</tt> will only list all the programs
+running on the current terminal, so all the processes give the same information in the
+TTY column. As you can see, both processes listed are running on <tt
+class="FILENAME">ttyp0</tt>. This indicates that they are either running remotely or from
+an X terminal of some variety.</p>
+
+<p>The <var class="LITERAL">TIME</var> column indicated how much CPU time the process has
+been running. This is different from the actual amount of time that a process runs.
+Remember that Linux is a multitasking operating system. There are many processes running
+all the time, and these processes each get a small portion of the processor's time. So,
+the TIME column should show much less time for each process than it actually takes to
+run. If you see more than several minutes in the TIME column, it could mean that
+something is wrong.</p>
+
+<p>Finally, the <var class="LITERAL">CMD</var> column shows what the program actually is.
+It only lists the base name of the program, not any command line options or similar
+information. To get that information, you'll need to use one of the many options to <tt
+class="COMMAND">ps</tt>. We'll discuss that shortly.</p>
+
+<p>You can get a complete listing of the processes running on your system using the right
+combination of options. This will probably result in a long listing of processes
+(fifty-five on my laptop as I write this sentence), so I'll abbreviate the output:</p>
+
+<table border="0" bgcolor="#E0E0E0" width="100%">
+<tr>
+<td>
+<pre class="SCREEN">
+<samp class="PROMPT">%</samp> <kbd class="USERINPUT">ps -ax</kbd>
+ PID TTY STAT TIME COMMAND
+ 1 ? S 0:03 init [3]
+ 2 ? SW 0:13 [kflushd]
+ 3 ? SW 0:14 [kupdate]
+ 4 ? SW 0:00 [kpiod]
+ 5 ? SW 0:17 [kswapd]
+ 11 ? S 0:00 /sbin/kerneld
+ 30 ? SW 0:01 [cardmgr]
+ 50 ? S 0:00 /sbin/rpc.portmap
+ 54 ? S 0:00 /usr/sbin/syslogd
+ 57 ? S 0:00 /usr/sbin/klogd -c 3
+ 59 ? S 0:00 /usr/sbin/inetd
+ 61 ? S 0:04 /usr/local/sbin/sshd
+ 63 ? S 0:00 /usr/sbin/rpc.mountd
+ 65 ? S 0:00 /usr/sbin/rpc.nfsd
+ 67 ? S 0:00 /usr/sbin/crond -l10
+ 69 ? S 0:00 /usr/sbin/atd -b 15 -l 1
+ 77 ? S 0:00 /usr/sbin/apmd
+ 79 ? S 0:01 gpm -m /dev/mouse -t ps2
+ 94 ? S 0:00 /usr/sbin/automount /auto file /etc/auto.misc
+ 106 tty1 S 0:08 -bash
+ 108 tty3 SW 0:00 [agetty]
+ 109 tty4 SW 0:00 [agetty]
+ 110 tty5 SW 0:00 [agetty]
+ 111 tty6 SW 0:00 [agetty]
+ [output cut]
+</pre>
+</td>
+</tr>
+</table>
+
+<p>Most of these processes are started at boot time on most systems. I've made a few
+modifications to my system, so your mileage will most likely vary. However, you will see
+most of these processes on your system too. As you can see, these options display command
+line options to the running processes. Recently, a kernel vulnerability in <tt
+class="COMMAND">ptrace</tt> facilitated a fix which no longer shows command line options
+for many running processes. These are now listed in brackets like PIDs 108 through 110.
+It also brings up a few more columns and some other interesting output.</p>
+
+<p>First, you'll notice that most of these processes are listed as running on tty
+&#8220;?&#8221;. Those are not attached to any particular terminal. This is most common
+with daemons, which are processes which run without attaching to any particular terminal.
+Common daemons are sendmail, BIND, apache, and NFS. They typically listen for some
+request from a client, and return information to it upon request.</p>
+
+<p>Second, there is a new column: <var class="LITERAL">STAT</var>. It shows the status of
+the process. <var class="LITERAL">S</var> stands for sleeping: the process is waiting for
+something to happen. <var class="LITERAL">Z</var> stands for a zombied process. A zombied
+processes is one whose parent has died, leaving the child processes behind. This is not a
+good thing. <var class="LITERAL">D</var> stands for a process that has entered an
+uninterruptible sleep. Often, these processes refuse to die even when passed a SIGKILL.
+You can read more about SIGKILL later in the next section on <tt
+class="COMMAND">kill</tt> . W stands for paging. A dead process is marked with an <var
+class="LITERAL">X</var>. A process marked <var class="LITERAL">T</var> is traced, or
+stopped. <var class="LITERAL">R</var> means that the process is runable.</p>
+
+<p>If you want to see even more information about the running processes, try this
+out:</p>
+
+<table border="0" bgcolor="#E0E0E0" width="100%">
+<tr>
+<td>
+<pre class="SCREEN">
+<samp class="PROMPT">%</samp> <kbd class="USERINPUT">ps -aux</kbd>
+ USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
+ root 1 0.0 0.0 344 80 ? S Mar02 0:03 init [3]
+ root 2 0.0 0.0 0 0 ? SW Mar02 0:13 [kflushd]
+ root 3 0.0 0.0 0 0 ? SW Mar02 0:14 [kupdate]
+ root 4 0.0 0.0 0 0 ? SW Mar02 0:00 [kpiod]
+ root 5 0.0 0.0 0 0 ? SW Mar02 0:17 [kswapd]
+ root 11 0.0 0.0 1044 44 ? S Mar02 0:00 /sbin/kerneld
+ root 30 0.0 0.0 1160 0 ? SW Mar02 0:01 [cardmgr]
+ bin 50 0.0 0.0 1076 120 ? S Mar02 0:00 /sbin/rpc.port
+ root 54 0.0 0.1 1360 192 ? S Mar02 0:00 /usr/sbin/sysl
+ root 57 0.0 0.1 1276 152 ? S Mar02 0:00 /usr/sbin/klog
+ root 59 0.0 0.0 1332 60 ? S Mar02 0:00 /usr/sbin/inet
+ root 61 0.0 0.2 1540 312 ? S Mar02 0:04 /usr/local/sbi
+ root 63 0.0 0.0 1796 72 ? S Mar02 0:00 /usr/sbin/rpc.
+ root 65 0.0 0.0 1812 68 ? S Mar02 0:00 /usr/sbin/rpc.
+ root 67 0.0 0.2 1172 260 ? S Mar02 0:00 /usr/sbin/cron
+ root 77 0.0 0.2 1048 316 ? S Mar02 0:00 /usr/sbin/apmd
+ root 79 0.0 0.1 1100 152 ? S Mar02 0:01 gpm
+ root 94 0.0 0.2 1396 280 ? S Mar02 0:00 /usr/sbin/auto
+ chris 106 0.0 0.5 1820 680 tty1 S Mar02 0:08 -bash
+ root 108 0.0 0.0 1048 0 tty3 SW Mar02 0:00 [agetty]
+ root 109 0.0 0.0 1048 0 tty4 SW Mar02 0:00 [agetty]
+ root 110 0.0 0.0 1048 0 tty5 SW Mar02 0:00 [agetty]
+ root 111 0.0 0.0 1048 0 tty6 SW Mar02 0:00 [agetty]
+ [output cut]
+</pre>
+</td>
+</tr>
+</table>
+
+<p>That's a whole lot of information. Basically, it adds information including what user
+started the process, how much of the system resources the process is using (the %CPU,
+%MEM, VSZ, and RSS columns), and on what date the process was started. Obviously, that's
+a lot of information that could come in handy for a system administrator. It also brings
+up another point: the information now goes off the edge of the screen so that you cannot
+see it all. The <var class="OPTION">-w</var> option will force <tt
+class="COMMAND">ps</tt> to wrap long lines.</p>
+
+<p>It's not terribly pretty, but it does the job. You've now got the complete listings
+for each process. There's even more information that you can display about each process.
+Check out the very in-depth man page for <tt class="COMMAND">ps</tt>. However, the
+options shown above are the most popular ones and will be the ones you need to use the
+most often.</p>
+</div>
+
+<div class="NAVFOOTER">
+<hr align="LEFT" width="100%" />
+<table summary="Footer navigation table" width="100%" border="0" cellpadding="0"
+cellspacing="0">
+<tr>
+<td width="33%" align="left" valign="top"><a href="process-control-foregrounding.html"
+accesskey="P">Prev</a></td>
+<td width="34%" align="center" valign="top"><a href="index.html"
+accesskey="H">Home</a></td>
+<td width="33%" align="right" valign="top"><a href="process-control-kill.html"
+accesskey="N">Next</a></td>
+</tr>
+
+<tr>
+<td width="33%" align="left" valign="top">Foregrounding</td>
+<td width="34%" align="center" valign="top"><a href="process-control.html"
+accesskey="U">Up</a></td>
+<td width="33%" align="right" valign="top"><tt class="COMMAND">kill</tt></td>
+</tr>
+</table>
+</div>
+</body>
+</html>
+