{"id":2196,"date":"2012-03-11T11:50:08","date_gmt":"2012-03-11T03:50:08","guid":{"rendered":"https:\/\/webhostinggeeks.com\/howto\/?p=2196"},"modified":"2023-06-23T12:51:52","modified_gmt":"2023-06-23T12:51:52","slug":"how-to-track-system-activity-with-top-command-on-linux-centos-5centos-6rhel-5-rhel-6-server-system-performance","status":"publish","type":"post","link":"https:\/\/webhostinggeeks.com\/howto\/how-to-track-system-activity-with-top-command-on-linux-centos-5centos-6rhel-5-rhel-6-server-system-performance\/","title":{"rendered":"How to Track System Activity with &#8220;top&#8221; Command on Linux CentOS (5\/6) and RHEL (5\/6)"},"content":{"rendered":"<p>In server administration, it&#8217;s crucial to have a comprehensive understanding of your system&#8217;s activity. This knowledge allows you to optimize performance, troubleshoot issues, and ensure the smooth operation of your <a href=\"https:\/\/webhostinggeeks.com\/blog\/what-are-web-servers-and-why-are-they-needed\/\">web server<\/a>. <\/p>\n<p>One of the most effective tools for this purpose is the top command, a utility that provides a dynamic, real-time view of a running system. It displays system summary information as well as a list of tasks currently managed by the Linux kernel.<\/p>\n<p>This guide will walk you through the usage of the top command on CentOS 5\/CentOS 6\/RHEL 5\/ RHEL 6 servers.<\/p>\n<p>For a more in-depth understanding of web server types, you may want to explore our articles on <a href=\"https:\/\/webhostinggeeks.com\/blog\/apache-http-server-explained\/\">Apache<\/a>, <a href=\"https:\/\/webhostinggeeks.com\/blog\/nginx-server-explained\/\">Nginx<\/a>, and <a href=\"https:\/\/webhostinggeeks.com\/blog\/litespeed-web-server-explained\/\">LiteSpeed<\/a>. Understanding the type of server you&#8217;re working with can greatly enhance your ability to optimize and troubleshoot it.<\/p>\n<h2>Using the `top` Command<\/h2>\n<p>The top command is a utility that allows you to monitor system activity interactively. When you run top from a shell window, it displays all active processes and updates the screen in real time. This is particularly useful for keeping track of system activity and optimizing system performance.<\/p>\n<p>To display the top command on RHEL 6, you would use the following command:<\/p>\n<pre>\r\n[root@rhel6 ~]# top\r\n<\/pre>\n<p>This will display a variety of information, including the total number of tasks, the number of running tasks, CPU usage, memory usage, and a list of all active processes.<\/p>\n<pre>\r\n[root@rhel6 ~]# top\r\ntop - 18:54:19 up 13:29,  2 users,  load average: 0.00, 0.00, 0.00\r\nTasks:  93 total,   1 running,  90 sleeping,   2 stopped,   0 zombie\r\nCpu(s):  0.0%us,  0.0%sy,  0.0%ni,100.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st\r\nMem:   1031320k total,   225804k used,   805516k free,    31120k buffers\r\nSwap:  2064376k total,        0k used,  2064376k free,   116716k cached\r\n\r\n  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND\r\n 1375 root      20   0 97768 9796 5768 S  0.3  0.9   0:03.43 httpd\r\n 3974 root      20   0  2632 1076  868 R  0.3  0.1   0:00.08 top\r\n    1 root      20   0  2828 1392 1196 S  0.0  0.1   0:01.81 init\r\n    2 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kthreadd\r\n    3 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 migration\/0\r\n    4 root      20   0     0    0    0 S  0.0  0.0   0:00.00 ksoftirqd\/0\r\n    5 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 watchdog\/0\r\n    6 root      20   0     0    0    0 S  0.0  0.0   0:00.25 events\/0\r\n    7 root      20   0     0    0    0 S  0.0  0.0   0:00.00 cpuset\r\n    8 root      20   0     0    0    0 S  0.0  0.0   0:00.00 khelper\r\n    9 root      20   0     0    0    0 S  0.0  0.0   0:00.00 netns\r\n   10 root      20   0     0    0    0 S  0.0  0.0   0:00.00 async\/mgr\r\n   11 root      20   0     0    0    0 S  0.0  0.0   0:00.00 pm\r\n   12 root      20   0     0    0    0 S  0.0  0.0   0:00.00 sync_supers\r\n   13 root      20   0     0    0    0 S  0.0  0.0   0:00.00 bdi-default\r\n   14 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kintegrityd\/0\r\n   15 root      20   0     0    0    0 S  0.0  0.0   0:00.02 kblockd\/0\r\n   16 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kacpid\r\n   17 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kacpi_notify\r\n   18 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kacpi_hotplug\r\n   19 root      20   0     0    0    0 S  0.0  0.0   0:00.01 ata\/0\r\n   20 root      20   0     0    0    0 S  0.0  0.0   0:00.00 ata_aux\r\n   21 root      20   0     0    0    0 S  0.0  0.0   0:00.00 ksuspend_usbd\r\n   22 root      20   0     0    0    0 S  0.0  0.0   0:00.00 khubd\r\n   23 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kseriod\r\n   25 root      20   0     0    0    0 S  0.0  0.0   0:00.00 khungtaskd\r\n   26 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kswapd0\r\n   27 root      25   5     0    0    0 S  0.0  0.0   0:00.00 ksmd\r\n   28 root      20   0     0    0    0 S  0.0  0.0   0:00.00 aio\/0\r\n   29 root      20   0     0    0    0 S  0.0  0.0   0:00.00 crypto\/0\r\n   34 root      20   0     0    0    0 S  0.0  0.0   0:00.00 pciehpd\r\n   36 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kpsmoused\r\n   37 root      20   0     0    0    0 S  0.0  0.0   0:00.00 usbhid_resumer\r\n   67 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kstriped\r\n  267 root      20   0     0    0    0 S  0.0  0.0   0:00.00 scsi_eh_0\r\n  268 root      20   0     0    0    0 S  0.0  0.0   0:00.00 scsi_eh_1\r\n  279 root      20   0     0    0    0 S  0.0  0.0   0:00.20 mpt_poll_0\r\n<\/pre>\n<h2>Adjusting the Update Interval<\/h2>\n<p>By default, top will update its screen every second. However, you can change this interval by using the d option followed by the number of seconds you want as the new interval. For example, to update the screen every 5 seconds, you would use the following command:<\/p>\n<pre>\r\n[root@rhel6 ~]# top d 5\r\n<\/pre>\n<pre>\r\n[root@rhel6 ~]# top d 5\r\ntop - 18:56:51 up 13:32,  2 users,  load average: 0.00, 0.00, 0.00\r\nTasks:  94 total,   1 running,  90 sleeping,   3 stopped,   0 zombie\r\nCpu(s):  0.0%us,  0.1%sy,  0.0%ni, 99.7%id,  0.2%wa,  0.0%hi,  0.0%si,  0.0%st\r\nMem:   1031320k total,   226064k used,   805256k free,    31136k buffers\r\nSwap:  2064376k total,        0k used,  2064376k free,   116716k cached\r\n<\/pre>\n<p>To update the screen every 10 seconds, you would use:<\/p>\n<pre>\r\n[root@rhel6 ~]# top d 10\r\n<\/pre>\n<pre>\r\n[root@rhel6 ~]# top d 10\r\ntop - 18:57:21 up 13:32,  2 users,  load average: 0.00, 0.00, 0.00\r\nTasks:  95 total,   1 running,  90 sleeping,   4 stopped,   0 zombie\r\nCpu(s):  0.0%us,  0.1%sy,  0.0%ni, 99.7%id,  0.2%wa,  0.0%hi,  0.0%si,  0.0%st\r\nMem:   1031320k total,   226448k used,   804872k free,    31144k buffers\r\nSwap:  2064376k total,        0k used,  2064376k free,   116716k cached\r\n<\/pre>\n<p>Updating the screen at an interval of 5 to 20 seconds is often more useful than the default setting of 1 second. This is because when top updates every second, it often lists itself in its own output as the main resource consumer.<\/p>\n<h2>Getting Help<\/h2>\n<p>If you need help while using top, you can press the h key while top is running to display a help screen.<\/p>\n<pre>\r\n  Z,B,E,e   Global: 'Z' colors; 'B' bold; 'E'\/'e' summary\/task memory scale\r\n  l,t,m     Toggle Summary: 'l' load avg; 't' task\/cpu stats; 'm' memory info\r\n  0,1,2,3,I Toggle: '0' zeros; '1\/2\/3' cpus or numa node views; 'I' Irix mode\r\n  f,F,X     Fields: 'f'\/'F' add\/remove\/order\/sort; 'X' increase fixed-width\r\n\r\n  L,&,<,> . Locate: 'L'\/'&' find\/again; Move sort column: '<'\/'>' left\/right\r\n  R,H,V,J . Toggle: 'R' Sort; 'H' Threads; 'V' Forest view; 'J' Num justify\r\n  c,i,S,j . Toggle: 'c' Cmd name\/line; 'i' Idle; 'S' Time; 'j' Str justify\r\n  x,y     . Toggle highlights: 'x' sort field; 'y' running tasks\r\n  z,b     . Toggle: 'z' color\/mono; 'b' bold\/reverse (only if 'x' or 'y')\r\n  u,U,o,O . Filter by: 'u'\/'U' effective\/any user; 'o'\/'O' other criteria\r\n  n,#,^O  . Set: 'n'\/'#' max tasks displayed; Show: Ctrl+'O' other filter(s)\r\n  C,...   . Toggle scroll coordinates msg for: up,down,left,right,home,end\r\n\r\n  k,r       Manipulate tasks: 'k' kill; 'r' renice\r\n  d or s    Set update interval\r\n  W,Y       Write configuration file 'W'; Inspect other output 'Y'\r\n  q         Quit\r\n<\/pre>\n<h2>Commands Mentioned<\/h2>\n<ul>\n<li><span class=\"fw-bold\">top<\/span> \u2013 Displays real-time system activity<\/li>\n<li><span class=\"fw-bold\">top -d [seconds]<\/span> \u2013 Changes the update interval of `top`<\/li>\n<\/ul>\n<h2>Conclusion<\/h2>\n<p>The top command is a powerful tool for server administrators, providing a real-time view of system activity and allowing for the optimization of system performance. By understanding how to use this command and adjust its settings, you can gain a comprehensive understanding of your server&#8217;s activity.<\/p>\n<p>This knowledge is crucial for troubleshooting issues, optimizing performance, and ensuring the smooth operation of your server. Whether you&#8217;re working with a <a href=\"https:\/\/webhostinggeeks.com\/blog\/what-is-dedicated-server-hosting\/\">dedicated server<\/a>, a <a href=\"https:\/\/webhostinggeeks.com\/blog\/what-is-vps-hosting\/\">VPS server<\/a>, <a href=\"https:\/\/webhostinggeeks.com\/blog\/what-is-cloud-hosting\/\">cloud hosting<\/a>, or <a href=\"https:\/\/webhostinggeeks.com\/blog\/what-is-shared-hosting\/\">shared hosting<\/a>, mastering the top command is a valuable skill for any webmaster or website administrator.<\/p>\n<p>Remember, the key to effective server administration is not just about knowing the right commands, but understanding how to interpret the data they provide. With the top command, you have a powerful tool at your disposal to monitor, analyze, and optimize your server&#8217;s performance.<\/p>\n<p>Happy server managing!<\/p>\n<h2>FAQ<\/h2>\n<ol itemscope itemtype=\"https:\/\/schema.org\/FAQPage\">\n<li itemscope itemprop=\"mainEntity\" itemtype=\"https:\/\/schema.org\/Question\">\n<p class=\"fw-bold\" itemprop=\"name\">What is the `top` command used for?<\/p>\n<p itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n                <span itemprop=\"text\">The `top` command is used to monitor system activity interactively. It provides a dynamic, real-time view of a running system, displaying system summary information and a list of tasks currently managed by the Linux kernel. This is particularly useful for keeping track of system activity and optimizing system performance.<\/span>\n            <\/p>\n<\/li>\n<li itemscope itemprop=\"mainEntity\" itemtype=\"https:\/\/schema.org\/Question\">\n<p class=\"fw-bold\" itemprop=\"name\">How can I change the update interval of the `top` command?<\/p>\n<p itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n                <span itemprop=\"text\">You can change the update interval of the `top` command by using the `d` option followed by the number of seconds you want as the new interval. For example, `top -d 5` will update the screen every 5 seconds.<\/span>\n            <\/p>\n<\/li>\n<li itemscope itemprop=\"mainEntity\" itemtype=\"https:\/\/schema.org\/Question\">\n<p class=\"fw-bold\" itemprop=\"name\">Why is it recommended to change the update interval of the `top` command?<\/p>\n<p itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n                <span itemprop=\"text\">Changing the update interval of the `top` command can prevent it from listing itself in its own output as the main resource consumer, which often happens when `top` updates every second (the default setting). Updating the screen at an interval of 5 to 20 seconds can provide a more useful view of system activity.<\/span>\n            <\/p>\n<\/li>\n<li itemscope itemprop=\"mainEntity\" itemtype=\"https:\/\/schema.org\/Question\">\n<p class=\"fw-bold\" itemprop=\"name\">What information does the `top` command display?<\/p>\n<p itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n                <span itemprop=\"text\">The `top` command displays a variety of information, including the total number of tasks, the number of running tasks, CPU usage, memory usage, and a list of all active processes. This information is updated in real time (or at the interval specified with the `d` option).<\/span>\n            <\/p>\n<\/li>\n<li itemscope itemprop=\"mainEntity\" itemtype=\"https:\/\/schema.org\/Question\">\n<p class=\"fw-bold\" itemprop=\"name\">How can I get help while using the `top` command?<\/p>\n<p itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n                <span itemprop=\"text\">If you need help while using the `top` command, you can press the `h` key while `top` is running to display a help screen. This screen provides a summary of the command&#8217;s options and how to use them.<\/span>\n            <\/p>\n<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>In server administration, it&#8217;s crucial to have a comprehensive understanding of your system&#8217;s activity. This knowledge allows you to optimize performance, troubleshoot issues, and ensure the smooth operation of your&#8230;<\/p>\n","protected":false},"author":6,"featured_media":323,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"wds_primary_category":0,"footnotes":""},"categories":[2055,2058],"tags":[1244,1251,1713,1715,1842],"class_list":["post-2196","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-centos","category-rhel","tag-centos","tag-centos-6","tag-rhel","tag-rhel-6","tag-top-command"],"_links":{"self":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/2196","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/comments?post=2196"}],"version-history":[{"count":0,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/2196\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media\/323"}],"wp:attachment":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media?parent=2196"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/categories?post=2196"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/tags?post=2196"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}