{"id":11291,"date":"2019-03-12T22:48:06","date_gmt":"2019-03-12T22:48:06","guid":{"rendered":"http:\/\/www.appservgrid.com\/paw92\/?p=11291"},"modified":"2019-03-12T22:48:06","modified_gmt":"2019-03-12T22:48:06","slug":"12-top-command-examples-in-linux","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/12\/12-top-command-examples-in-linux\/","title":{"rendered":"12 TOP Command Examples in Linux"},"content":{"rendered":"<p>This is the part of our on-going series of commands in Linux. We have covered basic\u00a0<a href=\"https:\/\/www.tecmint.com\/15-basic-ls-command-examples-in-linux\/\" target=\"_blank\" rel=\"noopener\">ls command<\/a>\u00a0and\u00a0<a href=\"https:\/\/www.tecmint.com\/13-basic-cat-command-examples-in-linux\/\" target=\"_blank\" rel=\"noopener\">cat command<\/a>. In this article, we are trying to explore\u00a0<strong>top<\/strong>\u00a0command which is one of the most frequently used commands in our daily system administrative jobs.\u00a0<strong>top<\/strong>\u00a0command displays processor activity of your Linux box and also displays tasks managed by kernel in real-time. It\u2019ll show processor and memory are being used and other information like running processes. This may help you to take correct action.\u00a0<strong>top<\/strong>\u00a0command found in UNIX-like operating systems.<\/p>\n<div id=\"attachment_973\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/08\/Linux-Top-Commands.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-973\" title=\"Linux Top Command Examples\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/08\/Linux-Top-Commands-300x194.png\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/08\/Linux-Top-Commands-300x194.png 300w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/08\/Linux-Top-Commands.png 425w\" alt=\"Linux Top Command Examples\" width=\"300\" height=\"194\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Linux Top Command Examples<\/p>\n<\/div>\n<p><strong>You might also be interested in following tutorials<\/strong>\u00a0:<\/p>\n<ol>\n<li><a href=\"https:\/\/www.tecmint.com\/install-htop-linux-process-monitoring-for-rhel-centos-fedora\/\" target=\"_blank\" rel=\"noopener\">Htop (Linux Process Monitoring) tool for RHEL, CentOS &amp; Fedora<\/a><\/li>\n<li><a href=\"https:\/\/www.tecmint.com\/install-iotop-monitor-linux-disk-io-in-rhel-centos-and-fedora\/\" target=\"_blank\" rel=\"noopener\">Iotop (Monitor Linux Disk I\/O) in RHEL, CentOS and Fedora<\/a><\/li>\n<\/ol>\n<h4>1. Display of Top Command<\/h4>\n<p>In this example, it will show information like\u00a0<strong>tasks<\/strong>,\u00a0<strong>memory<\/strong>,\u00a0<strong>cpu<\/strong>\u00a0and\u00a0<strong>swap<\/strong>. Press \u2018<strong>q<\/strong>\u2018 to quit window.<\/p>\n<pre><strong># top<\/strong><\/pre>\n<div id=\"attachment_961\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/08\/Top-Command.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-961\" title=\"Linux Top Command\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/08\/Top-Command.jpg\" sizes=\"auto, (max-width: 630px) 100vw, 630px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/08\/Top-Command.jpg 630w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/08\/Top-Command-300x204.jpg 300w\" alt=\"Linux Top Command\" width=\"630\" height=\"430\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Linux Top Command<\/p>\n<\/div>\n<h4>2. Sorting with -O (Uppercase Letter \u2018O\u2019).<\/h4>\n<p>Press (<strong>Shift+O<\/strong>) to Sort field via field letter, for example press \u2018<strong>a<\/strong>\u2018 letter to sort process with PID (<strong>Process ID<\/strong>).<\/p>\n<div id=\"attachment_962\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/08\/Top-Sort.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-962\" title=\"Sorting Process ID's with Top\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/08\/Top-Sort.jpg\" sizes=\"auto, (max-width: 630px) 100vw, 630px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/08\/Top-Sort.jpg 630w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/08\/Top-Sort-300x205.jpg 300w\" alt=\"Sorting Process ID's with Top\" width=\"630\" height=\"431\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Sorting Process ID\u2019s with Top<\/p>\n<\/div>\n<p>Type any key to return to main top window with sorted\u00a0<strong>PID<\/strong>\u00a0order as shown in below screen. Press \u2018<strong>q<\/strong>\u2018 to quit exit the window.<\/p>\n<div id=\"attachment_963\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/08\/Sort-with-PID.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-963\" title=\"Sorting Process ID's\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/08\/Sort-with-PID.jpg\" sizes=\"auto, (max-width: 630px) 100vw, 630px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/08\/Sort-with-PID.jpg 630w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/08\/Sort-with-PID-300x204.jpg 300w\" alt=\"Sorting Process ID's\" width=\"630\" height=\"429\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Sorting Process ID\u2019s<\/p>\n<\/div>\n<h4>3. Display Specific User Process<\/h4>\n<p>Use top command with \u2018<strong>u<\/strong>\u2018 option will display specific\u00a0<strong>User<\/strong>\u00a0process details.<\/p>\n<pre><strong># top -u tecmint<\/strong><\/pre>\n<div id=\"attachment_964\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/08\/Top-User-Process.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-964\" title=\"Top with Specific User Processes\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/08\/Top-User-Process.jpg\" sizes=\"auto, (max-width: 630px) 100vw, 630px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/08\/Top-User-Process.jpg 630w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/08\/Top-User-Process-300x204.jpg 300w\" alt=\"Top with Specific User Processes\" width=\"630\" height=\"430\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Top with Specific User Processes<\/p>\n<\/div>\n<h4>4. Highlight Running Process in Top<\/h4>\n<p>Press \u2018<strong>z<\/strong>\u2018 option in running top command will display running process in color which may help you to identified running process easily.<\/p>\n<div id=\"attachment_965\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/08\/Top-Colorful.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-965\" title=\"Top Process with Colorful\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/08\/Top-Colorful.png\" sizes=\"auto, (max-width: 630px) 100vw, 630px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/08\/Top-Colorful.png 630w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/08\/Top-Colorful-300x204.png 300w\" alt=\"Top Process with Colorful\" width=\"630\" height=\"430\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Top Process with Colorful<\/p>\n<\/div>\n<h4>5. Shows Absolute Path of Processes<\/h4>\n<p>Press \u2018<strong>c<\/strong>\u2018 option in running top command, it will display absolute path of running process.<\/p>\n<div id=\"attachment_966\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/08\/Top-command-with-Path.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-966\" title=\"Top with Specific Process Path\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/08\/Top-command-with-Path.jpg\" sizes=\"auto, (max-width: 630px) 100vw, 630px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/08\/Top-command-with-Path.jpg 630w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/08\/Top-command-with-Path-300x208.jpg 300w\" alt=\"Top with Specific Process Path\" width=\"630\" height=\"438\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Top with Specific Process Path<\/p>\n<\/div>\n<h4>6. Change Delay or Set \u2018Screen Refresh Interval\u2019 in Top<\/h4>\n<p>By default screen refresh interval is\u00a0<strong>3.0<\/strong>\u00a0seconds, same can be change pressing \u2018<strong>d<\/strong>\u2018 option in running top command and change it as desired as shown below.<\/p>\n<div id=\"attachment_967\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/08\/Top-Set-Refresh-Time.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-967\" title=\"Top - Set Refresh Time\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/08\/Top-Set-Refresh-Time.jpg\" sizes=\"auto, (max-width: 630px) 100vw, 630px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/08\/Top-Set-Refresh-Time.jpg 630w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/08\/Top-Set-Refresh-Time-300x210.jpg 300w\" alt=\"Top - Set Refresh Time\" width=\"630\" height=\"441\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Top \u2013 Set Refresh Time<\/p>\n<\/div>\n<h4>7. Kill running process with argument \u2018k\u2019<\/h4>\n<p>You can kill a process after finding\u00a0<strong>PID<\/strong>\u00a0of process by pressing \u2018<strong>k<\/strong>\u2018 option in running top command without exiting from top window as shown below.<\/p>\n<div id=\"attachment_968\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/08\/Top-Kill-Process.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-968\" title=\"Top - Kill Process ID\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/08\/Top-Kill-Process.jpg\" sizes=\"auto, (max-width: 630px) 100vw, 630px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/08\/Top-Kill-Process.jpg 630w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/08\/Top-Kill-Process-300x201.jpg 300w\" alt=\"Top - Kill Process ID\" width=\"630\" height=\"423\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Top \u2013 Kill Process ID<\/p>\n<\/div>\n<h4>8. Sort by CPU Utilisation<\/h4>\n<p>Press (<strong>Shift+P<\/strong>) to sort processes as per\u00a0<strong>CPU<\/strong>\u00a0utilization. See screenshot below.<\/p>\n<div id=\"attachment_969\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/08\/Top-With-CPU-Utilization.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-969\" title=\"Top - High CPU Utilization\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/08\/Top-With-CPU-Utilization.jpg\" sizes=\"auto, (max-width: 630px) 100vw, 630px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/08\/Top-With-CPU-Utilization.jpg 630w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/08\/Top-With-CPU-Utilization-300x201.jpg 300w\" alt=\"Top - High CPU Utilization\" width=\"630\" height=\"424\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Top \u2013 High CPU Utilization<\/p>\n<\/div>\n<h4>9. Renice a Process<\/h4>\n<p>You can use \u2018<strong>r<\/strong>\u2018 option to change the priority of the process also called Renice.<\/p>\n<div id=\"attachment_970\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/08\/Top-Renice-Process.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-970\" title=\"Top - Renice Process\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/08\/Top-Renice-Process.jpg\" sizes=\"auto, (max-width: 630px) 100vw, 630px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/08\/Top-Renice-Process.jpg 630w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/08\/Top-Renice-Process-300x202.jpg 300w\" alt=\"Top - Renice Process\" width=\"630\" height=\"425\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Top \u2013 Renice Process<\/p>\n<\/div>\n<h4>10. Save Top Command Results<\/h4>\n<p>To save the running top command results output to a file\u00a0<strong>\/root\/.toprc<\/strong>\u00a0use the following command.<\/p>\n<pre># top -n 1 -b &gt; top-output.txt\r\n<\/pre>\n<div id=\"attachment_971\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/08\/Top-Save-Results.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-971\" title=\"Top Command Save Results\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/08\/Top-Save-Results.jpg\" sizes=\"auto, (max-width: 630px) 100vw, 630px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/08\/Top-Save-Results.jpg 630w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/08\/Top-Save-Results-300x201.jpg 300w\" alt=\"Top Command Save Results\" width=\"630\" height=\"424\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Top Command Save Results<\/p>\n<\/div>\n<h4>11. Getting Top Command Help<\/h4>\n<p>Press \u2018<strong>h<\/strong>\u2018 option to obtain the top command help.<\/p>\n<div id=\"attachment_972\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/08\/Top-command-help.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-972\" title=\"Top Command Help\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/08\/Top-command-help.jpg\" sizes=\"auto, (max-width: 630px) 100vw, 630px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/08\/Top-command-help.jpg 630w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/08\/Top-command-help-300x202.jpg 300w\" alt=\"Top Command Help\" width=\"630\" height=\"425\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Top Command Help<\/p>\n<\/div>\n<h4>12. Exit Top Command After Specific repetition<\/h4>\n<p>Top output keep refreshing until you press \u2018<strong>q<\/strong>\u2018. With below command top command will automatically exit after 10 number of repetition.<\/p>\n<pre><strong># top -n 10<\/strong><\/pre>\n<p>There are number of arguments to know more about\u00a0<strong>top<\/strong>\u00a0command you may refer man page of\u00a0<strong>top<\/strong>\u00a0command.<\/p>\n<p><a href=\"https:\/\/www.tecmint.com\/12-top-command-examples-in-linux\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is the part of our on-going series of commands in Linux. We have covered basic\u00a0ls command\u00a0and\u00a0cat command. In this article, we are trying to explore\u00a0top\u00a0command which is one of the most frequently used commands in our daily system administrative jobs.\u00a0top\u00a0command displays processor activity of your Linux box and also displays tasks managed by kernel &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/12\/12-top-command-examples-in-linux\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;12 TOP Command Examples in Linux&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-11291","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/11291","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=11291"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/11291\/revisions"}],"predecessor-version":[{"id":11294,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/11291\/revisions\/11294"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=11291"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=11291"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=11291"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}