It is important to keep tabs on your CPU and memory usage in order for a system to continue running smoothly. Windows 11 PCs have handy tools or widgets to help you easily monitor your CPU, GPU, and RAM usage. Unfortunately, it's not as straightforward to do so on Linux devices. A much more technical approach is required, but there are many simple commands that can help you monitor things like CPU and memory usage.
What is a swap file in Linux and how much should you use?
Add some virtual memory to your Linux PC
Prerequisites
It is important to establish several things before you can start the procedure, so make sure that you have what you need before you begin.
- A Linux-based computer
- Access to a user account with sudo privileges
- Access to a terminal window
- A package installer, like apt or yum, both of which are included by default
These methods were tested on an Ubuntu 23.10 machine, but they will work on most Linux machines.
How to check CPU and RAM usage using the Terminal
Using the top command on Linux
One of the easiest ways to get CPU and RAM usage details is by using a simple top command in the terminal, as follows.
- Click on the Show apps button on your system's main screen.
- Click on the Terminal app to open it.
- If you want a list of processes that are currently running on your Linux-based system, this will give you details on active tasks, CPU load, memory usage, and more. Enter the command: top
- If you find the frequently changing items in the task list to be a bit overwhelming, then you can use a command to hide all idle processes, making it easier to sort through the list. Enter the command: top –i
To exit the Terminal, you can press the q key on the keyboard to quit the top function before trying other commands.
Using the htop command on Linux
The top command will get the job done, but you can also install htop to get an interactive list of running processes.
- Click on the Show apps button on your system's main screen.
- Select the Terminal application.
- Type the following command, and enter your system password when prompted to update your list of repositories. Enter the command: sudo apt update
- Install htop using apt command. Enter the command: sudo apt install htop
- Run htop to get the desired CPU and RAM utilization stats. Enter the command: htop
- You can now see a comprehensive list of tasks which you can scroll through. The CPU and the RAM usage can be found towards the top of the window. You can search for a specific task by the process name or by manually selecting an application.
You can press the F9 or F10 button to quit the htop command.
What's the difference between top and htop?
The difference between the two is that top is an older command that comes pre-installed on all Linux distros, while htop needs to be installed separately and isn't standard for all Linux systems. They both provide real-time information about your system's performance, but htop offers a slightly better user experience with added colors and a more interactive user interface.
How to check CPU and RAM usage using the System Monitor
Some Linux distributions, like Ubuntu, come with a built-in graphical monitoring tool called the System Monitor, which is similar to the Task Manager you get on Windows. It's just a simple application that you can use to monitor tasks and system utilization.
- Click on the Show apps button on your system's main screen.
- Open the Terminal application.
- Enter the following command: gnome-system-monitor
- Select the Resources tab in the new window.
- Now you can see a complete graphical representation of the CPU and RAM usage on your PC.
How to check CPU and RAM usage using the nmon monitoring tool
Nmon is another monitoring tool that's 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. Much like htop, nmon isn't available by default on Linux distros, meaning you'll have to install it separately, following the steps below.
- Click the Show apps button on your system's main screen.
- Open the Terminal application.
-
Enter the following command, and also enter the password when prompted:
sudo apt-get install nmon
-
Type the following command to run the nmon tool.
nmon
- Press the C key on the keyboard to view your device's CPU usage.
- Press the M key on the keyboard to view your device's Memory usage.
The top command lacks a UI
There are a couple of other ways to check the CPU and memory utilization on Linux, but the ones highlighted above are among the most reliable and easiest ways. The regular top command that's installed by default is the most popular way to check CPU and memory utilization on Linux machines.
While the top command works on every Linux device, alternatives like htop and nmon tools do a better job of providing the info with a more interactive user interface. Another alternative you can install and use is Bpytop, which is essentially a Python implementation of htop that requires the Python package manager pip to work.
However you go about it, keeping an eye on your system operations will allow you to spot issues before they have a major impact.
What's your favorite Linux distro?
Unlike Windows and macOS, the Linux landscape is teeming with countless distributions that bring their own set of unique features to the table. But with so many options, you're bound to have a distro or two as your favorites. Personally, I find it quite difficult to hone in on one distro. Instead, I have several options that I cycle through depending on my needs. For example, I love NixOS' unique (and downright eccentric) nature in my coding-oriented projects, while Pop_OS! is my go-to choice when I want to use an Nvidia GPU inside Linux. However, I'm also quite fond of Debian's stable nature, and even prefer it over Ubuntu. Then there's Q4OS, which can rejuvenate any old PC when combined with the ultra-light Trinity desktop environment. But that's just me being indecisive after years of distro-hopping. What about you?
