{"id":903,"date":"2016-02-04T10:16:29","date_gmt":"2016-02-04T17:16:29","guid":{"rendered":"http:\/\/homepages.uc.edu\/~yaozo\/wordpress\/?p=903"},"modified":"2022-11-22T05:06:44","modified_gmt":"2022-11-22T05:06:44","slug":"understanding-the-top-command-on-linux","status":"publish","type":"post","link":"https:\/\/zhuoyao.net\/index.php\/2016\/02\/04\/understanding-the-top-command-on-linux\/","title":{"rendered":"Understanding the Top command on Linux"},"content":{"rendered":"<p>Know what is happening in \u201creal time\u201d on your systems is in my opinion the basis to use and optimize your OS. On ArchLinux or better on GNU\/Linux in general the <code>top<\/code> command can help us, this is a very useful system monitor that is really easy to use, and that can also allows us to understand why our OS suffers and which process use most resources. The command to be run on the terminal is:<\/p>\n<div class=\"wp_syntax\">\n<table>\n<tbody>\n<tr>\n<td class=\"code\">\n<pre class=\"bash\">$ top<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>And we\u2019ll get a screen similar to the one on the right:<\/p>\n<p>Let\u2019s see now every single row of this output to explain all the information found within the screen.<br \/>\n<span id=\"more-5877\"><\/span><\/p>\n<h3>1\u00b0 Row \u2014 top<\/h3>\n<p><img decoding=\"async\" class=\"alignleft size-full wp-image-5884\" title=\"topr1\" src=\"http:\/\/cdn.linuxaria.com\/wp-content\/uploads\/2012\/08\/topr1.png\" sizes=\"(max-width: 632px) 100vw, 632px\" srcset=\"http:\/\/cdn.linuxaria.com\/wp-content\/uploads\/2012\/08\/topr1-300x9.png 300w, http:\/\/linuxaria.com\/wp-content\/uploads\/2012\/08\/topr1.png 632w\" alt=\"topr1\" width=\"632\"><\/p>\n<p>&nbsp;<\/p>\n<p>This first line indicates in order:<\/p>\n<ul>\n<li>current time (11:37:19)<\/li>\n<li>uptime of the machine (up 1 day, 1:25)<\/li>\n<li>users sessions logged in (3 users)<\/li>\n<li>average load on the system (load average: 0.02, 0.12, 0.07) the 3 values refer to the last minute, five minutes and 15 minutes.<\/li>\n<\/ul>\n<h3>2\u00b0 Row \u2013 task<\/h3>\n<p><img decoding=\"async\" class=\"alignleft size-full wp-image-5886\" title=\"topr2\" src=\"http:\/\/cdn.linuxaria.com\/wp-content\/uploads\/2012\/08\/topr2.png\" sizes=\"(max-width: 632px) 100vw, 632px\" srcset=\"http:\/\/cdn.linuxaria.com\/wp-content\/uploads\/2012\/08\/topr2-300x8.png 300w, http:\/\/linuxaria.com\/wp-content\/uploads\/2012\/08\/topr2.png 632w\" alt=\"topr2\" width=\"632\"><\/p>\n<p>&nbsp;<\/p>\n<p>The second row gives the following information:<\/p>\n<ul>\n<li>Processes running in totals (73 total)<\/li>\n<li>Processes running (2 running)<\/li>\n<li>Processes sleeping (71 sleeping)<\/li>\n<li>Processes stopped (0 stopped)<\/li>\n<li>Processes waiting to be stoppati from the parent process (0 zombie)<\/li>\n<\/ul>\n<h3>3\u00b0 Row \u2013 cpu<\/h3>\n<p><img decoding=\"async\" class=\"alignleft size-full wp-image-5887\" title=\"topr3\" src=\"http:\/\/cdn.linuxaria.com\/wp-content\/uploads\/2012\/08\/topr3.png\" sizes=\"(max-width: 632px) 100vw, 632px\" srcset=\"http:\/\/cdn.linuxaria.com\/wp-content\/uploads\/2012\/08\/topr3-300x8.png 300w, http:\/\/linuxaria.com\/wp-content\/uploads\/2012\/08\/topr3.png 632w\" alt=\"topr3\" width=\"632\"><\/p>\n<p>&nbsp;<\/p>\n<p>The third line indicates how the cpu is used. If you sum up all the percentages the total will be 100% of the cpu. Let\u2019s see what these values indicate in order:<\/p>\n<ul>\n<li>Percentage of the CPU for user processes (0.3%<strong>us<\/strong>)<\/li>\n<li>Percentage of the CPU for system processes (0.0%<strong>sy<\/strong>)<\/li>\n<li>Percentage of the CPU processes with priority upgrade&nbsp;<em>nice<\/em>&nbsp;(0.0%<strong>ni<\/strong>)<\/li>\n<li>Percentage of the CPU not used (99,4%<strong>id<\/strong>)<\/li>\n<li>Percentage of the CPU processes waiting for I\/O operations(0.0%<strong>wa<\/strong>)<\/li>\n<li>Percentage of the CPU serving hardware interrupts (0.3% <strong>hi<\/strong> \u2014 Hardware IRQ<\/li>\n<li>Percentage of the CPU serving software interrupts (0.0% <strong>si<\/strong> \u2014 Software Interrupts<\/li>\n<li>The amount of CPU \u2018stolen\u2019 from this virtual machine by the hypervisor for other tasks (such as running another virtual machine) this will be 0 on desktop and server without Virtual machine. (0.0%<strong>st<\/strong> \u2014 Steal Time)<\/li>\n<\/ul>\n<h3>4\u00b0 and 5\u00b0 Rows \u2013 memory usage<\/h3>\n<p><img decoding=\"async\" class=\"alignleft size-full wp-image-5890\" title=\"topr45\" src=\"http:\/\/cdn.linuxaria.com\/wp-content\/uploads\/2012\/08\/topr45.png\" sizes=\"(max-width: 632px) 100vw, 632px\" srcset=\"http:\/\/cdn.linuxaria.com\/wp-content\/uploads\/2012\/08\/topr45-300x15.png 300w, http:\/\/linuxaria.com\/wp-content\/uploads\/2012\/08\/topr45.png 632w\" alt=\"topr45\" width=\"632\"><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>The fourth and fifth rows respectively indicate the use of physical memory (RAM) and swap. In this order: Total memory in use, free, buffers cached. On this topic you can also read the following <a href=\"http:\/\/linuxaria.com\/howto\/linux-memory-management?lang=en\"> article <\/a><\/p>\n<h3>Following Rows \u2014 Processes list<\/h3>\n<p><img decoding=\"async\" class=\"alignleft size-full wp-image-5891\" title=\"topr6\" src=\"http:\/\/cdn.linuxaria.com\/wp-content\/uploads\/2012\/08\/topr6.png\" sizes=\"(max-width: 631px) 100vw, 631px\" srcset=\"http:\/\/cdn.linuxaria.com\/wp-content\/uploads\/2012\/08\/topr6-300x23.png 300w, http:\/\/linuxaria.com\/wp-content\/uploads\/2012\/08\/topr6.png 631w\" alt=\"topr6\" width=\"631\"><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>And as last thing ordered by CPU usage (as default) there are the processes currently in use. Let\u2019s see what information we can get in the different columns:<\/p>\n<ul>\n<li><strong>PID<\/strong>&nbsp;\u2013 l\u2019<a title=\"PID\" href=\"http:\/\/it.wikipedia.org\/wiki\/PID_%28Unix%29\" target=\"_blank\" rel=\"noopener\">ID<\/a>&nbsp;of the process(4522)<\/li>\n<li><strong>USER<\/strong>&nbsp;\u2013 The user that is the owner of the process (root)<\/li>\n<li><strong>PR<\/strong>&nbsp;\u2013 priority of the process (15)<\/li>\n<li><strong>NI<\/strong>&nbsp;\u2013 The \u201cNICE\u201d value of the process (0)<\/li>\n<li><strong>VIRT<\/strong>&nbsp;\u2013 virtual memory used by the process (132m)<\/li>\n<li><strong>RES<\/strong>&nbsp;\u2013 physical memory used from the process (14m)<\/li>\n<li><strong>SHR<\/strong>&nbsp;\u2013 shared memory of the process (3204)<\/li>\n<li><strong>S<\/strong>&nbsp;\u2013 indicates the status of the process:&nbsp;<strong>S<\/strong>=sleep&nbsp;<strong>R<\/strong>=running&nbsp;<strong>Z<\/strong>=zombie (S)<\/li>\n<li><strong>%CPU<\/strong>&nbsp;\u2013 This is the percentage of CPU used by this process (0.3)<\/li>\n<li><strong>%MEM<\/strong>&nbsp;\u2013 This is the percentage of RAM used by the process (0.7)<\/li>\n<li><strong>TIME+<\/strong>&nbsp;\u2013This is the total time of activity of this process (0:17.75)<\/li>\n<li><strong>COMMAND<\/strong>&nbsp;\u2013 And this is the name of the process (bb_monitor.pl)<\/li>\n<\/ul>\n<h3>Conclusions<\/h3>\n<p>Now that we have seen in detail all the information that the command \u201ctop\u201d returns, it will be easier to understand the reason of excessive load and\/or the slowing of the system.<\/p>\n<p>A good alternative to \u201c<strong> TOP <\/strong>\u201d is \u201c<a href=\"http:\/\/linuxaria.com\/article\/monitoring-process-top-htop?lang=en\"><strong> HTOP <\/strong><\/a>\u201c, an evolution of top with features really amazing.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Know what is happening in \u201creal time\u201d on your systems is in my opinion the basis to use and optimize your OS. On ArchLinux or&hellip; <\/p>\n","protected":false},"author":1,"featured_media":947,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[],"class_list":["post-903","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/zhuoyao.net\/index.php\/wp-json\/wp\/v2\/posts\/903","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/zhuoyao.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zhuoyao.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zhuoyao.net\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/zhuoyao.net\/index.php\/wp-json\/wp\/v2\/comments?post=903"}],"version-history":[{"count":1,"href":"https:\/\/zhuoyao.net\/index.php\/wp-json\/wp\/v2\/posts\/903\/revisions"}],"predecessor-version":[{"id":952,"href":"https:\/\/zhuoyao.net\/index.php\/wp-json\/wp\/v2\/posts\/903\/revisions\/952"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/zhuoyao.net\/index.php\/wp-json\/wp\/v2\/media\/947"}],"wp:attachment":[{"href":"https:\/\/zhuoyao.net\/index.php\/wp-json\/wp\/v2\/media?parent=903"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zhuoyao.net\/index.php\/wp-json\/wp\/v2\/categories?post=903"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zhuoyao.net\/index.php\/wp-json\/wp\/v2\/tags?post=903"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}