{"id":111,"date":"2021-10-26T12:06:23","date_gmt":"2021-10-26T12:06:23","guid":{"rendered":"https:\/\/bestdedicatedhosting.in\/blog\/?p=111"},"modified":"2021-11-02T13:07:44","modified_gmt":"2021-11-02T13:07:44","slug":"how-to-check-memory-usage-on-centos","status":"publish","type":"post","link":"https:\/\/bestdedicatedhosting.in\/blog\/how-to-check-memory-usage-on-centos\/","title":{"rendered":"How to check memory usage on CentOS"},"content":{"rendered":"\n<p><strong>Description&nbsp;:<\/strong><\/p>\n\n\n\n<p><a href=\"https:\/\/www.squarebrothers.com\/linux-web-hosting-india\/\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">Linux operating system<\/a>&nbsp;comes with many commands to check memory usage. <\/p>\n\n\n\n<p>The \u201cfree\u201d command usually displays the total amount of free and used physical and swap memory in the system, as well as the buffers used by the kernel. <\/p>\n\n\n\n<p>\u201ctop\u201d command provides a dynamic real-time view of a running system.<\/p>\n\n\n\n<p>The top command can display system summary information as well as a list of the process currently being managed by the Linux kernel.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>Checking memory usage on CentOS<\/strong><\/p>\n\n\n\n<p>Follow the below command to check memory usage on&nbsp;Linux machine.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/proc\/meminfo\n<\/pre>\n\n\n\n<p>You can check memory usage is to read the \/proc\/meminfo file.<\/p>\n\n\n\n<p>The same file is used to know the free and other utilities report of free and used memory (both physical and swap) on the system.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code># cat \/proc\/meminfo\nor\n# egrep --color 'Mem|Cache|Swap' \/proc\/meminfo<\/code><\/pre>\n\n\n\n<p>You will get some output like below:<\/p>\n\n\n\n<p><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>MemTotal:   7996284 kB\nMemFree:    5415608 kB\nCached:       92416 kB\nSwapCached:   35924 kB\nSwapTotal:  8187836 kB\nSwapFree:   8059332 kB<\/code><\/pre>\n\n\n\n<p><strong>free Command<\/strong><\/p>\n\n\n\n<p>You can check the total free and used physical and swap memory as well as the buffer used using free command.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># <code>free -m<\/code>\n<\/pre>\n\n\n\n<p>You will get some output like below:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>             total       used       free     shared    buffers     cached\nMem:          1006        317        689          0         36        190\n-\/+ buffers\/cache:         90        916\nSwap:         2015          0       2015<\/code><\/pre>\n\n\n\n<p><strong>where Command<\/strong><\/p>\n\n\n\n<p>The whereis command lets users locate binary, source, and manual page files for a command. Following is its syntax:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>Whereis [options]<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">-<code>b,-k,-m,-g: show output in bytes, KB, MB, or GB\n\u2013l: show detailed low and high memory statistics\n\u2013o: use old format (no -\/+buffers\/cache line)\n\u2013t: display total for RAM + swap\n\u2013s: update every [delay] seconds\n\u2013c: update [count] times<\/code><\/pre>\n\n\n\n<p><strong>vmstat command<\/strong><\/p>\n\n\n\n<p>vmstat reports information about processes, memory, paging, block IO, traps, and CPU activity.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code># vmstat<\/code><\/pre>\n\n\n\n<p>You will some output like below:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu-----\n r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st\n 0  0      0 701072  38236 198804    0    0    18    23   88   97  1  3 96  1  0<\/code><\/pre>\n\n\n\n<p>The vmstat command with the s option, lays out the memory usage statistics much like the proc command.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># <code>vmstat -s<\/code><\/pre>\n\n\n\n<p>You will some output like below:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>7996284    total memory\n3028732    used memory\n2587708    active memory\n253600     inactive memory\n4967552    free memory\n32212      buffer memory\n97732      swap cache\n8187836    total swap\n127572     used swap\n8060264    free swap\n2629730    non-nice user cpu ticks\n890        nice user cpu ticks\n335618     system cpu ticks\n80671997   idle cpu ticks\n14269700   IO-wait cpu ticks\n8          IRQ cpu ticks\n12963      softirq cpu ticks\n0          stolen cpu ticks\n320259348  pages paged in\n496267028  pages paged out\n40038      pages swapped in\n85154      pages swapped out\n151875583  interrupts\n278983792  CPU context switches\n1438090342 boot time\n300883     forks<\/code><\/pre>\n\n\n\n<p><strong>atop command<\/strong><\/p>\n\n\n\n<p>The program atop is an interactive monitor to view the load on a Linux system. <\/p>\n\n\n\n<p>This program can display the amount of used and free memory, i.e. cpu, memory, disk and network.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># <code>atop<\/code><\/pre>\n\n\n\n<p><strong>htop command<\/strong><\/p>\n\n\n\n<p>It is similar to top, also allows you to see all the processes running on the system, with their full command lines.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>#htop<\/code><\/pre>\n\n\n\n<p><code>top command<\/code><\/p>\n\n\n\n<p>The Linux top command is used to show all the running processes within your Linux environment.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">#<code>top<\/code><\/pre>\n\n\n\n<p>or<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># top c<\/pre>\n\n\n\n<p>We hope you\u2019ve found this useful!&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Description&nbsp;: Linux operating system&nbsp;comes with many commands to check memory usage. The \u201cfree\u201d command usually displays the total amount of free and used physical and swap memory in the system, as well as the buffers used by the kernel. \u201ctop\u201d command provides a dynamic real-time view of a running system. The top command can display [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_eb_attr":"","footnotes":""},"categories":[4],"tags":[],"class_list":["post-111","post","type-post","status-publish","format-standard","hentry","category-linux"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/bestdedicatedhosting.in\/blog\/wp-json\/wp\/v2\/posts\/111","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bestdedicatedhosting.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bestdedicatedhosting.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bestdedicatedhosting.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bestdedicatedhosting.in\/blog\/wp-json\/wp\/v2\/comments?post=111"}],"version-history":[{"count":4,"href":"https:\/\/bestdedicatedhosting.in\/blog\/wp-json\/wp\/v2\/posts\/111\/revisions"}],"predecessor-version":[{"id":116,"href":"https:\/\/bestdedicatedhosting.in\/blog\/wp-json\/wp\/v2\/posts\/111\/revisions\/116"}],"wp:attachment":[{"href":"https:\/\/bestdedicatedhosting.in\/blog\/wp-json\/wp\/v2\/media?parent=111"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bestdedicatedhosting.in\/blog\/wp-json\/wp\/v2\/categories?post=111"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bestdedicatedhosting.in\/blog\/wp-json\/wp\/v2\/tags?post=111"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}