How to Monitor Server Resource Usage with htop

If you run a Linux server, you’ll want to keep an eye on its health. One tool I really like for this is htop. It’s simple, fast, and easy to use.

In this post, I’ll walk you through how to install and use htop to check your server’s CPU, memory, and processes. I’ll also share why I prefer htop over the older top command.

Even if you’re new to Linux, don’t worry. I’ll explain things clearly.


What Is htop?

Let’s start with the basics.

htop is a tool that shows live information about your system. You can see how much memory is used, what programs are running, and how busy the CPU is.

I think of htop as a system monitor for the command line. It’s like Task Manager on Windows, but for Linux servers.

Why not just use top?

Good question. While top works, htop is easier to read. It’s colorful, more organized, and lets you scroll and search.


Why You Might Want to Use htop

Have you ever asked:

  • Why is my server slow?
  • What’s using all the RAM?
  • Is my CPU at 100%?
  • Which process is using all the bandwidth or disk?

I have. That’s why I use htop. It gives quick answers without having to write long commands.

It’s also great if:

  • You run multiple apps or websites on one server.
  • You want to check if something is using too many resources.
  • You’re learning Linux and want to see how the system works.

Step 1: Install htop

Let’s install htop. The command is different depending on what version of Linux you use.

If you’re on Debian or Ubuntu:

sudo apt update
sudo apt install htop -y

On CentOS 7:

sudo yum install epel-release -y
sudo yum install htop -y

For CentOS 8 or Rocky Linux:

sudo dnf install epel-release -y
sudo dnf install htop -y

Once installed, just type:

htop

And press Enter.

You’ll now see a colorful dashboard full of live stats.


What You’ll See in htop

Let’s break it down.

At the top:

  • CPU bars: Shows how much of each CPU core is used.
  • Memory bar: How much RAM is being used.
  • Swap bar: Usage of your swap file or partition.

Below that:

  • A list of processes. These are the programs or services running.

Each process has details like:

  • PID (Process ID)
  • User running it
  • CPU% and MEM% used
  • Command used to start it

You can scroll up and down using the arrow keys.


Useful htop Keys and Features

What makes htop great is that it’s interactive. You don’t need to type long commands.

Try these keys inside htop:

  • F3: Search for a process
  • F5: Tree view – shows which processes started others
  • F6: Sort by different columns
  • F9: Kill a process
  • F10: Exit htop

Want to sort by memory usage? Press F6, then select MEM% using the arrow keys and Enter.

Need to find apache2 or nginx? Press F3 and type the name.


Comparing htop to top

I used top before I learned about htop. But once I tried htop, I never looked back.

Here’s what I noticed:

Feature top htop
Colors No Yes
Mouse Support No Yes
Scroll Process No Yes
Easy to Read Not really Very
Interactive Limited Yes

You don’t need to memorize any flags with htop. It’s just more friendly.


Two Lists You Might Find Helpful

What You Can Monitor with htop

  • CPU usage per core
  • Memory usage
  • Swap usage
  • Number of tasks/processes
  • Load average (system stress)
  • Which services are using the most resources

When htop Comes in Handy

  • Server is running slow and you don’t know why
  • Something is using too much RAM or CPU
  • You want to stop a stuck process
  • You’re debugging a background script or cron job
  • You just want a quick look at what’s going on

A Quick Real-Life Example

I once ran a WordPress site on a small VPS. It kept going down.

At first, I thought the traffic was too high. But when I opened htop, I saw mysql was eating all the RAM. It wasn’t traffic. It was a misconfigured database.

After lowering the innodb_buffer_pool_size setting, things calmed down.

Without htop, I might’ve wasted hours guessing.


Customizing the htop Display

You can change what htop shows.

Press F2 to enter the setup menu. From here, you can:

  • Hide or show columns
  • Change color themes
  • Adjust meters (like CPU or RAM)

I like to keep things simple. I show:

  • PID
  • USER
  • CPU%
  • MEM%
  • TIME+
  • COMMAND

You can pick what makes sense for your work.


Should You Keep htop Running?

You can, but it’s better to use it when needed. htop does use a little CPU.

If you want to log CPU and RAM over time, htop isn’t the tool for that. For logs, try sar, collectl, or Netdata.

Still, htop is great for live snapshots.


Is htop Safe?

Yes, it’s safe to install. It’s open-source and read-only unless you choose to kill a process. Just be careful when pressing F9 – it asks before stopping anything.


Final Thoughts

htop is one of the first things I install on any VPS. It helps me solve problems fast, and it doesn’t get in the way.

If you’re just getting into Linux servers, try it. You’ll learn a lot by just watching your system in real time.

Leave a Reply