5 Commands to Check Memory Usage in Linux {Easy Way} (2023)


It is essential that your Linux system runs at an optimal level. A few simple terminal commands provide access to all relevant information and help you monitor memory statistics.

In this tutorial, learn five powerful commands to check memory usage in Linux.

We also provide detailed explanations of what they do and more importantly, how to interpret the results. The commands will work with nearly all Linux distributions. In this instance, the commands and the results are presented using Ubuntu 18.04.

5 Commands to Check Memory Usage in Linux {Easy Way} (1)


  • Access to a command line / terminal
  • User with sudo privileges
  • The apt package manager

Commands to Check Memory Use in Linux

cat Command to Show Linux Memory Information

Entering cat /proc/meminfo in your terminal opens the /proc/meminfo file.

This is a virtual file that reports the amount of available and used memory. It contains real-time information about the system’s memory usage as well as the buffers and shared memory used by the kernel. The output might differ slightly based on the architecture and operating system in question.

This is an example of what the /proc/meminfo file looks like in Ubuntu 18.04:

The terminal displays the information in kilobytes.

free Command to Display the Amount of Physical and Swap Memory

Typing freein your command terminal provides the following result:

5 Commands to Check Memory Usage in Linux {Easy Way} (3)

The data represents the used/available memory and the swap memory figures in kilobytes.

totalTotal installed memory
usedMemory currently in use by running processes (used= total – free – buff/cache)
freeUnused memory (free= total – used – buff/cache)
sharedMemory shared by multiple processes
buffersMemory reserved by the OS to allocate as buffers when process need them
cachedRecently used files stored in RAM
buff/cacheBuffers + Cache
availableEstimation of how much memory is available for starting new applications, without swapping.

Compared to the /proc/meminfo file, the free command provides less information. However, it is easier to understand. The key figure being the available value as it displays how much memory is still available for running new applications.

The free command has multiple options to format the output so that it better matches your requirements. The table below lists the most useful variations of the free command.

-boutput in bytes
-koutput in kibibytes
-moutput in mebibytes
-goutput in gibibytes
-ldetailed low and high memory statistics
-oold format (no -/+buffers/cache line)
-ttotal for RAM + swap
-supdate every [delay] seconds
-cupdate [count] times

Note: As with most commands, entering man free displays an overview of all variations and descriptions of the results.

vmstat Command to Report Virtual Memory Statistics

The vmstat command is a useful tool that reports virtual memory statistics.

vmstat provides general information about processes, memory, paging, block IO, traps, and CPU activity.

5 Commands to Check Memory Usage in Linux {Easy Way} (4)

The detailed description listed below provides an explanation for each value in case you need assistance in analyzing the results.

  • Procs
    • r: number of processes waiting for run time.
    • b: number of processes in uninterruptible sleep.
  • Memory
    • swpd: amount of virtual memory used.
    • free: amount of idle memory.
    • buff: the amount of memory used as buffers.
    • cache: amount of memory used as cache.
  • Swap
    • si: memory swapped in from disk (/s).
    • so: memory swapped to disk (/s).
  • IO
    • bi: Blocks received from a block device (blocks/s).
    • bo: Blocks sent to a block device (blocks/s).
  • System
    • in: number of interrupts per second, including the clock.
    • cs: number of context switches per second.
  • CPU – These are percentages of total CPU time.
    • us: Time spent running non-kernel code. (user time, including nice time)
    • sy: Time spent running kernel code. (system time)
    • id: Time spent idle. Before Linux 2.5.41, this includes IO-wait time.
    • wa: Time spent waiting for IO. Before Linux 2.5.41, included in idle.
    • st: Time stolen from a virtual machine. Before Linux 2.6.11, unknown.

top Command to Check Memory Use

The top command is useful to check memory and CPU usage per process. It displays information about:

  • uptime
  • average load
  • tasks running
  • number of users logged in
  • number of CPUs/CPU utilization
  • memory/swap system processes

The data is continuously updated, which allows you to follow the processes in real-time.

5 Commands to Check Memory Usage in Linux {Easy Way} (5)

Aside from providing you with essential memory information, the top command provides a limited interactive interface. It is possible to manipulate and configure operations by using command-line options.

The man command in Linux man top provides a comprehensive list of all available variations.

htop Command to Find Memory Load of Each Process

The information the htop command provides is similar to the top command. However, the real advantage to the htop command is its user-friendly environment and improved controls.

The command uses color for its output, provides full command lines for processes, as well as the option to scroll both vertically and horizontally.


The following output appears:

5 Commands to Check Memory Usage in Linux {Easy Way} (6)
  1. The top segment provides summary information and contains graphic meters and text counters.
  2. The lower section structures the detailed data, per process. This allows you to perform actions on individual processes with ease.
  3. The shortcuts listed at the bottom of the screen will enable you to manipulate and customize the processes quickly and without the need to type specific commands.

