Innovate | Connect | Transform
ContactService statusUSD $

GICT knowledge base

How to Monitor System Resources and Performance in Linux

Published

Linux

If you’ve ever had your Linux computer feel a bit sluggish, or you’ve wondered what’s eating up all your memory, you’re not alone. System slowdowns, mysterious freezing, or simply wanting to squeeze more performance out of your hardware—these are things every Linux user will encounter sooner or later.

The good news? Linux offers you some of the clearest insight into what’s going on under the hood. You don’t need to be a sysadmin to peek behind the curtain. You just need to know which tools to use and how to read what they’re telling you.

This guide isn’t just a dry list of commands. It’s a hands-on walkthrough, the kind you’d get from a friend who’s been down this road before—someone who’s learned a few lessons the hard way and wants to make your journey smoother.

Why Bother Monitoring at All?

Let’s be honest, most of us don’t think about our computer’s health until something’s wrong. Maybe the fan’s running non-stop, your web browser is crawling, or a game that used to run fine now stutters. Sometimes, you just want to see if your shiny new SSD is actually faster. Or maybe you’re running a server and want to make sure it doesn’t crash at the worst possible moment.

By keeping an eye on system resources like CPU, memory, and disk, you can:

  • Spot problems before they crash your system
  • Catch greedy apps or runaway scripts
  • Figure out if you need an upgrade—or just need to kill a process
  • Understand your system’s “normal,” so you know when something’s off

What to Watch: System Resources That Matter

In Linux, the big four are:

  • CPU usage (processing power)
  • Memory usage (RAM and swap)
  • Disk usage and I/O (your storage, both space and speed)
  • Network activity (uploading, downloading, or mysterious background chatter)

Almost every slowdown or bottleneck can be chased down to one of these.

Essential Tools for the Job

I’ll break these down by category and sprinkle in some stories and tips along the way.

1. top and htop (Your First Stop)

When my own system starts to lag, I almost always reach for top first. Just open a terminal and type:

top

You’ll get a dynamic list of what’s running, sorted by CPU usage by default. It’s like Task Manager for Linux—except all text.

Want something friendlier? Install htop:

sudo apt install htop

htop is colorful, lets you sort columns with a tap, and you can use your keyboard to scroll and kill processes instantly. For beginners and pros alike, it’s a lifesaver.

My advice: If you see one process hogging 99% of your CPU, that’s your likely troublemaker. Sometimes it’s a browser tab gone wild; sometimes it’s a backup script you forgot about.

2. free (How Much Memory Do You Have Left?)

Memory (or RAM) issues sneak up on you. Suddenly, things are swapping to disk and everything crawls.

free -h

The -h makes it human-readable. Pay attention to used, free, and available memory. If you see swap being used heavily, you’re probably running out of RAM.

3. df and du (Where Did My Disk Space Go?)

When you get a “disk full” error, panic sets in. But it’s easy to check:

df -h

Shows disk usage on all mounted drives.

