How to Monitor Linux with Command-Line Tools

Monitoring the seemingly vast ocean of Linux nuances requires a little patience, and a handful of useful utilities. After discovering a few unresponsive NodeJS applications and other Apache-hosting-related issues, I went in search of the perfect system-monitoring utilities.

top – Linux Process Monitoring

Most of the issues you will encounter in Linux will usually have to do with a process consuming too many system resources like memory or CPU.

Just start up top, and by default, it will show you the CPU utilization of each process. you should shart the program using top -c or the process name may be truncated.

Aye! Where’s the rest of my text

top with the -c argument.

By pressing <SHIFT><F>, you can sort and filter on many useful metrics, such as memory usage and CPU utilization.

Sorting and filtering option a-plenty.

htop – A Fancier Linux Process Monitor

If you want to make a better top utility, stick an “H” in front. The htop utility does everything the top utility does, but adds a process tree view, some ASCII graphs, and on-screen keyboard command bar.

Graphs – the stuff dreams are made of.

df – Disk Free Utility

When you just need to know the amount of free space, df is a very fast and compact utility.

78%? I Feel so used

ncdu – NCurse Disk Usage Viewer

Unlike du which will list every file and folder and the space being used by it, ncdu will produce nice graphs and stats of the file and directory sizes and allow you to navigate through to find to space hogs.

This utility is not included in many distributions by default but you can easily install in most platforms with sudo apt-get install ncdu.

lof – List of Open Files

If you really like lists, this utility will really make you smile. Entering lsof without any arguments will list all the files in use on your Linux system. Better to enter lsof | more if you’re more the pagination type.

pm2 – Production Runtime and Process Manager for Node.js Applications

If you’re just looking for the vitals on your Node.js processes, and you’re using PM2 to start them, a simple pm2 status will display an overview whilepm2 log will show the node application logs.

pm2 status showing the vitals.

netstat – Network Utility Tool to Display Ports

The Netstat utility is great for showing open and waiting connections on your Linux box. My favorite is sudo netstat -tulpn which shows a list of listening ports and processes.

Wee! Apache’s working!

w3m – A Text-Based Web Browser

Hey! This isn’t a system-monitoring utility. No, but a tomato isn’t a vegetable, either.

The reason I included this little utility is that it’s very helpful in determining if a site (or Node application) is available without going through firewalls, redirects, and other obstacles.

For example, running w3m http://localhost:8080, I can tell if my Node application is running correctly.

netdata – the Britney Spears of Linux Monitoring

..of course, you could install NetData and monitor just about every key component on your system in a browser.

Thanks for reading! Please subscribe and share!


Carl Mann

Full-Stack Developer

Former owner of an I.T. consultancy business in Southampton, NY, Carl gave up the hustle-bustle of I.T. to live his dream of becoming a full-time application developer. When not busy blogging or programming, you might find Carl out taking a ride on his motorcycle or hiking off in some woodland trails.

Leave a Reply

Your email address will not be published. Required fields are marked *