Operating Systems  

Linux Server Monitoring: Essential Commands Every Developer Should Know

Introduction

Monitoring a Linux server is an essential skill for developers, DevOps engineers, and system administrators. Whether you're hosting a web application, database, API, or microservice, understanding server health helps identify performance issues before they impact users.

Linux provides several built-in commands that allow you to monitor CPU usage, memory consumption, disk space, network activity, and running processes.

In this article, you'll learn the most important Linux monitoring commands every developer should know.

Why Server Monitoring Matters

A server may experience:

  • High CPU usage

  • Memory shortages

  • Disk space issues

  • Network bottlenecks

  • Application crashes

Without monitoring:

Issue Occurs
     ↓
Users Experience Problems
     ↓
Investigation Starts

With proper monitoring:

Issue Detected Early
        ↓
Quick Resolution

This improves system reliability and uptime.

Check System Uptime

The uptime command shows how long the server has been running.

uptime

Example output:

10:30:15 up 25 days, 5:20,
load average: 0.35, 0.42, 0.50

Useful information:

  • System uptime

  • Active users

  • Load averages

Monitor CPU and Processes

The top command provides real-time system monitoring.

top

Displays:

  • CPU usage

  • Memory usage

  • Running processes

  • System load

To exit:

q

For many developers, top is the first troubleshooting command.

Use htop for Better Visualization

If installed:

htop

Benefits:

  • User-friendly interface

  • Color-coded metrics

  • Easy process management

Install on Ubuntu:

sudo apt install htop

Many administrators prefer htop over top.

Check Memory Usage

View memory consumption:

free -h

Example:

Total: 8GB
Used: 4GB
Free: 3GB

The -h flag displays human-readable values.

This command helps identify memory pressure.

Check Disk Space

Monitor disk usage:

df -h

Example output:

Filesystem   Size Used Avail
/dev/sda1     50G  20G   30G

Important for:

  • Application servers

  • Database servers

  • Log-heavy systems

Running out of disk space can cause service failures.

Find Large Directories

Identify storage-consuming folders.

du -sh *

Example:

2G logs
500M backups

Useful when investigating disk usage issues.

Monitor Running Processes

View all running processes:

ps aux

Search for a specific application:

ps aux | grep nginx

Common use cases:

  • Verify services are running

  • Investigate high CPU usage

  • Troubleshoot applications

Monitor Network Connections

Check active network connections.

ss -tuln

Shows:

  • Listening ports

  • TCP connections

  • UDP connections

Useful for debugging connectivity issues.

Check Open Ports

View listening services:

netstat -tulnp

Example:

Port 80
Port 443
Port 3306

Helps verify web servers and databases are accessible.

View System Logs

Linux logs are essential for troubleshooting.

View recent logs:

journalctl -xe

For specific services:

journalctl -u nginx

Logs often reveal the root cause of issues.

Monitor Disk I/O

Check disk activity:

iostat

Useful for:

  • Database servers

  • File servers

  • Storage performance analysis

Install if needed:

sudo apt install sysstat

Real-World Troubleshooting Example

Suppose your API becomes slow.

Investigation process:

top
 ↓
Check CPU

free -h
 ↓
Check Memory

df -h
 ↓
Check Disk

journalctl
 ↓
Check Logs

Using these commands together helps quickly identify the problem.

Best Practices

When monitoring Linux servers:

  • Check disk usage regularly.

  • Monitor CPU and memory trends.

  • Review logs frequently.

  • Set up alerting tools.

  • Investigate unusual spikes.

  • Remove unnecessary processes.

These habits help maintain healthy systems.

Conclusion

Linux provides powerful built-in tools for monitoring server health and diagnosing performance issues. Commands such as top, htop, free, df, ps, ss, and journalctl give developers valuable insight into system behavior.

Whether you're managing web applications, APIs, databases, or cloud servers, understanding these commands will help you troubleshoot problems faster and maintain reliable systems. Mastering Linux monitoring is a foundational skill for every developer working with production environments.