5 Practical Examples of Free Command in Linux

Free is the standard tool to check the memory usage in Linux. Anyone on your system is able to use free since it doesn’t require root access to run. The use of free is also extremely easy. You can use it by simply typing freeon the terminal.

It’s just, the default output generated by free is less readable. By default, free displays the memory consumption in bytes so you will see too many digits on your screen. To get a more readable output, you can use the available options offered by free. For instance, you can use the option of “h” to get a more readable display.

If you are new to Linux and want to learn how to use the free command, following are 5 practical examples you can try.

1. Show the memory usage in kilobytes

To display the memory consumption in kilobytes you can use the option of “k”. Simply type free -kand you should see the following output.

2. Show the memory usage in megabytes

To get less digits, you can also set free to display the memory usage in megabytes. To do so, you can use the option of “m”. Simply type free -mand you will see the output as follows.

3. Show the memory usage in gigabytes

Today, most computers have at least a 2GB of RAM. You can also set free to display the memory consumption in your Linux system in gigabytes. You can use the option of “g” to do so. Just type free -gand you will see the output like the following.

4. Show the memory use stats certain times then exit

You can also set free to display the stats of memory usage certain times before exit. Say you want to display the memory usage 5 times with a single command. You can use the option of “c” followed by how many you want free to repeat the report. Here is the syntax.

free -c N

You can replace “N” with any number, depending on how many times you want free to repeat the report. See the example below to make it clearer.

free -m -s 4

The command above will display the memory consumption in megabytes four times.

5. Show the memory usage in a readable output

This is the best use of free. You can use the option of “h” to set free to display the memory usage in your Linux system in a readable output. Depending on the memory you have on your system, this option will display the memory consumption in gigabytes, megabytes or combination between the two. Simply type free -hon the terminal. Below is the example of the output generated by the option.

Each command in Linux has a manual page. If you want to learn more about the free command in Linux you can read the manual page by typing man freeon the terminal. To see all of the options you can use, you can type free --help.

Related posts

Written by Al Putra

An open source user and CC0-licensed stuffs lover. Sometimes also use Windows



Leave a Comment

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