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?

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

Top comments (0)

Image of AssemblyAI

Automatic Speech Recognition with AssemblyAI

Experience near-human accuracy, low-latency performance, and advanced Speech AI capabilities with AssemblyAI's Speech-to-Text API. Sign up today and get $50 in API credit. No credit card required.

Try the API

๐Ÿ‘‹ Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay