Saturday 29 April 2017

free command usage and example

free 
It displays information about free and used memory on the system.

The total shows you the total memory assigned to machine but it excludes a small amount of RAM which is reserved for kernel for booting purpose

The first line, labeled Mem, displays physical memory utilization, including the amount of memory allocated to buffers and caches. 

A buffer memory, is a portion of memory that is set aside as a temporary holding place for data. Cache is a memory location to store frequently used data for faster access. Other difference between a buffer and a cache is that cache can be used multiple times where as buffer is used single time. 

Second line shows total buffers/Cache used and free.

Third line shows total swap memory available, used swap and free swap memory size available.

We can find more detailed information about total memory and current memory usage from the proc/meminfo file.

Syntax
free [options]

When used with no option it shows output in kilobytes.

Options
-b Will displays output in bytes
-k Will displays output in kilobytes
-m Will displays output in megabytes
-g Will displays output in gigabytes
-s num Will update free command every num seconds
-l Will displays detailed lowhigh memory statistics
-V Shows version

Example


watch
The alternative is to use free with its -s option using the watch command, which by default runs a program provided to it as an argument every two seconds after first temporarily clearing the screen.

watch free

watch -n 1 -d free

The -d (difference) option highlights changes in output, and its -n option followed by the number one to increase the frequency to one per second.

No comments:

Post a Comment