Site icon Hostbillo Blog – Web Hosting, Devops, Tech, and more

How Can I Check Memory Usage in Linux?

How Can I Check Memory Usage in Linux?

Introduction

You must ensure that your Linux system operates at an optimal level. There are some straightforward commands that let you have access to all relevant details and enable you to monitor memory statistics. With this guide, we have provided simple ways to check memory usage in Linux. At the same time, you will get detailed insights into how these ways can further help you. All the mentioned ways in this guide will work properly with nearly every Linux distribution. Dig into the sections below and get all the details. 

System Requirements

Before you learn the process to check memory usage in Linux, you need to consider the following prerequisites – 

6 Ways to Check Memory Usage in Linux

The below-mentioned list includes 6 different processes to check memory usage on Linux. Let’s take a quick glimpse at them!  

Check Memory Usage Using the “top” Command

The “top” command serves as a powerful utility that can be employed to check process memory usage in Linux. It gives real-time details about the processes operating on your system, including CPU usage, check memory usage linux, & other metrics.

Follow the below steps to check memory usage in Linux using the “top” command:

  1. Open a terminal window on your system.
  2. Type “top” and press Enter to launch the “top” command.
  1. Wait for a few seconds for the command to begin gathering data.
  2. Look for the “MEM” column in the output. This column displays the amount of physical memory usae linux used by each process, in kilobytes (KB).
  1. You can also check the “SWAP” column to see the amount of swap space used by each process, in KB.
  1. To sort the output by check memory usage in Linux, press the “M” key. This will arrange the processes in descending order of memory usage.
  1. To escape the “top” command, press the “q” key.

Check Memory Usage on Linux with User-friendly Controls Using the “htop” Command

The “htop” command is actually an interactive process viewer when it comes to Linux systems. It provides a human-friendly interface for monitoring system resources, incorporating memory usage. It serves as a more advanced version of the “top” command & enables more intuitive control of processes.

Here is the process to check memory usage in Linux utilizing the “htop” command:

  1. Open a terminal window on your system.
  2. Enter “sudo apt-get install htop” to install “htop” if it is not already installed on your system.
  1. Once “htop” is installed, type “htop” and press Enter to launch the “htop” command.
  1. Wait for a few seconds for the command to start gathering data.
  2. Look for the “MEM%” column in the output. This column displays the percentage of physical memory used by each process.
  1. You can also check the “SWAP%” column to see the percentage of swap space used by each process.
  2. To sort the output by checking memory usage, press the “F6” key, and then select “MEM%” from the list of sorting options.
  1. You can also filter the output to show only processes that meet certain criteria. To do this, press the “F4” key, and then enter a search term in the “Filter:” field.
  1. To exit the “htop” command, press the “q” key.

Recommended: A Complete Guide to useradd Command in Linux with Examples

Check the Amount of Physical & Swap Memory Free using the “free” Command

The “free” command serves as a utility and displays information about the amount of free & utilized memory in the system, including physical as well as swap memory.

Follow the below steps to check the memory usage in Linux employing “free” command in Linux: 

  1. Open a terminal window on your system.
  2. Type “free” and press Enter to launch the “free” command.
  1. The output of the command will show the total amount of physical and swap memory, as well as the amount of used and free memory in each category.
  1. Look for the “Mem” and “Swap” rows in the output. The columns in these rows show the following information:

Check the Virtual Memory Statistics Report Using the “vmstat” Command

The “vmstat” command is also a utility that can be found available with most Linux-based systems. It shows virtual memory statistics, including information about processes, paging, block I/O, and CPU activity.

Here are steps to check the virtual memory statistics report in Linux employing the “vmstat” command:

  1. Open a terminal window on your system.
  2. Type “vmstat” and press Enter to launch the “vmstat” command.
  1. The output of the command will display a series of columns with the following information:

Check Linux Memory Info Using the “cat” Command

The “cat” command is yet another utility that is available with most Linux-based systems. It is employed to show the contents of files as well as system information. 

Follow the below steps to check memory usage on Linux using the “cat” command:

  1. Open a terminal window on your system.
  2. Type “cat /proc/meminfo” and press Enter to display the memory information.
  1. The output of the command will show various lines of information about the system’s check memory usage in Linux, including:

Check Memory Usage in Linux Using GUI

You can easily check memory usage in Linux with the help of graphical user interfaces (GUI) such as the system monitor tool. The system monitor provides a human-friendly way to monitor the performance of your system, including memory usage.

Here are the quick steps to check memory usage in Linux utilizing GUI:

  1. Open the system monitor tool. This can usually be found in the Applications menu, under System Tools or System Settings, depending on your Linux distribution.
  1. In the system monitor tool, click on the Resources tab.
  1. Under the Memory section, you will see information about your system’s memory usage, including:

You can also check out more detailed insights about memory usage by clicking on the Memory History button or by selecting the Memory tab. This will show a graphical representation of your system’s memory usage over time.

Also Read: How to Use the xargs Command in Linux?

Summing Up

Once you go through this guide thoroughly, you will learn how to check memory usage in Linux. At the same time, you can apprehend how a single command offers considerable valuable data for future analysis. It is very essential for you to learn to interpret the data or details. All this enables you to administer your web hosting server much more effectively. Moreover, you can reach out to our Hostbillo professionals anytime to get the right solutions to the relevant queries or issues you may face.

Exit mobile version