Linux Tutorial
Linux File/Directory Management
Linux Packaging And Compression
Vim Text Editor
Linux Text Processing
Linux Software Installation
Linux User/User Group Management
Linux Permission Management
Linux Filesystem Management
Linux Advanced Filesystem Management
Linux System Management
Linux Backup and Recovery
Linux System Service Management
Linux System Log Management
Linux Boot Management
LAMP/LNMP Environment
SELinux Management
The free
command in Linux is a command-line utility that displays information about the system's RAM usage, including total, used, and free memory. It is a helpful tool for monitoring memory usage and identifying potential issues related to memory consumption. Here's a tutorial on the Linux free
command:
Basic usage:
Run the free
command without any options to display memory usage in kilobytes:
free
The output will show information in several columns, including total, used, free, shared, buffer/cache, and available memory.
Display memory usage in human-readable format:
Use the -h
option to display memory usage in a more human-readable format, such as kilobytes (K), megabytes (M), or gigabytes (G):
free -h
Display memory usage in different units:
You can display memory usage in specific units, such as bytes (B), kilobytes (K), megabytes (M), or gigabytes (G), using the -b
, -k
, -m
, or -g
options, respectively:
free -m
The example above shows memory usage in megabytes.
Refresh the output periodically:
To refresh the free
command output at regular intervals, use the -s
option followed by the number of seconds between updates:
free -s N
Replace N
with the number of seconds you want between updates. For example, to refresh the output every 2 seconds:
free -s 2
Limit the number of updates:
You can also limit the number of updates when using the -s
option by combining it with the -c
option, followed by the number of updates you want to display:
free -s N -c M
Replace N
with the number of seconds between updates and M
with the number of updates you want to display. For example, to show memory usage every 2 seconds for a total of 5 updates:
free -s 2 -c 5
By using the free
command and its various options, you can effectively monitor memory usage on your Linux system and identify potential issues related to memory consumption.
How to use the free
command in Linux:
free
command in Linux is used to display information about system memory usage, including both physical RAM and swap space.free
Checking memory usage with free
:
free
command without any additional options.free
Displaying total and used memory in free
:
-t
option with free
.free -t
Viewing memory statistics with free
:
-s
option with free
.free -s 2 # Refresh every 2 seconds
Displaying memory in human-readable format with free
:
-h
option with free
.free -h
Checking swap space usage using free
:
free
output.free -s 2 # Real-time monitoring with 2-second refresh
Real-time monitoring of memory with free
:
-s
option with a specified refresh interval.free -s 2 # Refresh every 2 seconds