top
top provides an ongoing look at processor activity in real time. It displays a listing of the most CPU-intensive tasks on the system, and can provide an interactive interface for manipulating processes. It can sort the tasks by CPU usage, memory usage and runtime. Can be better configured than the standard top from the procps suite. Procps is the package that has a bunch of small useful utilities that give information about processes using the /proc filesystem. The package includes the programs ps, top, vmstat, w, kill, free, slabtop, and skill. Most features can either be selected by an interactive command or by specifying the feature in the personal or system-wide configuration file.
Syntax
top [options]
Options
-a
Sort by memory usage
-b
-b
Starts top in 'Batch mode', which could be useful for sending output from top to other programs or to a file. In this mode, top will not accept input and runs until the iterations limit you've set with the '-n' command-line option or until killed.
-c
-c
Starts top with the last remembered 'c' state reversed. Thus, if top was displaying command lines, now that field will show program names, and vice versa.
-d
-d
Delay time interval as: -d ss.tt (seconds. tenths) Specifies the delay between screens updates, and overrides the corresponding value in one's personal configuration file or the startup default. Later this can be changed with the ’d’ or 's' interactive commands. Fractional seconds are honored, but a negative number is not allowed. In all cases, however, such changes are prohibited if top is running in 'Secure mode', except for root (unless the ’s’ command-line option was used).
-h
-h
Show Library version and the usage prompt, then quit.
-H
-H
Starts top with the last remembered 'H' state reversed. When this toggle is On, all individual threads will be displayed. Otherwise, top displays a summation of all threads in a process.
-i
-i
Starts top with the last remembered 'i' state reversed. When this toggle is Off, tasks that are idled or zombie will not be displayed.
-m
-m
Reports USED (sum of process and swap total count) instead of VIRT
-M
-M
Show memory units (k/M/G) and display floating point values in the memory summary.
-n
-n
Specifies the maximum number of iterations, or frames, top should produce before ending.
-p
-p
Monitor only processes with specified process IDs. This option can be given up to 20 times, or you can provide a comma delimited list with up to 20 process IDs. Co-mingling both approaches is permitted. This is a command-line option only. And should you wish to return to normal operation, it is not necessary to quit and restart top -- just issue the '=' interactive command.
-s
-s
Starts top with secure mode forced, even for root. This mode is far better controlled through the system configuration file (see topic 5. FILES).
-S
-S
Starts top with the last remembered 'S' state reversed. When 'Cumulative mode' is On, each process is listed with the CPU time that it and its dead children have used. See the 'S' interactive command for additional information regarding this mode.
-u Monitor only processes with an effective UID or user name matching that given.
-U
-u Monitor only processes with an effective UID or user name matching that given.
-U
Monitor only processes with a UID or user name matching that given. This matches real, effective, saved, and file system UIDs.
-v
-v
Show library version and the usage prompt, then quit.
Output
PID | The process id. |
USERNAME
|
Username of the process's owner (if -u is specified, a UID column will be substituted for USERNAME).
|
THR
|
The number of threads in the processes also labeled as NLWP.
|
PR
|
Current priority of the process.
|
NICE
|
Nice amount in the range -20 to 20, as established by the use of the command nice.
|
SIZE
|
Total size of the process (text, data, and stack) given in kilobytes.
|
VIRT | Virtual memory used by process, |
RES
|
Resident memory: current amount of process memory that resides in physical memory, given in kilobytes. |
SHR | Shows the shareable memory |
CPU
|
Percentage of available cpu time used by this process. |
MEM | Memory used by process as a percentage |
TIME
|
Number of system and user cpu seconds that the process has used. |
COMMAND
|
Name of the command that the process is currently running. |
top
top - 20:50:55 up 167 days, 14:26, 82 users, load average: 0.13, 0.05, 0.01
Tasks: 3 total, 1 running, 2 sleeping, 0 stopped, 0 zombie
Cpu(s): 0.0% user, 2.2% system, 0.0% nice, 97.8% idle
Mem: 514964k total, 507860k used, 7104k free, 30404k buffers
Swap: 1630588k total, 158708k used, 1471880k free, 275380k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 3747
hope 11 0 2004 1608 1608 S 0.3 0.3 0:00.56 sshd 22245
hope 10 0 688 676 672 S 0.0 0.1 0:00.06 csh 14015
hope 10 0 1024 1024 848 R 0.0 0.2 0:00.00 top
Startup Defaults
The following startup defaults assume no configuration file, thus no user customizations. Even so, items shown with an asterisk ('*') could be overridden through the command-line.Startup Defaults
Some
more options in running top command
O | To Sort field via field letter. |
z | Will display running process in color. |
x | Will highlight the values in the sort column with bold text. |
b | Will highlight with a different background color. |
c | Will display absolute path of running process. |
1 | Will display the load information about individual CPU cores. |
V | Will display the processes in a parent child hierarchy. |
r | Will change the priority of the process also called as renice. |
R | Will reverse the sorting order of the currently sorted column. |
k | We can kill a process after finding PID of process by pressing ‘k‘ option in running top command without exiting from top window. |
P | Will sort processes as per CPU utilization. |
W | Will save the running top command results under /root/.toprc |
ctrl + z | Will pause top so that we can continue using the terminal. To bring top back to the foreground, type fg. |
f | By default top displays only few columns out of many more that it can display. If you want to add or remove a particular column or change the order of columns. |
No comments:
Post a Comment