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

Linux free Command: Display Memory Status

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:

  1. 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.

  2. 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
    
  3. 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.

  4. 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
    
  5. 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.

  1. How to use the free command in Linux:

    • Description: The free command in Linux is used to display information about system memory usage, including both physical RAM and swap space.
    • Example:
      free
      
  2. Checking memory usage with free:

    • Description: To check the current memory usage, you can use the free command without any additional options.
    • Example:
      free
      
  3. Displaying total and used memory in free:

    • Description: To show both total and used memory, use the -t option with free.
    • Example:
      free -t
      
  4. Viewing memory statistics with free:

    • Description: To display detailed memory statistics, use the -s option with free.
    • Example:
      free -s 2  # Refresh every 2 seconds
      
  5. Displaying memory in human-readable format with free:

    • Description: To display memory sizes in a human-readable format (e.g., KB, MB, GB), use the -h option with free.
    • Example:
      free -h
      
  6. Checking swap space usage using free:

    • Description: To check the usage of swap space, look at the "Swap" row in the free output.
    • Example:
      free -s 2  # Real-time monitoring with 2-second refresh
      
  7. Real-time monitoring of memory with free:

    • Description: To monitor memory usage in real-time, use the -s option with a specified refresh interval.
    • Example:
      free -s 2  # Refresh every 2 seconds