Usage of “free” command in linux

Usage of “free” command in linux

Monitoring is most important for every LINUX administrator and necessary for troubleshooting. While working on system/servers some times you feel your system responding late and is actually slow. This is normally because of the high load on system or your system is running out of memory.

This article will helps you in monitor physical and swap memory memory of your system.
There are many commands available in Linux which helps you in monitoring and troubleshooting. Free command is very useful as it provides information about the unused and used physical memory and swap space on any computer running Linux or another Unix-like operating system. Using some good example we will learn how “free” command works and how it is really helpful in our daily work.

The basic syntax of free is

free [options]

1. Displays System Memory

free command by default display the total used and available memory in kilobytes format

# free
            	 total        used        free     	    shared     buffers      cached
Mem:       3791332     613956    3177376          0      28600     299604
-/+ buffers/cache:     285752    3505580
Swap:      4194300          0    4194300

2. Display Memory in Bytes

To see the free memory available in bytes use the -b option.

# free -b
             total        used        free      shared     buffers      cached
Mem:    3882323968 1684504576 2197819392          0   48066560  903553024
-/+ buffers/cache:  732884992 3149438976
Swap:   4294963200          0 4294963200

3. Display Memory in Kilo Bytes

This option is similar as free alone command. Free -k gives you output in kilobyte (KB).

# free -k
             total        used        free      shared     buffers      cached
Mem:       3791332    1643668    2147664          0      46908     886812
-/+ buffers/cache:     709948    3081384
Swap:      4194300          0    4194300

4. Display Memory in Mega Bytes

free with -m will shows the output in megabytes (MB).

# free -m
             total        used        free      shared     buffers      cached
Mem:          3702       1601       2101          0         45        861
-/+ buffers/cache:        693       3008
Swap:         4095          0       4095

5. Display Memory in Giga Bytes

If you wish to check available in gigabytes (GB) please use -g option with free command.

# free -g
             	total        used        free      shared     buffers      cached
Mem:             3              1          2          0          0          0
-/+ buffers/cache:          0          2
Swap:            3              0          3