The command top (which stands for "table of processes") displays a list of processes that is refreshed every two seconds. To terminate the program, press Q. The parameter -n 1 terminates the program after a single display of the process list:
$ top -n 1 top - 14:19:53 up 62 days, 3:35, 14 users, load average: 0.01, 0.02, 0.00 Tasks: 102 total, 7 running, 93 sleeping, 0 stopped, 2 zombie Cpu(s): 0.3% user, 0.1% system, 0.0% nice, 99.6% idle Mem: 514736k total, 497232k used, 17504k free, 56024k buffers Swap: 1794736k total, 104544k used, 1690192k free, 235872k cached PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ Command 1426 root 15 0 116m 41m 18m S 1.0 8.2 82:30.34 X 20836 jj 15 0 820 820 612 R 1.0 0.2 0:00.03 top 1 root 15 0 100 96 72 S 0.0 0.0 0:08.43 init 2 root 15 0 0 0 0 S 0.0 0.0 0:04.96 keventd 3 root 34 19 0 0 0 S 0.0 0.0 0:00.99 ksoftirqd_CPU0 4 root 15 0 0 0 0 S 0.0 0.0 0:33.63 kswapd 5 root 15 0 0 0 0 S 0.0 0.0 0:00.71 bdflush [...] 1362 root 15 0 488 452 404 S 0.0 0.1 0:00.02 nscd 1363 root 15 0 488 452 404 S 0.0 0.1 0:00.04 nscd 1377 root 17 0 56 4 4 S 0.0 0.0 0:00.00 mingetty 1379 root 18 0 56 4 4 S 0.0 0.0 0:00.01 mingetty 1380 root 18 0 56 4 4 S 0.0 0.0 0:00.01 mingetty
If you press F while top is running, a menu opens with which to make extensive changes to the format of the output.
The parameter -U UID monitors only the processes associated with a particular user. Here, UID is the user ID of the user. The following command returns the UID of the user on the basis of the user name and displays his processes:
$ top -U $(id -u username)