How to check Memory Usage in centos using ‘free’ commands
2 mins read

How to check Memory Usage in centos using ‘free’ commands

Description 

Linux is one of the most popular open source operating system and comes with huge set of commands.

The most important and single way of determining the total available space of the physical memory and swap memory is by using “free” command.

The Linux “free” command gives information about total used and available space of physical memory and swap memory with buffers used by kernel in Linux/Unix like operating systems.

This article provides some useful examples of “free” commands with options, that might be useful for you to better utilize memory that you have.

 

1. Display System Memory

Free command used to check the used and available space of physical memory and swap memory in KB.

[root@vps ~]# free
              total        used        free      shared  buff/cache   available
Mem:        1012436       53864      197272       25552      761300      903124
Swap:       2097148           0     2097148

 

2. Display Memory in Bytes

Free command with option -b, display the size of memory in Bytes

[root@vps ~]# free -b
              total        used        free      shared  buff/cache   available
Mem:     1036734464    52916224   204431360    26132480   779386880   927121408
Swap:    2147479552           0  2147479552

 

3. Display Memory in Kilo Bytes

Free command with option -k, display the size of memory in (KB) Kilobytes

[root@vps ~]# free -k
              total        used        free      shared  buff/cache   available
Mem:        1012436       51548      199764       25520      761124      905520
Swap:       2097148           0     2097148

 

4. Display Memory in Megabytes

To see the size of the memory in (MB) Megabytes use option as -m.

[root@vps ~]# free -m
              total        used        free      shared  buff/cache   available
Mem:            988          50         195          24         743         884
Swap:          2047           0        2047

 

5. Display Memory in Gigabytes

Using -g option with free command, would display the size of the memory in GB(Gigabytes).

[root@vps ~]# free -g
              total        used        free      shared  buff/cache   available
Mem:              0           0           0           0           0           0
Swap:             1           0           1

 

6. Display Total Line

Free command with -t option, will list the total line at the end.

[root@vps ~]# free -t
              total        used        free      shared  buff/cache   available
Mem:        1012436       51548      199764       25520      761124      905520
Swap:       2097148           0     2097148
Total:      3109584       51548     2296912

 

7. Disable Display of Buffer Adjusted Line

By default the free command display “buffer adjusted” line, to disable this line use option as -o.

[root@vps ~]# free -o
total       used       free     shared    buffers     cached
Mem:       1021628     912520     109108          0     120368     655548
Swap:      4194296          0    4194296

 

8. Display Memory Status for Regular Intervals

The -s option with number, used to update free command at regular intervals.

For example, the below command will update free command every 5 seconds.

[root@vps ~]# free -s 5
              total        used        free      shared  buff/cache   available
Mem:        1012436       51672      199640       25520      761124      905396
Swap:       2097148           0     2097148

 

9. Show Low and High Memory Statistics

The -l switch displays detailed high and low memory size statistics.

[root@vps ~]# free 1
              total        used        free      shared  buff/cache   available
Mem:        1012436       51652      199660       25520      761124      905416
Swap:       2097148           0     2097148

 

10. Check Free Version

The -V option, display free command version information.

[root@vps ~]# free -V
free from procps-ng 3.3.10

 

We hope you’ve found this useful!

 

Leave a Reply

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