Monitoring using Linux Commands

Listen to this Post

Linux provides powerful built-in tools for system monitoring. Here are essential commands to monitor system performance, resources, and processes:

1. System Information

– `uname -a` – Displays kernel and system information.
– `lsb_release -a` – Shows Linux distribution details.
– `hostnamectl` – Provides hostname and OS details.

2. CPU Monitoring

– `top` – Real-time CPU and process monitoring.
– `htop` (install via sudo apt install htop) – Enhanced interactive process viewer.
– `mpstat -P ALL` – Displays CPU utilization per core.
– `lscpu` – Lists CPU architecture details.

3. Memory Usage

– `free -h` – Shows RAM usage in human-readable format.
– `vmstat 1` – Displays memory, swap, and CPU stats every second.
– `cat /proc/meminfo` – Detailed memory information.

4. Disk Monitoring

– `df -h` – Lists disk space usage.
– `du -sh ` – Checks directory sizes.
– `iostat -x 1` – Monitors disk I/O statistics.
– `iotop` (requires installation) – Shows live disk I/O by process.

5. Network Monitoring

– `ifconfig` or `ip a` – Displays network interfaces.
– `netstat -tuln` – Lists active connections and listening ports.
– `ss -tuln` – Modern alternative to netstat.
– `ping ` – Checks network connectivity.
– `traceroute ` – Traces network path.

6. Process Management

– `ps aux` – Lists all running processes.
– `pstree` – Displays processes in a tree structure.
– `kill -9 ` – Force-stops a process.

7. Log Monitoring

– `tail -f /var/log/syslog` – Follows system logs in real-time.
– `journalctl -xe` – Views systemd logs (for modern Linux distros).
– `dmesg` – Displays kernel ring buffer messages.

You Should Know:

  • Use `watch -n 1 ` to refresh output every second (e.g., watch -n 1 free -h).
  • For persistent monitoring, use `nmon` or `glances` (install via package manager).
  • To check system uptime, run uptime.
  • For security auditing, use `auditd` and lynis.

What Undercode Say:

Linux command-line monitoring is essential for system administrators, DevOps engineers, and cybersecurity professionals. Mastering these commands ensures efficient troubleshooting and performance optimization. Automation with scripts (bash, Python) can enhance monitoring further.

Expected Output:

$ free -h 
total used free shared buff/cache available 
Mem: 7.7G 2.1G 3.2G 345M 2.4G 5.0G 
Swap: 2.0G 0B 2.0G 
$ top 
top - 14:30:45 up 2 days, 5:10, 2 users, load average: 0.15, 0.10, 0.05 
Tasks: 210 total, 1 running, 209 sleeping, 0 stopped, 0 zombie 
%Cpu(s): 2.3 us, 0.7 sy, 0.0 ni, 96.8 id, 0.2 wa, 0.0 hi, 0.0 si, 0.0 st 
KiB Mem : 8064164 total, 3342148 free, 2198328 used, 2523688 buff/cache 
KiB Swap: 2097148 total, 2097148 free, 0 used. 5432148 avail Mem 

Keep exploring and automating for better system insights! 🚀

References:

Reported By: Kinge Hans – Hackers Feeds
Extra Hub: Undercode MoN
Basic Verification: Pass ✅

Join Our Cyber World:

💬 Whatsapp | 💬 TelegramFeatured Image