[Home] [Credit Search] [Category Browser] [Staff Roll Call] | The LINUX.COM Article Archive |
Originally Published: Tuesday, 12 June 2001 | Author: Michael Stutz |
Published to: learn_articles_firststep/General | Page: 4/5 - [Printable] |
The Linux Cookbook: Chapter 2, WHAT EVERY LINUX USER KNOWS
Today's Learn article derived from Chapter Two of the
soon to be published Linux Cookbook contains a ton
of useful information for the new user. Learn all kinds of useful
commands and short-cuts for basic system operation, and then join
author Michael Stutz as he answers your questions live in Linux.com
Live! Linux.com would like to thank publisher Bill Polluck of No Starch Press for the free use of
this material.
|
<< Page 4 of 5 >> | |
2.7 LISTING SYSTEM ACTIVITYWhen you run a command, you are starting a process on the system, which is a program that is currently executing. Every process is given a unique number, called its process ID, or "PID." Use ps to list processes on the system. Some of the information it can display about a process includes process ID, name of command being run, username running the command, and how long the process has been running. By default, ps outputs 5 columns: process ID, the name of the terminal from which the process was started, the current status of the process (including 'S' for sleeping, meaning that it is on hold at the moment, 'R' meaning that it is running, and 'Z' meaning that it is a zombie process, or a process whose parent processes have died), the total amount of time the CPU has spent on the process since the process started, and finally the name of the command being run. The following recipes describe popular usage of ps. 2.7.1 LISTING YOUR CURRENT PROCESSESType ps with no arguments to list the processes you have running in your current shell session.
$ ps "Ret"
In this example, ps shows that two processes are running: the bash and ps commands. 2.7.2 LISTING ALL OF A USER'S PROCESSESTo list all the processes of a specific user, use ps and give the username to list as an argument to the '-u' option. While you can't snoop on the actual activities of other users, you can list the commands they are running at a given moment.
$ ps -u hst "Ret"
NOTE: This command is useful for listing all of your own processes, across all terminals and shell sessions; give your own username as an argument. 2.7.3 LISTING ALL PROCESSES ON THE SYSTEMTo list all processes by all users on the system, use the 'aux' options.
NOTE: There could be a lot of output--even single-user Linux systems typically have fifty or more processes running at one time--so you may want to pipe the output of this command through less for perusal (see Recipe 9.1 Perusing Text, page 111). Additionally, use top to show a display of all processes on the system, sorted by their demand on the system resources. The display is continually updated with current process information; type q to stop the display and exit the program. This tool also displays the information about system runtime and memory that can be output with the uptime and free commands.
2.7.4 LISTING PROCESSES BY NAME OR NUMBERTo list processes whose output contains a name or other text to match, list all processes and pipe the output to grep. This is useful for when you want to see which users are running a particular program or command.
| |
<< Page 4 of 5 >> |