DEV Community

Neer S
Neer S

Posted on

Ultimate guide of Linux commands for Monitoring

Here are some essential commands to monitor the health and CPU utilization of your Ubuntu 22.04 server:

1. General System Information

  • View system information:
  uname -a
Enter fullscreen mode Exit fullscreen mode
  • Check uptime and load average:
  uptime
Enter fullscreen mode Exit fullscreen mode
  • View system memory and swap usage:
  free -h
Enter fullscreen mode Exit fullscreen mode

2. CPU Utilization

  • Display real-time CPU and memory usage:
  top
Enter fullscreen mode Exit fullscreen mode

Press q to exit.

  • Better interactive process viewer:
  htop
Enter fullscreen mode Exit fullscreen mode

(You may need to install it: sudo apt install htop)

  • Display CPU usage statistics:
  mpstat 1 5
Enter fullscreen mode Exit fullscreen mode

(Install with: sudo apt install sysstat)

3. Disk Usage

  • Check disk space usage:
  df -h
Enter fullscreen mode Exit fullscreen mode
  • Analyze disk usage in detail:
  du -sh *
Enter fullscreen mode Exit fullscreen mode

4. Network Monitoring

  • View network statistics:
  ifconfig
Enter fullscreen mode Exit fullscreen mode

(Install with: sudo apt install net-tools if not available)

  • Monitor network traffic in real-time:
  nload
Enter fullscreen mode Exit fullscreen mode

(Install with: sudo apt install nload)

5. System Logs

  • View system logs:
  journalctl -xe
Enter fullscreen mode Exit fullscreen mode
  • Tail system logs in real-time:
  tail -f /var/log/syslog
Enter fullscreen mode Exit fullscreen mode

6. Hardware Information

  • View CPU information:
  lscpu
Enter fullscreen mode Exit fullscreen mode
  • Check hardware information:
  lshw -short
Enter fullscreen mode Exit fullscreen mode

(Install with: sudo apt install lshw)

7. Resource Monitoring Utilities

  • Install sysstat for detailed monitoring tools:
  sudo apt install sysstat
Enter fullscreen mode Exit fullscreen mode

Then use commands like:

  • iostat (for I/O stats)
  • sar (system performance stats)

    • Monitor system resource usage with glances:
  sudo apt install glances
  glances
Enter fullscreen mode Exit fullscreen mode

8. Check Running Services

  • List running services:
  systemctl list-units --type=service --state=running
Enter fullscreen mode Exit fullscreen mode

9. Temperature and Sensors

  • Install and check hardware sensors:
  sudo apt install lm-sensors
  sudo sensors-detect
  sensors
Enter fullscreen mode Exit fullscreen mode

Would you like a script to combine these into a single health check?

Top comments (0)