c10fb333d6
git-svn-id: svn+ssh://atelier.inf.usi.ch/home/bevilj/group-1@189 a672b425-5310-4d7a-af5c-997e18724b81
74 lines
2.3 KiB
HTML
74 lines
2.3 KiB
HTML
---
|
|
layout: page
|
|
category-title: Intermediate commands
|
|
category-page: intermediate
|
|
tags:
|
|
author: Andrea Brites Marto
|
|
title: ps
|
|
---
|
|
|
|
<p>
|
|
The <code>ps</code> command stands for "process status" and it is used to provide
|
|
various information about the currently running processes.<br>
|
|
|
|
Every process is an executing instance of a program which is assigned a unique PID
|
|
(process identification numbers) by the system.<br>
|
|
|
|
The basic syntax of <code>ps</code> is:
|
|
|
|
<pre>
|
|
ps [options]
|
|
</pre>
|
|
|
|
This command can be used without any option and by doing this you will get the standard output,
|
|
which is the display monitor by default with four items of information for at least two
|
|
processes currently on the system: the shell and ps.<br>
|
|
|
|
Since we have already saw PID before, the TTY information that stands for terminal type
|
|
(originally teletype) is the console (or terminal) in which the user logged into.<br>
|
|
|
|
TIME is very simple: is the amount of CPU time in minutes and seconds that the process
|
|
has been running. CMD is simply the name of the command that launched the process.<br>
|
|
|
|
Here you will find some common option combinations
|
|
|
|
<pre>
|
|
ps -aux | less
|
|
</pre>
|
|
|
|
<ul>
|
|
<li>The -a option is used to list the processes of all users on the system.</li>
|
|
<li>The -u option tells ps to provide detailed information about each process.</li>
|
|
<li>The -x option adds to the list, processes that have no controlling terminal
|
|
(programs launched during booting).
|
|
</li>
|
|
</ul>
|
|
|
|
This can be piped to the less command ( see out section pipe), which let us to
|
|
view all processes in one screenfull at a time.<br>
|
|
|
|
Another way to view all processes running on the system is:
|
|
|
|
<pre>
|
|
ps -ef | less
|
|
</pre>
|
|
|
|
Where:
|
|
|
|
<ul>
|
|
<li>The -e option is used to generate a list of information about every process
|
|
(currently running).
|
|
</li>
|
|
<li>The -f option providesa list that contains some information for each process.</li>
|
|
</ul>
|
|
|
|
This is very useful, it can be used for example to control UID information (username of
|
|
the account that owns the process) and STIME to know when the process started, or
|
|
the starting date.<br>
|
|
|
|
|
|
In the end the <code>ps</code> is very powerful if we knoe how to use it.
|
|
If you need to kill a process you can list all process in various ways
|
|
and search for the process you need to kill by reading its PID or by UID for example.
|
|
\
|
|
</p>
|