free Command in Linux with examples
Last Updated :
09 Sep, 2024
While using LINUX there might come a situation when you are willing to install a new application (big in size) and you wish to know the amount of free memory available on your system. In LINUX, there exists a command line utility for this and that is the ‘free’ command which displays the total amount of free space available along with the amount of memory used and swap memory in the system, and also the buffers used by the kernel. This is pretty much what free command does for you.
What is the ‘free’ Command?
The `free` command in Linux is the one that facilitates with providing the overview of system memory utilization. It displays all the details regarding the RAM usage such as how is the total, what is used, and free memory including buffers and cached data, aiding in real-time monitoring of memory resources. It acts as essential command for administrators and users to assess system performance, allocate resources effectively, and identify potential memory-related issues promptly.
Syntax:
The basic syntax of the “free” command is as follows:
free [OPTION]
Common Options of ‘free’ Command
As ‘free’ displays the details of the memory related to your system , its syntax doesn’t need any arguments to be passed but only options which you can use according to your wish.
The following are the some of the optiosn of linux free command:
Options |
Description |
-k, –kilo |
Displays memory usage in kilobytes (default). |
-m, –mega |
Displays memory usage in megabytes. |
-g, –giga |
Displays memory usage in gigabytes. |
–tera |
Displays memory usage in terabytes. |
-h, –human |
Automatically scales all output columns to the shortest three-digit unit and displays the units (B, K, M, G, T). |
-c, –count |
Displays the output ‘c’ number of times; works with the -s option. |
-l, –lohi |
Shows detailed low and high memory statistics. |
-o, –old |
Disables the display of the buffer-adjusted line. |
-s, –seconds |
Continuously displays the output after ‘s’ seconds delay. Uses the usleep system call for microsecond resolution delay times. |
-t, –total |
Adds an additional line in the output showing column totals. |
–help |
Displays a help message and exits. |
-V, –version |
Displays version information and exits. |
Basic Usage of ‘free’ Command
The following command helps in finding the usage of ram memory in the system:
free
The following screenshot illustrates with displaying the usage of ram memory:
Free command without any option shows the used and free space of swap and physical memory in KB
When no option is used then free command produces the columnar output as shown above where column:
- total displays the total installed memory (MemTotal and SwapTotal i.e present in /proc/meminfo).
- used displays the used memory.
- free displays the unused memory.
- shared displays the memory used by tmpfs(Shmen i.e. present in ‘/proc/meminfo’ and displays zero in case not available).
- buffers displays the memory used by kernel buffers.
- cached displays the memory used by the page cache and slabs(Cached and Slab available in ‘/proc/meminfo’).
- buffers/cache displays the sum of buffers and cache.
Usage and Examples of free command with options
The following are options and examples discussing the usage of free command with options:
1. Using ‘-b’ (Displaying Output in Bytes)
It just displays the output in unit bytes. The following is the command of its usage:
free -b
2. Using ‘-k’ (Displaying Output in Kilobytes)
This option displays the result in kilobytes. The following is the command of its usage:
free -k
3. Using ‘-m’ (Displaying Output in Megabytes)
This option displays the result in megabytes. The following is the command of its usage:
free -m
4. Using ‘-g’ (Displaying Output in Gigabytes)
This option displays the result in gigabytes. The following is the command of its usage:
free -g

5. Using ‘-t’ (Displaying Totals with the -t Option)
This option displays an additional line containing the total of the total, used and free columns.
free -t
5. Using ‘-s’ and ‘-c’ (Continuously Monitoring Memory Usage)
This option allows you to display the output of free command after a set time gap given by the user. This option requires a numeric value to be passed with it that is treated as the number of seconds after which the output will be displayed.
free -s 3 -c 3

f
The above output will be displayed (only 3 times) after every 3 seconds. Now, with ‘-s’ you can only specify the time gap but not the number of times you want the output to be displayed.
For this, ‘-c’ is used along with ‘-s’ specifying the number of times the output will be displayed.
Importance of Linux ‘free’ Command
The following are the some of the important points of linux free commmand:
- Real-time Memory Monitoring: It faiclitates with provides the immediate insight regarding the system memory usage. It helps the administrators and users in monitoring the resource allocation.
- Performance Optimization: It llows the users for proactive management by identifying memory-intensive processes or applications, enabling timely adjustments to improve overall system performance.
- Resource Planning: It facilitates with efficient resource planning and allocation decisions based on accurate data about available, used, and cached memory, ensuring optimal utilization of system resources.
Conclusion
The free
command is used in Linux to check the amount of free and used memory on your system. It shows details about the RAM (physical memory) and swap space usage. The output displays different columns like total memory, used memory, free memory, and memory used for caching. You can use various options with free
to change the units (bytes, kilobytes, etc.), show a continuous update of memory usage, or display totals. The free
command is very useful for monitoring how much memory is available on your Linux system before running big programs or installing new applications.
Similar Reads
fc Command in Linux with Examples
As we all know that LINUX is command friendly and while working on LINUX, you may deal with very long commands that may include long paths or really difficult syntax, and imagine what if working with such commands you do a minor mistake which will require re-writing of the entire command synopsis an
3 min read
fc-cache command in Linux with Examples
The fc-cache command in Linux scans the font directories and build font cache for applications which use fontconfig for their font handling. When no arguments are passed fc-cache scans each directory for font files readable by FreeType. A cache is created which contains properties of each font and t
2 min read
fc-list command in Linux with examples
fc-list command is a part of the fontconfig system. It is used to list the available fonts and font styles. Using the format option, the list of all fonts can be filtered and sorted out. Moreover, multiple parameters can be passed to it after a colon symbol (:) to restrict the information that is be
3 min read
fdisk command in Linux with examples
The 'fdisk' command in Linux, short for "format disk," is a powerful, dialog-driven utility used for creating and manipulating the disk partition table. Essential for system administrators and users looking to manage their hard driveâs structure, 'fdisk' supports a range of operations such as creati
5 min read
fg command in Linux with examples
The fg command in Linux is used to bring a background job into the foreground. It allows you to resume a suspended job or a background process directly in the terminal window, so you can interact with it. Syntaxfg [job_spec]The job_spec is a way to refer to the background jobs that are currently run
3 min read
fgrep command in Linux with examples
The 'fgrep' filter is used to search for the fixed-character strings in a file. There can be multiple files also to be searched. This command is useful when you need to search for strings that contain lots of regular expression metacharacters, such as "^", "$", etc. This makes 'fgrep' particularly v
4 min read
file command in Linux with examples
The 'file' command in Linux is a vital utility for determining the type of a file. It identifies file types by examining their content rather than their file extensions, making it an indispensable tool for users who work with various file formats. The file type can be displayed in a human-readable f
3 min read
How to Find a File in Linux | Find Command
Linux, renowned for its robust command-line interface, provides a suite of powerful tools for efficient file and directory management. Among these, the "find" command stands out as an indispensable asset, offering unparalleled versatility in searching for files based on diverse criteria. This articl
9 min read
Finger command in Linux with Examples
The 'finger' command is a powerful utility in Linux used to display information about users logged into the system. This command is commonly used by system administrators to retrieve detailed user information, including login name, full name, idle time, login time, and sometimes the user's email add
4 min read
fmt command in Linux with examples
fmt command in LINUX actually works as a formatter for simplifying and optimizing text files. Formatting of text files can also be done manually, but it can be really time-consuming when it comes to large text files, this is where fmt comes to rescue. fmt re-formats each paragraph in the file specif
4 min read