Task Manager in Linux


Everyone is familiar with the task manager in Windows.
There is a similar option in Linux too.
It is known as “System Monitor” is present under “System> Administration> System Monitor”. It lists out many details u would like to know about any running process.

Another way is the “ps” command, stands for Process Status. It basically reports a snapshot of the current processes. It is much more powerful, customizable and useful(if you know how to use it). To execute it just type out:

$ ps

Now there are many more options ie. the processes u want to display(or “Select” as it is called in linux) possible with this. I have listed out some important & useful options and information.

SIMPLE PROCESS SELECTION
-A, -e Select all processes. Identical to -e.
-N Negates the selection. Identical to –deselect.
T Select all processes associated with this terminal. Identical to the t option without any argument.
-a Select all processes except session leaders and processes not associated with a terminal.
a List all processes with a terminal (tty), list all processes when used together with the x option.
r Restrict the selection to only running processes.
x List all processes owned by you (same EUID as ps).
–deselect Select all processes except those that fulfill the specified conditions. (negates the selection) Identical to -N.

PROCESS SELECTION BY LIST
These options accept a single argument in the form of a blank-separated or comma-separated list. They can be used multiple times.
For example: ps -p “1 2” -p 3,4

-C cmdlist Select by command name.
-G grplist Select by real group ID (RGID) or name.
U userlist Select by effective user ID (EUID) or name.
-U userlist Select by real user ID (RUID) or name.
p pidlist Select by process ID. Identical to -p and –pid.
-p pidlist Select by PID.
This selects the processes whose process ID numbers appear in pidlist. Identical to p and –pid.
-u userlist Select by effective user ID (EUID) or name. Identical to U and –user.

OUTPUT FORMAT CONTROL
These options are used to choose the information displayed by ps. The output may differ by personality.

-F extra full format. See the -f option, which -F implies.
-O format is like -o, but preloaded with some default columns. Identical to -o pid,format,state,tname,time,command or
-o pid,format,tname,time,cmd, see -o below.
O format is preloaded o (overloaded).
The BSD O option can act like -O (user-defined output format with some common fields predefined) or can be used to specify sort order. To ensure that the desired behavior is obtained (sorting or formatting), specify the option in some other way (e.g. with -O or –sort). When used as a formatting option, it is identical to -O, with the BSD personality.

THREAD DISPLAY
H Show threads as if they were processes
-L Show threads, possibly with LWP and NLWP columns
-T Show threads, possibly with SPID column
m Show threads after processes
-m Show threads after processes

PROCESS FLAGS
The sum of these values is displayed in the “F” column, which is provided by the flags output specifier.
1 forked but didn’t exec
4 used super-user privileges

PROCESS STATE CODES
Here are the different values that the s, stat and state output specifiers (header “STAT” or “S”) will display to describe the state of a process.
D Uninterruptible sleep (usually IO)
R Running or runnable (on run queue)
S Interruptible sleep (waiting for an event to complete)
T Stopped, either by a job control signal or because it is being traced.
W paging (not valid since the 2.6.xx kernel)
X dead (should never be seen)
Z Defunct (“zombie”) process, terminated but not reaped by its parent.

For BSD formats and when the stat keyword is used, additional characters may be displayed:
< high-priority (not nice to other users)
N low-priority (nice to other users)
L has pages locked into memory (for real-time and custom IO)
s is a session leader
l is multi-threaded (using CLONE_THREAD, like NPTL pthreads do)
+ is in the foreground process group

More information can be obtained by using the usual "man" command for the linux manual.
$ man ps

Hope this information will be helpful esp. for System programming.

Advertisements

What do you think??

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s