How to check CPU and memory usage in Linux

To keep a system running smoothly, it's important to keep an eye on CPU and memory usage. Windows 11 PCs have handy tools or widgets that allow you to easily monitor CPU, GPU, and RAM usage. Unfortunately, it's not as easy on Linux devices. A much more technical approach is required, but there are many simple commands you can use to monitor things like CPU and memory usage.



Requirements

There are a few things you need to sort out before you can begin the procedure, so make sure you have everything you need before you begin.

  • A Linux-based computer
  • Access to a user account at Sudo permissions
  • Accessing a terminal window
  • A package installer such as apt or yum, both of which are included by default

These methods were tested on an Ubuntu 23.10 machine, but will work on most Linux machines.

How to check CPU and RAM usage using the terminal

Using the top command in Linux

One of the easiest ways to get details about CPU and RAM usage is to use a simple Great Command in terminal as follows.

  1. Click on the Show apps button on the main screen of your system.
  2. Click on the terminal app to open it.
  3. If you want a list of processes currently running on your Linux-based system, you can get details about active tasks, CPU usage, memory usage, and more. Enter the following command: Great
  4. If you find the frequently changing items in the task list a bit overwhelming, you can use a command to hide all inactive processes, making it easier to sort the list. Enter the following command: up –i


To
Leave the terminal.
You can
Q
Key on the keyboard to exit the top function before trying other commands.

Using the htop command on Linux

The Great command does the job, but you can also install h up to get an interactive list of running processes.

  1. Click on the Show apps button on the main screen of your system.
  2. Select the terminal Application.
  3. Enter the following command and enter your system password when prompted to refresh your repository list. Enter the command: sudo apt update​​
  4. Install h up with the apt command. Enter the command: sudo apt install htop
  5. Run h up to get the desired statistics on CPU and RAM usage. Enter the command: htop
  6. You can now see a comprehensive list of tasks that you can browse through. CPU and RAM usage can be found at the top of the window. You can search for a specific task by process name or by manually selecting an application.


You can press F9 or F10 to exit the htop command.

What is the difference between top and htop?

A screenshot showing the terminal window on Linux with the top -i command.

The difference between the two is that top is an older command that comes pre-installed on all Linux distributions, while htop must be installed separately and is not standard for all Linux systems. Both provide real-time information about your system's performance, but htop offers a slightly better user experience with additional colors and a more interactive interface.


How to check CPU and RAM usage with System Monitor

Some Linux distributions, such as Ubuntu, have a built-in graphical monitoring tool called System Monitor, which is similar to Windows Task Manager. It is just a simple application that allows you to monitor tasks and system usage.

  1. Click on the Show apps button on the main screen of your system.
  2. Open the terminal Application.
  3. Enter the following command: Gnome System Monitor
  4. Select the resources tab in the new window.
  5. Now you can see a complete graphical representation of CPU and RAM usage on your PC.


Nmon is another monitoring tool that is popular among many Linux users. IBM originally developed this system performance monitoring tool for the AIX operating system, but it was later ported to Linux. Similar to htop, nmon is not available by default in Linux distributions, which means you need to install it separately. To do so, follow the steps below.

  1. Click on the Show apps button on the main screen of your system.
  2. Open the terminal Application.
  3. Enter the following command and enter the password when prompted:
    sudo apt-get install nmon 
  4. Type the following command to run the Nmon tool.
    nmon 
  5. Press the C Key on the keyboard to CPU Use.
  6. Press the M Key on the keyboard to Memory Use.


The top command lacks a user interface

There are a few other ways to check CPU and memory usage on Linux, but the ones highlighted above are some of the most reliable and easiest ways. The regular top command, installed by default, is the most popular way to check CPU and memory usage on Linux machines.

While the top command will work on any Linux device, alternatives like htop and nmon can provide the information better with a more interactive user interface. Another alternative you can install and use is Bpytopessentially a Python implementation of htop that requires the Python package manager pip to work.

Whatever you do, keeping an eye on how your system is operating can help you identify problems before they have a major impact.


Related

What is your favorite Linux distribution?

Unlike Windows and macOS, the Linux landscape is teeming with countless distros that bring their own unique features. But with so many options, you're bound to have one or two distros as your favorites. Personally, I find it quite difficult to settle on one distro. Instead, I have several options that I cycle through as needed. For example, I love the unique (and downright eccentric) nature of NixOS in my coding-focused projects, while Pop_OS! is my go-to when I want to use an Nvidia GPU in Linux. However, I also really like the stable nature of Debian and even prefer it to Ubuntu. Then there's Q4OS, which combined with the ultra-lightweight Trinity desktop environment can rejuvenate any old PC. But that's just my indecision after years of distro hopping. And you?

Leave a Comment