{"id":197,"date":"2024-01-24T02:21:48","date_gmt":"2024-01-24T02:21:48","guid":{"rendered":"https:\/\/chennaihosting.co.in\/kb\/?p=197"},"modified":"2024-01-24T03:23:00","modified_gmt":"2024-01-24T03:23:00","slug":"how-to-check-top-running-cpu-memory-usage","status":"publish","type":"post","link":"https:\/\/chennaihosting.co.in\/kb\/how-to-check-top-running-cpu-memory-usage\/","title":{"rendered":"Find top running CPU &#038; Memory usage in Linux"},"content":{"rendered":"\n<p>Memory and CPU usage in <a href=\"https:\/\/www.linux.org\/\" data-type=\"link\" data-id=\"https:\/\/www.linux.org\/\" target=\"_blank\" rel=\"noopener\">Linux <\/a>refer to the utilization of system resources, specifically RAM (Random Access Memory) and CPU (Central Processing Unit), respectively. <\/p>\n\n\n\n<p>Monitoring these metrics is essential for understanding the performance and health of a Linux system.<\/p>\n\n\n\n<div class=\"wp-block-rank-math-toc-block\" id=\"rank-math-toc\"><h2>Table of Contents<\/h2><nav><ul><li><a href=\"#memory-usage\">Memory Usage:<\/a><ul><li><a href=\"#memory-usage-tools\">Memory Usage Tools:<\/a><\/li><\/ul><\/li><li><a href=\"#cpu-usage\">CPU Usage:<\/a><ul><li><a href=\"#cpu-usage-tools\">CPU Usage Tools:<\/a><\/li><\/ul><\/li><li><a href=\"#check-top-processes-sorted-by-ram-or-cpu-usage-in-linux\">Check Top Processes sorted by RAM or CPU Usage in Linux<\/a><\/li><\/ul><\/nav><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"memory-usage\"><strong>Memory Usage:<\/strong><\/h2>\n\n\n\n<p>RAM (Random Access Memory): This is the volatile memory that the system uses to store data that is actively being used or processed by the CPU. It is faster than storage (like hard drives or SSDs) but is temporary and gets cleared when the system is powered off. <\/p>\n\n\n\n<p>Linux uses a combination of free RAM and swap space (a designated area on disk) to manage memory.<\/p>\n\n\n\n<p>To find the top running CPU and memory usage in a Linux web <a href=\"https:\/\/chennaihosting.co.in\/vps-hosting-chennai.html\" data-type=\"link\" data-id=\"https:\/\/chennaihosting.co.in\/vps-hosting-chennai.html\">hosting environment<\/a>, you can use various command-line tools or monitoring applications.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"memory-usage-tools\">Memory Usage Tools:<\/h3>\n\n\n\n<p>The <strong>free <\/strong>command provides information about total, used, and free memory.<\/p>\n\n\n\n<p>free -m<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"85\" src=\"https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2024\/01\/image-5-1024x85.png\" alt=\"\" class=\"wp-image-210\" srcset=\"https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2024\/01\/image-5-1024x85.png 1024w, https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2024\/01\/image-5-300x25.png 300w, https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2024\/01\/image-5-768x64.png 768w, https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2024\/01\/image-5.png 1473w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>The <strong>top <\/strong>command displays real-time information about system resource usage, including memory.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>top<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"608\" src=\"https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2024\/01\/image-3-1024x608.png\" alt=\"\" class=\"wp-image-206\" srcset=\"https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2024\/01\/image-3-1024x608.png 1024w, https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2024\/01\/image-3-300x178.png 300w, https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2024\/01\/image-3-768x456.png 768w, https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2024\/01\/image-3-1536x912.png 1536w, https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2024\/01\/image-3.png 1616w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>The <strong>htop <\/strong>command is an enhanced version of top with a more user-friendly interface.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>htop<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"439\" src=\"https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2024\/01\/image-6-1024x439.png\" alt=\"\" class=\"wp-image-212\" srcset=\"https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2024\/01\/image-6-1024x439.png 1024w, https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2024\/01\/image-6-300x129.png 300w, https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2024\/01\/image-6-768x329.png 768w, https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2024\/01\/image-6-1536x659.png 1536w, https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2024\/01\/image-6.png 1893w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>The ps command can be used to list processes and sort them based on different criteria.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ps aux --sort=-%mem | head -n 11\n<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"226\" src=\"https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2024\/01\/image-8-1024x226.png\" alt=\"\" class=\"wp-image-214\" srcset=\"https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2024\/01\/image-8-1024x226.png 1024w, https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2024\/01\/image-8-300x66.png 300w, https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2024\/01\/image-8-768x170.png 768w, https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2024\/01\/image-8-1536x339.png 1536w, https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2024\/01\/image-8.png 1896w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"cpu-usage\">CPU Usage:<\/h2>\n\n\n\n<p>The <strong>CPU <\/strong>is the brain of the computer, responsible for executing instructions and processing data. Monitoring CPU usage is crucial for understanding how much processing power is being utilized.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"cpu-usage-tools\">CPU Usage Tools:<\/h3>\n\n\n\n<p>CPU usage tools are software applications or commands in Linux that help users and system administrators monitor and analyze the utilization of the Central Processing Unit (CPU) in a computer system. <\/p>\n\n\n\n<p>These tools provide insights into how much of the CPU&#8217;s processing power is being used by various processes and applications.<\/p>\n\n\n\n<p>High CPU usage by a single program may indicate that it is highly demanding of processing power or that it may malfunction; for example, it has entered an\u00a0infinite loop.<\/p>\n\n\n\n<p>The <strong>top <\/strong>command also provides information about CPU usage in addition to memory usage.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>top<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"612\" src=\"https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2024\/01\/image-4-1024x612.png\" alt=\"\" class=\"wp-image-208\" srcset=\"https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2024\/01\/image-4-1024x612.png 1024w, https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2024\/01\/image-4-300x179.png 300w, https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2024\/01\/image-4-768x459.png 768w, https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2024\/01\/image-4-1536x918.png 1536w, https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2024\/01\/image-4.png 1565w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>The <strong>htop <\/strong>command shows CPU usage as well.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>htop<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"439\" src=\"https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2024\/01\/image-7-1024x439.png\" alt=\"\" class=\"wp-image-213\" srcset=\"https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2024\/01\/image-7-1024x439.png 1024w, https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2024\/01\/image-7-300x129.png 300w, https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2024\/01\/image-7-768x329.png 768w, https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2024\/01\/image-7-1536x658.png 1536w, https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2024\/01\/image-7.png 1893w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>The <strong>mpstat <\/strong>command provides detailed information about CPU usage.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mpstat<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"92\" src=\"https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2024\/01\/mpstat-1-1024x92.jpg\" alt=\"\" class=\"wp-image-216\" srcset=\"https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2024\/01\/mpstat-1-1024x92.jpg 1024w, https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2024\/01\/mpstat-1-300x27.jpg 300w, https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2024\/01\/mpstat-1-768x69.jpg 768w, https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2024\/01\/mpstat-1-1536x138.jpg 1536w, https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2024\/01\/mpstat-1.jpg 1700w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>The <strong>sar<\/strong> command (System Activity Report) can be used for comprehensive system resource monitoring.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sar<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"256\" src=\"https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2024\/01\/sar-1024x256.jpg\" alt=\"\" class=\"wp-image-217\" srcset=\"https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2024\/01\/sar-1024x256.jpg 1024w, https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2024\/01\/sar-300x75.jpg 300w, https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2024\/01\/sar-768x192.jpg 768w, https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2024\/01\/sar-1536x385.jpg 1536w, https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2024\/01\/sar.jpg 1681w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>It&#8217;s important to note that there are various graphical tools and system monitoring applications available that provide a more user-friendly interface for monitoring both memory and CPU usage. Additionally, monitoring tools may vary slightly depending on the Linux distribution in use.<\/p>\n\n\n\n<p>The <strong>ps <\/strong>command can be used to list processes and sort by CPU usage<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ps aux --sort=-%cpu | head -n 11<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"210\" src=\"https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2024\/01\/image-9-1024x210.png\" alt=\"\" class=\"wp-image-218\" srcset=\"https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2024\/01\/image-9-1024x210.png 1024w, https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2024\/01\/image-9-300x62.png 300w, https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2024\/01\/image-9-768x158.png 768w, https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2024\/01\/image-9-1536x315.png 1536w, https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2024\/01\/image-9.png 1895w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"check-top-processes-sorted-by-ram-or-cpu-usage-in-linux\">Check Top Processes sorted by RAM or CPU Usage in Linux<\/h2>\n\n\n\n<p>The following command will show the list of top processes ordered by RAM and CPU use in descendant form (remove the&nbsp;<strong>pipeline<\/strong>&nbsp;and&nbsp;<strong>head<\/strong>&nbsp;if you want to see the full list):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%mem | head<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"246\" src=\"https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2024\/01\/image-10-1024x246.png\" alt=\"\" class=\"wp-image-219\" srcset=\"https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2024\/01\/image-10-1024x246.png 1024w, https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2024\/01\/image-10-300x72.png 300w, https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2024\/01\/image-10-768x184.png 768w, https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2024\/01\/image-10.png 1397w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>The -o (or \u2013format) option of ps allows you to specify the output format. A favorite of mine is to show the processes\u2019 PIDs (pid), PPIDs (pid), the name of the executable file associated with the process (cmd), and the RAM and CPU utilization (%mem and %cpu, respectively).<\/p>\n\n\n\n<p>Additionally, I use &#8211;sort to sort by either %mem or %cpu. By default, the output will be sorted in ascendant form, but personally I prefer to reverse that order by adding a minus sign in front of the sort criteria.<\/p>\n\n\n\n<p>To add other fields to the output, or change the sort criteria, refer to the OUTPUT FORMAT CONTROL section in the man page of ps command.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Memory and CPU usage in Linux refer to the utilization [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":229,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[14,15],"class_list":["post-197","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","tag-cpu","tag-memory"],"_links":{"self":[{"href":"https:\/\/chennaihosting.co.in\/kb\/wp-json\/wp\/v2\/posts\/197","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/chennaihosting.co.in\/kb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/chennaihosting.co.in\/kb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/chennaihosting.co.in\/kb\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/chennaihosting.co.in\/kb\/wp-json\/wp\/v2\/comments?post=197"}],"version-history":[{"count":14,"href":"https:\/\/chennaihosting.co.in\/kb\/wp-json\/wp\/v2\/posts\/197\/revisions"}],"predecessor-version":[{"id":232,"href":"https:\/\/chennaihosting.co.in\/kb\/wp-json\/wp\/v2\/posts\/197\/revisions\/232"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/chennaihosting.co.in\/kb\/wp-json\/wp\/v2\/media\/229"}],"wp:attachment":[{"href":"https:\/\/chennaihosting.co.in\/kb\/wp-json\/wp\/v2\/media?parent=197"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/chennaihosting.co.in\/kb\/wp-json\/wp\/v2\/categories?post=197"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/chennaihosting.co.in\/kb\/wp-json\/wp\/v2\/tags?post=197"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}