du -sh ~/Downloads/*

Quickly shows which folders in your Downloads directory are taking up space. You can swap that path for any directory.

Real-life tip: I once found a month-old video project eating 50 GB in my /tmp folder. A quick du and some cleanup made my system feel brand new.

4. ps (Hunting for Rogue Processes)

To see what’s eating your CPU or memory:

ps aux --sort=-%cpu | head

Or for memory hogs:

ps aux --sort=-%mem | head

This is especially handy if you want to spot a runaway process in a script or cron job.

5. iostat, vmstat, and mpstat (Getting Fancy)

If you’re running a server or want deeper insight:

  • iostat shows how busy your disks are
  • vmstat reveals memory, system, and process stats
  • mpstat can break down CPU usage per core

You might need to install them first:

sudo apt install sysstat

Then try:

iostat -xz 2 3
vmstat 2 5
mpstat -P ALL 1 5

6. netstat, ss, and iftop (Watch the Network)

To see open ports and connections:

ss -tuln

Or, for a live bandwidth view:

sudo apt install iftop
sudo iftop

If you notice your system’s slow whenever you download, or something’s using up all your upload bandwidth, these are great tools.

7. lsof (What’s Using That File or Port?)

Ever tried to unmount a drive, only to be told it’s “busy”? Use:

sudo lsof /path/to/device

Or find what’s tying up port 80:

sudo lsof -i :80

It’s a detective’s tool for stuck files and mysterious processes.

Using Graphical Tools

Not a fan of the terminal? No problem.

  • System Monitor (GNOME): Lets you view processes, CPU, memory, and file systems with a few clicks.
  • KSysGuard (KDE): Like System Monitor, but with more graphs and customization.
  • XFCE Task Manager: Lightweight, but gets the job done.

If you’re on a desktop Linux, these tools are usually just a few clicks away in your menu.

Real-World Situations: How Monitoring Solves Problems

Scenario 1: Desktop Suddenly Slows Down

You’re writing an email and everything starts lagging. Open htop and see a “tracker-miner” process eating 90% CPU. Turns out, your search indexing went wild. Kill the process, and things bounce back.

Scenario 2: Server Disk Space Fills Up Overnight

Your web server stops serving pages. A quick df -h reveals /var/log is at 100%. You run du -sh /var/log/* and spot a single log file that grew out of control. Truncate or rotate the log, and your server’s back online.

Scenario 3: Wi-Fi Feels Slow, but Only Sometimes

You use iftop to watch network activity and notice huge spikes around 7 p.m. every day. Turns out, someone’s streaming 4K videos on the same Wi-Fi. At least now you know it’s not your router’s fault!

Interpreting Results: What’s “Normal”?

Every system is different. A gaming desktop and a Raspberry Pi server have totally different baselines. Spend a few days running these tools when things are working well—that way, you’ll notice when something’s off.

A few rules of thumb:

  • CPU at 100% for a long time (without you running something big) probably means trouble.
  • Memory filling up and swap growing means you need to close some programs or upgrade RAM.
  • Disk at 90%+ is a warning sign—cleanup needed!
  • Network usage spikes could be normal updates or something unexpected.

Advanced Monitoring: Logging and Alerts

If you’re managing a critical system, consider:

  • Setting up regular logs: Use cron to log top, df, or free output every hour.
  • Automated alerts: Tools like Nagios, Zabbix, or Monit can send you emails when things get out of bounds.
  • Historical analysis: Tools like sar (from sysstat) let you look back in time to see trends.

Troubleshooting and Best Practices

  • Don’t panic if you see a spike. Some processes run heavy for a few seconds and then finish.
  • Be careful when killing processes. Make sure you know what it does before you send a kill signal.
  • Update regularly. Software bugs can cause resource leaks.
  • Read the man pages. For any tool, try man toolname (like man top) for options and help.

Frequently Asked Questions (FAQ)

Q: Is there a single tool that does everything?
A: No one tool does it all, but htop, glances, and nmon come close. Try a few and see what feels right.
Q: Can I monitor my system remotely?
A: Yes! Use SSH to run these commands from anywhere, or set up web-based dashboards with tools like Netdata or Cockpit.
Q: Why does my free RAM seem low, even when I’m not running much?
A: Linux uses spare RAM for disk caching to speed things up. That’s normal! Check “available” memory in free -h.
Q: How do I monitor for days or weeks at a time?
A: Set up logging with sar, collectl, or a monitoring suite.
Q: Do these tools work on all Linux distributions?
A: Yes, though you may need to install some with your package manager.

Conclusion

Learning to monitor your Linux system is one of the most empowering skills you can develop. It takes the mystery out of performance issues, helps you spot and fix problems before they get out of hand, and gives you confidence that you truly understand your machine.

Start with top, htop, and df -h. Explore the graphical tools, and don’t be afraid to dig deeper with more advanced utilities as your needs grow. The more you practice, the more Linux will feel like an open book—one where you’re always in control.

Related guides

Account services are unavailable until the production backend is configured.