ps & top
Using the ps Command
The
ps
command allows you to display information about
running processes.
It produces “a static list”, that is, a snapshot of what is running when you
execute the command
To list all processes which are currently
running on the system including processes owned by other users; use #ps ax
This command displays 5 additional information:
1. Displays
the process ID (
PID
)
2. The
terminal that is associated with it (
TTY
)
3. The
current status (
STAT
)
4. The
cumulated CPU time (
TIME
)
5. The name of the executable files (
COMMAND
)
root@localhost ~]# ps ax
Warning: bad syntax, perhaps a bogus '-'? See
/usr/share/doc/procps-3.2.8/FAQ
USER PID %CPU
%MEM VSZ RSS TTY STAT START TIME COMMAND
root 1895 0.0
0.1 64116 1164 ?
Ss 01:13 0:00 /usr/sbin/sshd
root 1933 0.0
0.1 29612 1556 ?
Ss 01:13 0:00 tpvmlpd2
ntp 1945 0.0
0.1 30160 1632 ?
Ss 01:13 0:00 ntpd -u ntp:ntp
postfix 2073 0.0
0.3 78800 3252 ?
S 01:13 0:00 pickup -l -t fi
root 2118 0.3
0.1 117212 1380 ? Ss
01:13 0:01 crond
gdm 2293 0.0
0.0 20036 640 ?
S 01:13 0:00 /usr/bin/dbus-l
root 2299 0.0
0.2 45096 2572 ?
S 01:13 0:00 /usr/libexec/de
rtkit 2352 0.0
0.1 168452 1216 ? SNl
01:13 0:00 /usr/libexec/rt
root 2358 0.0
0.2 176904 2996 ? S
01:13 0:00 pam: gdm-passwo
redhat 2377 0.0
0.6 253072 6672 ? Ssl
01:14 0:00 gnome-session
apache 2755 0.0
0.2 184152 2444 ? S
01:17 0:00 /usr/sbin/httpd
apache 2758 0.0
0.2 184152 2444 ? S
01:17 0:00 /usr/sbin/httpd
redhat 2789 0.0
0.1 108364 1816 pts/2 Ss
01:17 0:00 bash
To view a specific process as vsftpd use:
[root@localhost ~]# ps ax |grep vsftpd
1957 ? Ss
0:00 /usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf
3242 pts/0 S+
0:00 grep vsftpd
[root@localhost ~]#
To display the owner alongside each process;
use #ps -aux
For a complete list of available command line
options, refer to the ps(1) manual page.
Using the top Command
The
top
command displays a real-time list of processes that are running on the
system.
It displays also:
1. System
uptime,
2. Current
CPU and memory usage,
3. Total
number of running processes,
4. Allows
you to perform actions such as sorting the list or killing a process.
[root@localhost ~]# top
top - 14:19:11 up 55 days, 10:37, 5 users,
load average: 0.07, 0.13, 0.09
Tasks: 160 total, 1
running, 159 sleeping, 0 stopped, 0 zombie
Cpu(s): 15.7%us,
1.0%sy, 0.0%ni, 88.3%id, 0.0%wa,
0.0%hi, 0.0%si, 0.0%st
Mem: 760752k
total, 644360k used, 116392k free, 3988k buffers
Swap: 1540088k
total, 76648k used, 1463440k free, 196832k cached
PID USER PR
NI VIRT RES
SHR S %CPU %MEM TIME+ COMMAND
14401 jhradile 20 0
313m 10m 5732 S 5.6
1.4 6:27.29 gnome-system-mo
1764 root 20
0 133m 23m 4756 S
5.3 3.2 6:32.66 Xorg
13865 jhradile 20 0 1625m 177m 6628 S 0.7 23.8
0:57.26 java
20 root 20
0 0 0
0 S 0.3 0.0
4:44.39 ata/0
2085 root 20
0 40396 348 276 S
0.3 0.0 1:57.13 udisks-daemon
1 root 20
0 19404 832 604 S
0.0 0.1 0:01.21 init
2 root 20
0 0 0
0 S 0.0 0.0
0:00.01 kthreadd
3 root RT
0 0 0
0 S 0.0 0.0
0:00.00 migration/0
4 root 20
0 0 0
0 S 0.0 0.0
0:00.02 ksoftirqd/0
5 root RT
0 0 0
0 S 0.0 0.0
0:00.00 migration/0
6 root RT
0 0 0 0
S 0.0
0.0 0:00.00 watchdog/0
7 root 20
0 0 0
0 S 0.0 0.0
0:01.00 events/0
8 root 20
0 0 0
0 S 0.0 0.0
0:00.00 cpuset
10 root 20
0 0 0
0 S 0.0 0.0
0:00.00 netns
11 root 20
0 0 0
0 S 0.0 0.0
0:00.00 async/mgr
Command
|
Description
|
Enter, Space
|
Immediately refreshes the display.
|
h, ?
|
Displays a help screen.
|
k
|
Kills a process. You are prompted for the
process ID and the signal to send to it.
|
n
|
Changes the number of displayed processes. You are
prompted to enter the number.
|
u
|
Sorts the list by user.
|
M
|
Sorts the list by memory usage.
|
P
|
Sorts the list by CPU usage.
|
q
|
Terminates the utility and returns to the shell prompt.
|
No comments:
Post a Comment