How to Check Memory Usage In Linux

There are a few commands that can help us to check the memory usage in linux server. The usage including free memory, used physical memory, swap memory and also buffers used by the kernel.

1. Type top command at ssh login or terminal.

    [root@server ~]# top
    

Sample outputs:

    top - 23:35:48 up  1:36,  1 user,  load average: 0.00, 0.01, 0.02
    Tasks:  67 total,   1 running,  66 sleeping,   0 stopped,   0 zombie
    Cpu(s):  0.4%us,  1.8%sy,  0.1%ni, 95.6%id,  2.1%wa,  0.1%hi,  0.0%si,  0.0%st
    Mem:    604324k total,   329952k used,   274372k free,    65428k buffers
    Swap:  1052248k total,        0k used,  1052248k free,   208324k cached
    
      PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
        1 root      15   0  2156  640  548 S  0.0  0.1   0:01.03 init
        2 root      RT  -5     0    0    0 S  0.0  0.0   0:00.00 migration/0
        3 root      34  19     0    0    0 S  0.0  0.0   0:00.00 ksoftirqd/0
        4 root      RT  -5     0    0    0 S  0.0  0.0   0:00.00 watchdog/0
        5 root      10  -5     0    0    0 S  0.0  0.0   0:00.00 events/0
        6 root      10  -5     0    0    0 S  0.0  0.0   0:00.00 khelper
        7 root      11  -5     0    0    0 S  0.0  0.0   0:00.00 kthread
       10 root      10  -5     0    0    0 S  0.0  0.0   0:00.01 kblockd/0
       11 root      20  -5     0    0    0 S  0.0  0.0   0:00.00 kacpid
      170 root      15  -5     0    0    0 S  0.0  0.0   0:00.00 cqueue/0
      173 root      15  -5     0    0    0 S  0.0  0.0   0:00.00 khubd
      175 root      10  -5     0    0    0 S  0.0  0.0   0:00.00 kseriod
      240 root      15   0     0    0    0 S  0.0  0.0   0:00.00 khungtaskd
      241 root      20   0     0    0    0 S  0.0  0.0   0:00.00 pdflush
      242 root      15   0     0    0    0 S  0.0  0.0   0:00.20 pdflush
      243 root      15  -5     0    0    0 S  0.0  0.0   0:00.00 kswapd0
      244 root      15  -5     0    0    0 S  0.0  0.0   0:00.00 aio/0
    

2. Type vmstat command at ssh login or terminal

    [root@server ~]# vmstat
    

Sample outputs:

    procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
     r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
     0  0      0 273256  65688 208884    0    0    79    39 1039   84  0  2 96  2  0
    

3. Display free memory in bytes, KB, MB, or GB

See also  Download CentOS 6.5 x86_64 and x86 ISO

usage: free [-b|-k|-m|-g] [-l] [-o] [-t] [-s delay] [-c count] [-V]
-b,-k,-m,-g show output in bytes, KB, MB, or GB
-l show detailed low and high memory statistics
-o use old format (no -/+buffers/cache line)
-t display total for RAM + swap
-s update every [delay] seconds
-c update [count] times
-V display version information and exit

Type below command if you want to displays a line containing the totals memory in MB:

    [root@server ~]# free -m -t
    

Sample outputs:

                 total       used       free     shared    buffers     cached
    Mem:           590        323        266          0         64        204
    -/+ buffers/cache:         54        535
    Swap:         1027          0       1027
    Total:        1617        323       1294
    

4. Cat the /proc/meminfo to get the memory usage information as below:

    [root@server ~]# cat /proc/meminfo
    

Sample outputs:

    MemTotal:       604324 kB
    MemFree:        272512 kB
    Buffers:         66040 kB
    Cached:         209256 kB
    SwapCached:          0 kB
    Active:          61864 kB
    Inactive:       222596 kB
    HighTotal:           0 kB
    HighFree:            0 kB
    LowTotal:       604324 kB
    LowFree:        272512 kB
    SwapTotal:     1052248 kB
    SwapFree:      1052248 kB
    Dirty:            1032 kB
    Writeback:           0 kB
    AnonPages:        9172 kB
    Mapped:           6468 kB
    Slab:            39896 kB
    PageTables:        972 kB
    NFS_Unstable:        0 kB
    Bounce:              0 kB
    CommitLimit:   1354408 kB
    Committed_AS:    76248 kB
    VmallocTotal:   417784 kB
    VmallocUsed:      4052 kB
    VmallocChunk:   413304 kB
    HugePages_Total:     0
    HugePages_Free:      0
    HugePages_Rsvd:      0
    Hugepagesize:     4096 kB
    

How to Reset the Directory Manager Password on RHEL 7 / CentOS 7
How to Reset the Directory Manager Password on RHEL 7 / CentOS 7

It is best practice to remember passwords, but because too many passwords, sometimes we forget. We are not encouraged to write the password on any paper or share the password...

How to Find Big Files Size on Linux RHEL/CentOS
How to Find Big Files Size on Linux RHEL/CentOS

As the linux administrator, sometimes we have to identify which files are most take much space in the linux server resulting in low free space. Low disk space can also...

Why Linux users should worry about malware and what they can do about it
Why Linux users should worry about malware and what they can do about it

Don’t drop your guard just because you’re running Linux. Preventing the spread of malware and/or dealing with the consequences of infection are a fact of life when using computers. If...

How to Reset Forgotten Root Password on Linux RHEL 7 / CentOS 7
How to Reset Forgotten Root Password on Linux RHEL 7 / CentOS 7

This short howto will explain the steps to reset a lost root password or to reset a forgotten root password on Linux RHEL 7 or CentOS 7. Basically, we will...

How to Update CentOS or Upgrade CentOS to the Latest Version
How to Update CentOS or Upgrade CentOS to the Latest Version

Recently, the latest version of CentOS 7.3 was released. All users of CentOS 7.0, 7.1 and 7.2 can upgrade their system to the most recent. This quick guide will explain...

How to Change your WordPress Username, Nickname and Display Name in MySQL
How to Change your WordPress Username, Nickname and Display Name in MySQL

After you create an account log in WordPress, you may want to change your WordPress username, as appropriate or due to security reason. However, you can not do this from...

How to Enable SSH Root Login on Ubuntu 16.04
How to Enable SSH Root Login on Ubuntu 16.04

As what we wrote in the previous article on how to allow SSH root on Ubuntu 14.04, after installing a fresh new copy of Ubuntu 16.04 LTS, we find that...

How to Change UUID of Linux Partition on CentOS 7
How to Change UUID of Linux Partition on CentOS 7

UUID (Universally Unique IDentifier) should be unique and it is used to identify storage devices on a linux system. If you cloned a virtual machine from vCenter, the metadata containing...

Leave a Reply

Your email address will not be published. Required fields are marked *