{"id":167,"date":"2024-02-03T08:23:27","date_gmt":"2024-02-03T08:23:27","guid":{"rendered":"https:\/\/fatreseller.in\/blog\/?p=167"},"modified":"2024-02-03T08:23:30","modified_gmt":"2024-02-03T08:23:30","slug":"commonly-used-7-memory-usage-linux-commands","status":"publish","type":"post","link":"https:\/\/fatreseller.in\/blog\/commonly-used-7-memory-usage-linux-commands\/","title":{"rendered":"Commonly used 7 Memory Usage Linux Commands"},"content":{"rendered":"\n<p>In Linux, monitoring memory usage is crucial for system administrators to ensure optimal performance and troubleshoot potential issues. One commonly used command is <code>free<\/code>, which provides a concise overview of total, used, and free memory. The <code>top<\/code> command offers real-time insights into various system resources, including memory usage, while its more user-friendly counterpart, <code>htop<\/code>, presents a visually appealing and interactive display. <\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"474\" height=\"223\" src=\"https:\/\/fatreseller.in\/blog\/wp-content\/uploads\/2024\/02\/check-memory-usage-with-RAM1.jpg\" alt=\"linux\" class=\"wp-image-186\" srcset=\"https:\/\/fatreseller.in\/blog\/wp-content\/uploads\/2024\/02\/check-memory-usage-with-RAM1.jpg 474w, https:\/\/fatreseller.in\/blog\/wp-content\/uploads\/2024\/02\/check-memory-usage-with-RAM1-300x141.jpg 300w\" sizes=\"(max-width: 474px) 100vw, 474px\" \/><\/figure><\/div>\n\n\n<p>For a detailed examination of a specific process&#8217;s memory consumption, the <code>pmap<\/code> command allows users to inspect the memory map. Additionally, the <code>vmstat<\/code> command provides comprehensive information about processes, memory, and CPU activity. For a sorted list of processes based on memory usage, the <code>ps<\/code> command can be utilized with the <code>--sort=-%mem<\/code> option. For a more sophisticated and accurate memory usage report, the <code>smem<\/code> tool is available, though it might need to be installed using the package manager. These commands empower Linux users to monitor and manage memory resources effectively, ensuring the smooth operation of their systems.<\/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=\"#free-memory-usage-command-in-linux\">free\u00a0memory usage command in linux<\/a><\/li><li><a href=\"#top-command-in-linux\">top command in linux<\/a><\/li><li><a href=\"#htop-command-in-linux\">htop command in linux<\/a><\/li><li><a href=\"#vmstat-command-in-linux\">vmstat command in linux<\/a><\/li><li><a href=\"#pmap-command-in-linux\">pmap command in linux<\/a><\/li><li><a href=\"#ps-command-in-linux\">ps command in linux<\/a><\/li><li><a href=\"#smem-command-in-linux\">smem command in linux<\/a><\/li><\/ul><\/nav><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"free-memory-usage-command-in-linux\"><strong><strong>free<\/strong>&nbsp;memory usage command<\/strong> in linux<\/h2>\n\n\n\n<p>Displays information about total, used, and free memory.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">free -h<\/pre>\n\n\n\n<p>The <code>-h<\/code> option is used to display the information in a human-readable format.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1021\" height=\"65\" src=\"https:\/\/fatreseller.in\/blog\/wp-content\/uploads\/2024\/02\/free.png\" alt=\"\" class=\"wp-image-172\" srcset=\"https:\/\/fatreseller.in\/blog\/wp-content\/uploads\/2024\/02\/free.png 1021w, https:\/\/fatreseller.in\/blog\/wp-content\/uploads\/2024\/02\/free-300x19.png 300w, https:\/\/fatreseller.in\/blog\/wp-content\/uploads\/2024\/02\/free-768x49.png 768w\" sizes=\"(max-width: 1021px) 100vw, 1021px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"top-command-in-linux\"><strong>top<\/strong> <strong>command<\/strong> in linux<\/h2>\n\n\n\n<p>Provides real-time information about system resources, including memory usage.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">top<\/pre>\n\n\n\n<p>Press <code>q<\/code> to exit the <code>top<\/code> command.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"932\" height=\"582\" src=\"https:\/\/fatreseller.in\/blog\/wp-content\/uploads\/2024\/02\/top.png\" alt=\"\" class=\"wp-image-173\" srcset=\"https:\/\/fatreseller.in\/blog\/wp-content\/uploads\/2024\/02\/top.png 932w, https:\/\/fatreseller.in\/blog\/wp-content\/uploads\/2024\/02\/top-300x187.png 300w, https:\/\/fatreseller.in\/blog\/wp-content\/uploads\/2024\/02\/top-768x480.png 768w\" sizes=\"(max-width: 932px) 100vw, 932px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"htop-command-in-linux\"><strong>htop<\/strong> <strong>command<\/strong> in linux<\/h2>\n\n\n\n<p>A more user-friendly and feature-rich alternative to <code>top<\/code>.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">htop<\/pre>\n\n\n\n<p>Similar to <code>top<\/code>, press <code>q<\/code> to exit <code>htop<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"vmstat-command-in-linux\"><strong>vmstat<\/strong> <strong>command<\/strong> in linux<\/h2>\n\n\n\n<p>Reports information about processes, memory, paging, block IO, traps, and CPU activity.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">vmstat 1<\/pre>\n\n\n\n<p>The <code>1<\/code> specifies the update interval in seconds. You can adjust it as needed.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"712\" height=\"577\" src=\"https:\/\/fatreseller.in\/blog\/wp-content\/uploads\/2024\/02\/vmstat.png\" alt=\"\" class=\"wp-image-174\" srcset=\"https:\/\/fatreseller.in\/blog\/wp-content\/uploads\/2024\/02\/vmstat.png 712w, https:\/\/fatreseller.in\/blog\/wp-content\/uploads\/2024\/02\/vmstat-300x243.png 300w\" sizes=\"(max-width: 712px) 100vw, 712px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"pmap-command-in-linux\"><strong>pmap<\/strong> <strong>command<\/strong> in linux<\/h2>\n\n\n\n<p>Displays the memory map of a process or processes.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">pmap<\/pre>\n\n\n\n<p>Replace <code>&lt;pid&gt;<\/code> with the process ID you want to examine.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"512\" height=\"512\" src=\"https:\/\/fatreseller.in\/blog\/wp-content\/uploads\/2024\/02\/2703588.png\" alt=\"\" class=\"wp-image-177\" srcset=\"https:\/\/fatreseller.in\/blog\/wp-content\/uploads\/2024\/02\/2703588.png 512w, https:\/\/fatreseller.in\/blog\/wp-content\/uploads\/2024\/02\/2703588-300x300.png 300w, https:\/\/fatreseller.in\/blog\/wp-content\/uploads\/2024\/02\/2703588-150x150.png 150w\" sizes=\"(max-width: 512px) 100vw, 512px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"ps-command-in-linux\"><strong>ps command<\/strong> in linux<\/h2>\n\n\n\n<p>Provides information about processes, including their memory usage.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">ps aux --sort=-%mem<\/pre>\n\n\n\n<p>This command lists processes sorted by memory usage, showing the highest usage first.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1021\" height=\"441\" src=\"https:\/\/fatreseller.in\/blog\/wp-content\/uploads\/2024\/02\/ps.png\" alt=\"\" class=\"wp-image-175\" srcset=\"https:\/\/fatreseller.in\/blog\/wp-content\/uploads\/2024\/02\/ps.png 1021w, https:\/\/fatreseller.in\/blog\/wp-content\/uploads\/2024\/02\/ps-300x130.png 300w, https:\/\/fatreseller.in\/blog\/wp-content\/uploads\/2024\/02\/ps-768x332.png 768w\" sizes=\"(max-width: 1021px) 100vw, 1021px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"smem-command-in-linux\"><strong>smem<\/strong> <strong>command<\/strong> in linux<\/h2>\n\n\n\n<p>A report generator tool that provides a more detailed and accurate report of memory usage.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">smem<\/pre>\n\n\n\n<p>You may need to install <code>smem<\/code> using your package manager before using it.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"343\" src=\"https:\/\/fatreseller.in\/blog\/wp-content\/uploads\/2024\/02\/memory-usage-1024x343.jpg\" alt=\"\" class=\"wp-image-182\" srcset=\"https:\/\/fatreseller.in\/blog\/wp-content\/uploads\/2024\/02\/memory-usage-1024x343.jpg 1024w, https:\/\/fatreseller.in\/blog\/wp-content\/uploads\/2024\/02\/memory-usage-300x100.jpg 300w, https:\/\/fatreseller.in\/blog\/wp-content\/uploads\/2024\/02\/memory-usage-768x257.jpg 768w, https:\/\/fatreseller.in\/blog\/wp-content\/uploads\/2024\/02\/memory-usage-1536x514.jpg 1536w, https:\/\/fatreseller.in\/blog\/wp-content\/uploads\/2024\/02\/memory-usage-2048x686.jpg 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Memory usage commands in Linux provide valuable information about the system&#8217;s memory utilization, helping administrators and users monitor and manage system performance. Here are some advantages of using memory usage commands in Linux:<\/p>\n\n\n\n<p><strong>Resource Monitoring:<\/strong><\/p>\n\n\n\n<p>Commands like <code>free<\/code>, <code>top<\/code>, and <code>htop<\/code> allow users to monitor real-time memory usage. They display information such as total, used, and free memory, as well as swap usage.<\/p>\n\n\n\n<p><strong>Identifying Performance Issues:<\/strong><\/p>\n\n\n\n<p>Memory usage commands help identify performance issues caused by excessive memory consumption. By regularly checking memory usage, administrators can detect potential problems and take corrective actions before they impact system performance.<\/p>\n\n\n\n<p><strong>Troubleshooting:<\/strong><\/p>\n\n\n\n<p>When a system experiences slowdowns or becomes unresponsive, checking memory usage can help pinpoint the source of the issue. Commands like <code>ps<\/code> and <code>pmap<\/code> can be used to analyze the memory consumption of individual processes.<\/p>\n\n\n\n<p><strong>Capacity Planning:<\/strong><\/p>\n\n\n\n<p>Memory usage commands assist in capacity planning by providing insights into how much memory is currently in use and how much is available. This information is crucial for determining whether additional resources are needed or if existing resources are underutilized.<\/p>\n\n\n\n<p><strong>Process Management:<\/strong><\/p>\n\n\n\n<p>Commands like <code>kill<\/code> and <code>pkill<\/code> can be used to terminate specific processes that are consuming excessive memory. This is especially useful for preventing memory leaks or addressing issues with poorly optimized applications.<\/p>\n\n\n\n<p><strong>Monitoring Trends:<\/strong><\/p>\n\n\n\n<p>Memory usage commands can be used to track memory usage trends over time. By analyzing historical data, administrators can identify patterns and make informed decisions about system upgrades or adjustments.<\/p>\n\n\n\n<p><strong>Understanding Virtual Memory:<\/strong><\/p>\n\n\n\n<p>Commands like <code>vmstat<\/code> provide information about virtual memory usage, including swap space utilization. This helps in understanding how the system is managing memory resources beyond physical RAM.<\/p>\n\n\n\n<p><strong>User and Application Behavior:<\/strong><\/p>\n\n\n\n<p>Memory usage commands help administrators understand how different users and applications are utilizing <a href=\"https:\/\/fatreseller.in\/vps-hosting.html\">system <\/a>resources. This information is valuable for optimizing resource allocation and ensuring fair usage among multiple users.<\/p>\n\n\n\n<p><strong>Preventing Out-of-Memory Issues:<\/strong><\/p>\n\n\n\n<p>Regularly monitoring memory usage allows administrators to proactively address potential out-of-memory situations. By being aware of memory constraints, they can implement preventive measures or allocate additional resources as needed.<\/p>\n\n\n\n<p><strong>Integration with Monitoring Systems:<\/strong><\/p>\n\n\n\n<p>Memory usage commands provide data that can be integrated into monitoring systems for automated alerting and reporting. This facilitates a proactive approach to system management by notifying administrators of abnormal memory usage patterns.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In Linux, monitoring memory usage is crucial for system administrators to ensure optimal performance and troubleshoot potential issues. One commonly used command is free, which provides a concise overview of total, used, and free memory. The top command offers real-time insights into various system resources, including memory usage, while its more user-friendly counterpart, htop, presents [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":188,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21],"tags":[20,19],"class_list":["post-167","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","tag-linux","tag-memory"],"_links":{"self":[{"href":"https:\/\/fatreseller.in\/blog\/wp-json\/wp\/v2\/posts\/167"}],"collection":[{"href":"https:\/\/fatreseller.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fatreseller.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fatreseller.in\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/fatreseller.in\/blog\/wp-json\/wp\/v2\/comments?post=167"}],"version-history":[{"count":13,"href":"https:\/\/fatreseller.in\/blog\/wp-json\/wp\/v2\/posts\/167\/revisions"}],"predecessor-version":[{"id":189,"href":"https:\/\/fatreseller.in\/blog\/wp-json\/wp\/v2\/posts\/167\/revisions\/189"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/fatreseller.in\/blog\/wp-json\/wp\/v2\/media\/188"}],"wp:attachment":[{"href":"https:\/\/fatreseller.in\/blog\/wp-json\/wp\/v2\/media?parent=167"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fatreseller.in\/blog\/wp-json\/wp\/v2\/categories?post=167"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fatreseller.in\/blog\/wp-json\/wp\/v2\/tags?post=167"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}