LinuxDevCenter.com
oreilly.comSafari Books Online.Conferences.





Linux in a Nutshell

This directory of Linux commands is from Linux in a Nutshell, 5th Edition.

Click on any of the 687 commands below to get a description and list of available options. All links in the command summaries point to the online version of the book on Safari Bookshelf.

Buy it now, or read it online on Safari Bookshelf.



top

top [options]

Provide information (frequently refreshed) about the most CPU-intensive processes currently running. You do not need to include a - before options. See ps for explanations of the field descriptors.

Options

-b

Run in batch mode; don't accept command-line input. Useful for sending output to another command or to a file.

-c

Show command line in display instead of just command name.

-d delay

Specify delay between refreshes.

-f

Add or remove fields or columns.

-h

Print a help message and exit.

-i

Suppress display of idle and zombie processes. -i is a toggle; top starts with the last remembered setting.

-n num

Update display num times, then exit.

-p pid

Monitor only processes with the specified process ID.

-s

Secure mode. Disable some (dangerous) interactive commands.

-S

Cumulative mode. Print total CPU time of each process, including dead child processes.

-u user

Monitor only processes with the specified effective UID or username.

-U user

Monitor only processes with the specified UID or username, matching real, effective, saved, and filesystem ids.

-v

Print version information and exit.

Interactive commands

=

Remove restrictions on which tasks are shown. Reverses the effect of an active i or n command.

space, Enter

Update display immediately.

<, >

Move the sort field. Use < to move one column left and > to move one column to the right.

A

Toggle alternate display mode between a single window or multiple windows. See the following section Alternate display mode commands for the commands that work with A.

b

Toggle between bold and reverse display. Only works with x or y.

B

Globally toggle bold display.

c

Toggle display of command name or full command line.

d, s

Change delay between refreshes. Prompt for new delay time, which should be in seconds. Suppressed in secure mode.

f

Prompt to add fields to or remove fields from the display.

F, O

Select sort field.

G

Select another field group and make it current, or change by selecting a number from the following list:

1

Def

2

Job

3

Mem

4

Usr

h, ?

Display help about commands and the status of secure and cumulative modes.

I, 1

Toggle SMP view. Use I to toggle IRIX/Solaris mode, 1 to toggle single/separate states.

k

Prompt for process ID to kill, and signal to send (default is 15) to kill it.

i

Toggle suppression of idle and zombie processes.

l

Toggle display of load-average and uptime information.

m

Toggle display of memory information.

n, #

Prompt for maximum number of processes to show. If 0 is entered, show as many as will fit on the screen (default).

N

Sort numerically by process ID.

o

Prompt to change order of displayed fields.

P

Sort tasks by CPU usage (default).

q

Exit.

r

Apply renice to a process. Prompt for PID and renice value. Suppressed in secure mode.

R

Toggle normal or reverse sort.

S

Toggle cumulative mode. (See the -S option.)

t

Toggle display of processes and CPU states lines.

T

Sort tasks by time/cumulative time.

u

Prompt for specific user to show.

W

Write current setup to ~/.toprc. This is the recommended way to write a top configuration file.

x

Toggle highlighting for sort field.

y

Toggle highlights for running tests.

z

Toggle between color and mono display.

Z

Globally change color mappings.

Alternate display mode commands

=

Rebalance tasks in the current window.

+

Rebalance tasks in every window.

-

Show or hide the current window.

_

Show all invisible windows or hide all visible windows.

a

Cycle forward through all four windows.

g

Change the name of the current window or group.

w

Cycle backward through all four windows.

Field descriptions

The first five entries in the following list describe the lines that appear at the top of the top display. The rest are the fields that can be displayed for each task (sizes are in kilobytes). Use the interactive f command to add or remove fields.

top

Display the time the system has been up, the number of users, and three load averages consisting of the average number of processes ready to run in the last 1, 5, and 15 minutes.

Tasks

The total number of processes running when the last update was taken, shown as the number of running, sleeping, stopped, or undead tasks.

Cpu(s)

The percentage of CPU time spent in user mode, in system mode, on tasks with a negative nice value, and idle.

Mem

Memory statistics, including total available memory, free memory, memory used, shared memory, and memory used for buffers.

Swap

Swapspace statistics, including total, available, used, and cached.

PID

Process ID.

PPID

Parent process ID.

UID

Effective user ID of task's owner.

USER

Effective username of task's owner.

RUSER

Real username of task's owner.

GROUP

The effective group name of task's owner.

PR

Priority.

NI

Nice value.

nFLT

Page fault count.

CODE

Code size.

DATA

Data plus stack size.

RES

Resident task size.

SWAP

Size of swapped-out portion of task.

VIRT

The total amount of virtual memory used by the task.

nDRT

Size of pages marked dirty.

#C

Last-used processor, for multiprocessor systems.

SHR

Amount of shared memory used.

S

State of the task. Values are S (sleeping), D (uninterruptible sleep), R (running), Z (zombies), or T (stopped or traced), possibly followed by < (negative nice value), N (positive nice value), or W (swapped out).

WCHAN

Address or name of the kernel function in which the task is currently sleeping.

TIME

Total CPU time used by task and any children.

TIME+

Like TIME, but shows the time down to hundredths of a second.

%CPU

Share of CPU time since last update, as percentage of total CPU time.

%MEM

Share of physical memory.

TTY

Controlling tty.

COMMAND

Command line (truncated if too long) if task is in memory, or command name in parentheses if swapped out.

FLAGS

Task flags.