{"id":195,"date":"2021-07-28T09:14:57","date_gmt":"2021-07-28T09:14:57","guid":{"rendered":"https:\/\/www.cyberrafting.com\/blog\/?p=195"},"modified":"2021-07-28T09:15:37","modified_gmt":"2021-07-28T09:15:37","slug":"top-command","status":"publish","type":"post","link":"https:\/\/www.cyberrafting.com\/blog\/linux\/top-command\/","title":{"rendered":"Useful Linux Top Command"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">This is part of our ongoing series of Linux commands. We&#8217;ve already gone over the ls and cat commands. In this article, we will look at the top command, which is one of the most commonly used commands in our day-to-day system administration tasks. The top command displays the processor activity of your Linux box as well as real-time tasks managed by the kernel. It will display the processor and memory usage, as well as other information such as running processes. This may assist you in taking corrective action\u2014the most important command in UNIX-like operating systems.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>1. Display of Top Command<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">In this case, it will display information such as tasks, memory, CPU, and swap. To close the window, press &#8216;q&#8217;.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># top<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>2. Sorting with -O (Uppercase Letter \u2018O\u2019)<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Press (Shift+O) to Sort field by field letter, for example, to sort process with PID (Process ID).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To return to the main top window with sorted PID order, press any key, as shown in the screen below. To exit the window, press &#8216;q&#8217;.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>3. Display Specific User Process<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Using the top command with the \u2018u\u2018 option will display details about specific User processes.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># top -u tecmint<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>4. Highlight Running Process in Top<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">When running the top command, pressing the \u2018z\u2018 option will display the running process in colour, which may help you identify the running process more easily.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>5. Shows Absolute Path of Processes<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">When running the top command, press the \u2018c\u2018 option to display the absolute path of the running process.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>6. Change Delay or Set \u2018Screen Refresh Interval\u2019 in Top<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The screen refresh interval is set to 3.0 seconds by default, but this can be changed by pressing the \u2018d\u2018 option while running the top command and changing it as desired.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>7. Kill running process with argument \u2018k\u2019<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">You can kill a process after determining its PID by pressing the \u2018k\u2018 option while running the top command without exiting the top window.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>8. Sort by CPU Utilisation<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">To sort processes by CPU utilisation, press (Shift+P).<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>9. Renice a Process<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The &#8216;r&#8217; option can be used to change the priority of the Renice process.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>10. Save Top Command Results<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Use the following command to save the output of the top running command to the file \/root\/.toprc.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># top -n 1 -b &gt; top-output.txt<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>11. Getting Top Command Help<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">To get top command help, press the &#8216;h&#8217; key.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>12. Exit Top Command After Specific repetition<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The top output will continue to refresh until you press the \u2018q&#8217; key. With the following command, the top command will exit after ten repetitions.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># top -n 10<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>This is part of our ongoing series of Linux commands. We&#8217;ve already gone over the ls and cat commands. In this article, we will look &hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[],"class_list":["post-195","post","type-post","status-publish","format-standard","hentry","category-linux"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.6 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Useful Linux Top Command<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.cyberrafting.com\/blog\/linux\/top-command\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Useful Linux Top Command\" \/>\n<meta property=\"og:description\" content=\"This is part of our ongoing series of Linux commands. We&#8217;ve already gone over the ls and cat commands. In this article, we will look &hellip;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.cyberrafting.com\/blog\/linux\/top-command\/\" \/>\n<meta property=\"og:site_name\" content=\"Cyber Rafting\" \/>\n<meta property=\"article:published_time\" content=\"2021-07-28T09:14:57+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-07-28T09:15:37+00:00\" \/>\n<meta name=\"author\" content=\"cyberrafting\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"cyberrafting\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.cyberrafting.com\\\/blog\\\/linux\\\/top-command\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.cyberrafting.com\\\/blog\\\/linux\\\/top-command\\\/\"},\"author\":{\"name\":\"cyberrafting\",\"@id\":\"https:\\\/\\\/www.cyberrafting.com\\\/blog\\\/#\\\/schema\\\/person\\\/0533280d6685c57435a3151c387fff99\"},\"headline\":\"Useful Linux Top Command\",\"datePublished\":\"2021-07-28T09:14:57+00:00\",\"dateModified\":\"2021-07-28T09:15:37+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.cyberrafting.com\\\/blog\\\/linux\\\/top-command\\\/\"},\"wordCount\":414,\"commentCount\":0,\"articleSection\":[\"Linux\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.cyberrafting.com\\\/blog\\\/linux\\\/top-command\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.cyberrafting.com\\\/blog\\\/linux\\\/top-command\\\/\",\"url\":\"https:\\\/\\\/www.cyberrafting.com\\\/blog\\\/linux\\\/top-command\\\/\",\"name\":\"Useful Linux Top Command\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.cyberrafting.com\\\/blog\\\/#website\"},\"datePublished\":\"2021-07-28T09:14:57+00:00\",\"dateModified\":\"2021-07-28T09:15:37+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.cyberrafting.com\\\/blog\\\/#\\\/schema\\\/person\\\/0533280d6685c57435a3151c387fff99\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.cyberrafting.com\\\/blog\\\/linux\\\/top-command\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.cyberrafting.com\\\/blog\\\/linux\\\/top-command\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.cyberrafting.com\\\/blog\\\/linux\\\/top-command\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.cyberrafting.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Useful Linux Top Command\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.cyberrafting.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.cyberrafting.com\\\/blog\\\/\",\"name\":\"Cyber Rafting Blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.cyberrafting.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.cyberrafting.com\\\/blog\\\/#\\\/schema\\\/person\\\/0533280d6685c57435a3151c387fff99\",\"name\":\"cyberrafting\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/c1f1c30a5a84d51fe015a59038822cd67358fd7fa1e202f74b946af36798f286?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/c1f1c30a5a84d51fe015a59038822cd67358fd7fa1e202f74b946af36798f286?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/c1f1c30a5a84d51fe015a59038822cd67358fd7fa1e202f74b946af36798f286?s=96&d=mm&r=g\",\"caption\":\"cyberrafting\"},\"sameAs\":[\"https:\\\/\\\/www.cyberrafting.com\\\/blog\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Useful Linux Top Command","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.cyberrafting.com\/blog\/linux\/top-command\/","og_locale":"en_US","og_type":"article","og_title":"Useful Linux Top Command","og_description":"This is part of our ongoing series of Linux commands. We&#8217;ve already gone over the ls and cat commands. In this article, we will look &hellip;","og_url":"https:\/\/www.cyberrafting.com\/blog\/linux\/top-command\/","og_site_name":"Cyber Rafting","article_published_time":"2021-07-28T09:14:57+00:00","article_modified_time":"2021-07-28T09:15:37+00:00","author":"cyberrafting","twitter_card":"summary_large_image","twitter_misc":{"Written by":"cyberrafting","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.cyberrafting.com\/blog\/linux\/top-command\/#article","isPartOf":{"@id":"https:\/\/www.cyberrafting.com\/blog\/linux\/top-command\/"},"author":{"name":"cyberrafting","@id":"https:\/\/www.cyberrafting.com\/blog\/#\/schema\/person\/0533280d6685c57435a3151c387fff99"},"headline":"Useful Linux Top Command","datePublished":"2021-07-28T09:14:57+00:00","dateModified":"2021-07-28T09:15:37+00:00","mainEntityOfPage":{"@id":"https:\/\/www.cyberrafting.com\/blog\/linux\/top-command\/"},"wordCount":414,"commentCount":0,"articleSection":["Linux"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.cyberrafting.com\/blog\/linux\/top-command\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.cyberrafting.com\/blog\/linux\/top-command\/","url":"https:\/\/www.cyberrafting.com\/blog\/linux\/top-command\/","name":"Useful Linux Top Command","isPartOf":{"@id":"https:\/\/www.cyberrafting.com\/blog\/#website"},"datePublished":"2021-07-28T09:14:57+00:00","dateModified":"2021-07-28T09:15:37+00:00","author":{"@id":"https:\/\/www.cyberrafting.com\/blog\/#\/schema\/person\/0533280d6685c57435a3151c387fff99"},"breadcrumb":{"@id":"https:\/\/www.cyberrafting.com\/blog\/linux\/top-command\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.cyberrafting.com\/blog\/linux\/top-command\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.cyberrafting.com\/blog\/linux\/top-command\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.cyberrafting.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Useful Linux Top Command"}]},{"@type":"WebSite","@id":"https:\/\/www.cyberrafting.com\/blog\/#website","url":"https:\/\/www.cyberrafting.com\/blog\/","name":"Cyber Rafting Blog","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.cyberrafting.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.cyberrafting.com\/blog\/#\/schema\/person\/0533280d6685c57435a3151c387fff99","name":"cyberrafting","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/c1f1c30a5a84d51fe015a59038822cd67358fd7fa1e202f74b946af36798f286?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/c1f1c30a5a84d51fe015a59038822cd67358fd7fa1e202f74b946af36798f286?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/c1f1c30a5a84d51fe015a59038822cd67358fd7fa1e202f74b946af36798f286?s=96&d=mm&r=g","caption":"cyberrafting"},"sameAs":["https:\/\/www.cyberrafting.com\/blog"]}]}},"_links":{"self":[{"href":"https:\/\/www.cyberrafting.com\/blog\/wp-json\/wp\/v2\/posts\/195","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.cyberrafting.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cyberrafting.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cyberrafting.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cyberrafting.com\/blog\/wp-json\/wp\/v2\/comments?post=195"}],"version-history":[{"count":1,"href":"https:\/\/www.cyberrafting.com\/blog\/wp-json\/wp\/v2\/posts\/195\/revisions"}],"predecessor-version":[{"id":196,"href":"https:\/\/www.cyberrafting.com\/blog\/wp-json\/wp\/v2\/posts\/195\/revisions\/196"}],"wp:attachment":[{"href":"https:\/\/www.cyberrafting.com\/blog\/wp-json\/wp\/v2\/media?parent=195"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cyberrafting.com\/blog\/wp-json\/wp\/v2\/categories?post=195"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cyberrafting.com\/blog\/wp-json\/wp\/v2\/tags?post=195"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}