Skillnad mellan versioner av "TOP"
Js146669 (Diskussion | bidrag) (TOP command for linux) |
(Ingen skillnad)
|
Nuvarande version från 20 maj 2021 kl. 09.53
TOP
The top program provides a dynamic real-time view of a running system. It can display system summary information as well as a list of tasks currently being managed by the Linux kernel.
Executing on the cli
Usage: top -hv | -bcHiOSs -d secs -n max -u|U user -p pid(s) -o field -w [cols]
# top # top –u dbuser | option will display specific User process details # top -n 1 -b > top-output.txt | save the running top command results output to a file # top -n 10 |automatically exit after 10 number of repetition.
Reading the output
N.B! By default, top updates its display every three seconds
- The first line of numbers on the dashboard includes the time, how long your computer has been running, the number of people logged in, and what the load average has been for the past one, five, and 15 minutes.
- The second line shows the number of tasks and their states: running, stopped, sleeping, or zombie.
- The third line displays the following central processing unit (CPU) values:
us: Amount of time the CPU spends executing processes for people in “user space.” sy: Amount of time spent running system “kernel space” processes. ni: Amount of time spent executing processes with a manually set nice value. id: Amount of CPU idle time. wa: Amount of time the CPU spends waiting for I/O to complete. hi: Amount of time spent servicing hardware interrupts. si: Amount of time spent servicing software interrupts. st: Amount of time lost due to running virtual machines (“steal time”).
- The fourth line shows the total amount (in kibibytes) of physical memory, and how much is free, used, and buffered or cached.
- The fifth line shows the total amount (also in kibibytes) of swap memory, and how much is free, used, and available. The latter includes memory that’s expected to be recoverable from caches.
The column headings in the process list are as follows:
PID: Process ID. USER: The owner of the process. PR: Process priority. NI: The nice value of the process. VIRT: Amount of virtual memory used by the process. RES: Amount of resident memory used by the process. SHR: Amount of shared memory used by the process. S: Status of the process. (See the list below for the values this field can take). %CPU: The share of CPU time used by the process since the last update. %MEM: The share of physical memory used. TIME+: Total CPU time used by the task in hundredths of a second. COMMAND: The command name or command line (name + options).
The status of the process can be one of the following:
D: Uninterruptible sleep R: Running S: Sleeping T: Traced (stopped) Z: Zombie
If you have a multi-core CPU, press 1 to change the display and see individual statistics for each CPU.
For each CPU, top displays three numbers and the graph. From left to right, the numbers are as follows:
- The combined us and ni percentage (user space+tasks with nonstandard nice settings). - The sy percentage (kernel space). - The total (rounded to an integer value).
Changing the Numeric Units
Memory values are shown in kibibytes.
Change the display units to more readable values by presssing capital E to cycle through the units used to display memory values in these options:
kibibytes mebibytes gibibytes tebibytes pebibytes exbibytes
The unit in use is the first item on lines four and five.
Press lowercase “e” to do the same thing for the values in the process list:
kibibytes mebibytes gibibytes tebibytes pebibytes
Sorting by Columns
By default, the process list is sorted by the %CPU column.
You can change the sort column by pressing the following: P: The %CPU column. M: The %MEM column. N: The PID column. T: The TIME+ column.
TOP interactive console cmds
h |help screen z |highlight processes in red c |display absolute path of running process I |display only active tasks. n |limit the display to a certain number of lines, regardless of whether the tasks are active. t |swap the CPU displays to simple ASCII graphs that show the percentage of usage for each CPU. u |display the processes for a single user. You’ll be prompted for the name or UID. V |display a “tree” of processes that were launched or spawned by other processes k |kill a process after finding PID d |change default screen refresh interval default= 3 seconds Shift+P | to sort processes as per CPU utilization Shift+O | to Sort field via field letter Space |Force top to refresh its display right now.
Press Q to exit top
You can also install htop which is more user-friendly / interactive than original top
URL: HTOP