The free
command in Linux is used to display information about the system’s memory usage. It provides details about the total, used, free, and available memory on the system, as well as information about swap space.
Here’s an overview of how to use the free
command:
- Basic Usage:
To display memory usage information, simply typefree
in your terminal. For example:
free
This command will display information about the system’s memory usage.
- Displaying Memory Usage:
Thefree
command will provide output indicating the memory usage on the system. It typically displays the following information:
total
: The total amount of physical memory (RAM) available on the system.used
: The amount of memory used by the system, including buffers and cached data.free
: The amount of memory currently available for new processes.shared
: The amount of memory used by shared memory segments.buffers
: The amount of memory used for buffer cache.cached
: The amount of memory used for page cache.available
: The estimated amount of memory that can be allocated to new processes without swapping.
- Displaying Swap Space:
Additionally, thefree
command displays information about swap space, which is a portion of the hard disk used as virtual memory when the physical memory is exhausted. It includes the following information:
Swap
: The total amount of swap space available on the system.Used
: The amount of swap space currently in use.Free
: The amount of swap space available for use.
- Example:
Here’s an example output of thefree
command:
total used free shared buff/cache available
Mem: 2048 968 300 200 779 620
Swap: 1024 10 1014
In this example, the system has 2048 MB of total physical memory (RAM). Of that, 968 MB is currently in use, 300 MB is free, 200 MB is used by shared memory segments, and 779 MB is used for buffers and page cache. The estimated available memory for new processes is 620 MB. The system also has 1024 MB of swap space, with 10 MB currently in use and 1014 MB free.
The free
command provides a quick overview of the system’s memory usage, helping you monitor memory consumption and determine the available resources.
For more information about the free
command and its options, you can refer to the manual page by typing man free
in your terminal.