By Jwalitha N J, Divya Monisha
Syntax : ps [options]
Ps is used to list all the active process. It list the process ID, parent processs ID, user ID, name, terminal.
There are various options that could be given along the ps command such as
To list simple process
Ps –A or ps-e,
Ps –a
Ps T
Ps r
Ps f
To list standard process
Ps –ef
Ps –eF
Ps –ely
To list BSD format
Ps –aux
Ps aux
To list root process ps –u root
To list threads ps -eLF
Syntax: ps [options]
Definition: ps lists the information of active process.
There are various options that could be given in ps , they are as follows
1. ps
When ps alone is executed at the Linux terminal the output generated is
PID TTY TIME CMD
5839 pts/2 00:00:00 bash
5885 pts/2 00:00:00 ps
Here bash is the name of the working terminal and the process that currently running is man ps. Hence here the list has two processes with process-id(PID),file name of the terminal(tty),TIME and CMD
2. ps –A or ps –e
Selects all the process. The output contains PID,TTY,TIME and CMD
3. ps – a
Selects all the process except the process associated with the terminal.
PID TTY TIME CMD
5849 pts/0 00:00:00 man
5858 pts/0 00:00:00 less
5897 pts/2 00:00:00 ps
4. ps –d
Select all process except session leaders. Session leader is one that creates another session.
5. ps r
Selects only running process.
PID TTY STAT TIME COMMAND
5685 pts/0 R+ 0:00 ps r
6. ps T
Selects those process that are associated with the terminal
PID TTY STAT TIME COMMAND
5637 pts/0 Ss 0:00 bash
5702 pts/0 R+ 0:00 ps t
Here bash is the name the working terminal and the process that is associated with bash is ps t command that is currently running.
There are options that displays files in particularformat such as standard format and BSD format
To display standard format process
1. ps -e : selection of all process.
2. Ps –ef
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 19:56 ? 00:00:00 /sbin/init
root 2 0 0 19:56 ? 00:00:00 [kthreadd]
root 3 2 0 19:56 ? 00:00:00 [ksoftirqd/0]
root 4 2 0 19:56 ? 00:00:00 [kworker/0:0]
3. ps -eF
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 19:56 ? 00:00:00 /sbin/init
root 2 0 0 19:56 ? 00:00:00 [kthreadd]
root 3 2 0 19:56 ? 00:00:00 [ksoftirqd/0]
root 4 2 0 19:56 ? 00:00:00 [kworker/0:0]
4. ps -ely
S UID PID PPID C PRI NI RSS SZ WCHAN TTY TIME CMD
S 0 1 0 0 80 0 1812 730 poll_s ? 00:00:00 init
S 0 2 0 0 80 0 0 0 kthrea ? 00:00:00 kthreadd
S 0 3 2 0 80 0 0 0 run_ks ? 00:00:00 ksoftirqd/0
S 0 4 2 0 80 0 0 0 worker ? 00:00:00 kworker/0:0
To display process of BSD format
1. ps -aux
This selects process those associated with a particular user.
PID TTY STAT TIME COMMAND
1 ? Ss 0:00 /sbin/init
2 ? S 0:00 [kthreadd]
3 ? S 0:00 [ksoftirqd/0]
2. ps aux
This selects all the process with the complete details The difference in aux and -aux is that , in -aux the user name is given example –ausylar.If that user does not exists then the command is treated as aux displaying all the process.
To get information on threads we use the options as
1. ps -eLf
Example:
UID PID PPID LWP C NLWPSZ RSS PSR STIME TTY TIME CMD
root 1 0 1 0 1 549 704 0 19:51 ? 00:00:01 init [5]
root 2 0 2 0 1 0 0 1 19:51 ? 00:00:00 [kthreadd]
sylar 5795 5637 5795 0 1 650 852 0 20:11 pts/0 00:00:00 ps -eLF
Sample program
ps // to list current working process.
#ps –e
ps u // to list process that run as root
ps -u root
ps -eopid // to list all process PID.
ps -p 2454 // to list the name of the process with PID 2454.
Output
// output for ps
PID TTY TIME CMD
5927 pts/3 00:00:00 bash
6006 pts/3 00:00:00 sh
6007 pts/3 00:00:00 ps
// output for ps u
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
sylar 5637 0.0 0.0 5028 2272 pts/0 Ss 19:53 0:00 bash
sylar 5652 0.0 0.0 5028 2268 pts/2 Ss 19:53 0:00 bash
sylar 5668 0.0 0.0 4508 1656 pts/2 S+ 19:53 0:00 man ps
sylar 5677 0.0 0.0 3848 996 pts/2 S+ 19:53 0:00 less
sylar 5854 0.0 0.0 2600 868 pts/0 R+ 20:18 0:00 ps u
// output for ps –u root
PID TTY TIME CMD
1 ? 00:00:01 init
2 ? 00:00:00 kthreadd
3 ? 00:00:00 ksoftirqd/0
4 ? 00:00:01 kworker/0:0
6 ? 00:00:00 migration/0
7 ? 00:00:00 watchdog/0
8 ? 00:00:00 migration/1
10 ? 00:00:00 ksoftirqd/1
12 ? 00:00:00 watchdog/1
13 ? 00:00:00 migration/2
// output for ps -eopid
PID
1
2
3
4
6
7
.. 6008
//output for ps –p 2454
PID TTY TIME CMD
2454 tty5 00:00:00 mingetty
No comments:
Post a Comment