Note: If you run into “Command ‘htop’ not found” message when trying to run the htop command, you will need to install the htop function first:

sudo snap install htop

As an alternative, use the command below:

sudo apt install htop

Checking Memory Usage in Linux using the GUI

Using a graphical interface for server administration is not common practice. However, certain data sets are much clearer, with a visual representation of memory usage.

To access the System Monitor:

  1. Navigate to Show Applications.
  2. Enter System Monitor in the search bar and access the application.
  3. Select the Resources tab.
  4. A graphical overview of your memory consumption in real time, including historical information is displayed.
5 Commands to Check Memory Usage in Linux {Easy Way} (7)


This guide provided several options to check memory usage on your Linux system. We learned that a single command provides an abundance of valuable data for future analysis. Learning to interpret the information correctly is critical.

Now you can administer your server more efficiently.


What is the command to check memory usage in Linux? ›

Using the `vmstat` command to check memory usage in Linux.

vmstat vmstat command is used to display virtual memory statistics of the system. This command reports data about the memory, paging, disk, and CPU activities, etc. The first use of this command returns the data averages since the last reboot.

How to find top 5 memory consuming process in Linux? ›

How to Find Top Running Processes by Memory and CPU Usage
  1. Processes in Linux. UID – Associated user ID for this process. ...
  2. If you are using fedora then execute the below command: sudo dnf install htop. ...
  3. launching htop. ...
  4. htop. ...
  5. Then you can see the processes and the resources consumed by each of them. ...
  6. system monitor.
Oct 26, 2022

How to check memory capacity in Linux? ›

  1. Open the command line.
  2. Type the following command: grep MemTotal /proc/meminfo.
  3. You should see something similar to the following as output: MemTotal: 4194304 kB.
  4. This is your total available memory.

How to check memory usage in Linux per user? ›

Using the ps Command. In this command, -u filters by the username we provide, and -o specifies the output format. Here, %MEM represents the percentage of physical memory used by each process for the specific user. We can sum up these values to obtain the total memory usage for the specified user.

How to check memory usage? ›

Here's how:
  1. Press Ctrl + Shift + Esc to launch Task Manager. Or, right-click the Taskbar and select Task Manager.
  2. Select the Performance tab to see current RAM usage displayed in the Memory box, and total RAM capacity listed under Physical Memory.
Aug 12, 2023

How to check CPU memory usage in Linux? ›

Check CPU Usage with vmstat Command

The vmstat command will display the information about system processes, memory, swap, I/O, and CPU performance. It will display the average details since the last reboot. Press CTRL+C to close the vmstat.

How to check shared memory in Linux? ›

Also, by using the ipcs command we get to view the shared memory segments in our system. Additionally, by utilizing the pstree command we get to list processes generated from the shared memory segment using its identifier (shmid).

How do I investigate high memory usage in Linux? ›

Memory issues can be resolved by analyzing the logs which are stored in the kernel log /var/log/kern. log or in the syslog /var/log/syslog location. You can manually analyze all the logs with the help of grep command and find out the cause of the memory issue.

What is the top command for memory usage? ›

The top command is used for memory monitoring. It works only on Linux platform. The top command produces an ordered list of running processes selected by user-specified criteria, and updates it periodically. By default, ordering is by CPU usage, and it shows processes that consume maximum CPU.

How to check max RAM in Linux? ›

Find Out Maximum Supported RAM In Linux using Dmidecode

Dmidecode is available in most Linux distribution's default repositories. As you see in the above output, the maximum supported RAM size is 16 GB, and the number of available RAM slots (DIMM) are 2.

How to check RAM memory in Linux terminal? ›

The procedure to find and show random access memory (RAM) in gigabytes (GB) is as follows:
  1. Open the Linux terminal application.
  2. Type the free -g -h -t or free --gibi -h -t command to display the amount of memory in gibibytes. ...
  3. Press the enter key. ...
  4. The -g option show output in GB (gibibytes) for Linux memory.
Jun 7, 2022

How to check JVM memory usage in Linux? ›

To find the Java heap size and the amount of memory used on a Linux system, you can use the jstat command and specify the process ID (PID) of the Java process. This will display the Java heap size and the amount of memory used, as well as other information about the garbage collector.


Top Articles
Latest Posts
Article information

Author: Amb. Frankie Simonis

Last Updated: 23/12/2023

Views: 6472

Rating: 4.6 / 5 (76 voted)

Reviews: 83% of readers found this page helpful

Author information

Name: Amb. Frankie Simonis

Birthday: 1998-02-19

Address: 64841 Delmar Isle, North Wiley, OR 74073

Phone: +17844167847676

Job: Forward IT Agent

Hobby: LARPing, Kitesurfing, Sewing, Digital arts, Sand art, Gardening, Dance

Introduction: My name is Amb. Frankie Simonis, I am a hilarious, enchanting, energetic, cooperative, innocent, cute, joyous person who loves writing and wants to share my knowledge and understanding with you.