Mastering Linux: The Essential Toolkit for Resource Monitoring (50+ Commands with Examples)

top 50 linux commands for resource monitoring with examples

Photo by Pankaj Patel on Unsplash

In modern infrastructure, visibility is not a luxury; it is a prerequisite for stability. As organizations move toward cloud-native architectures and multi-cluster orchestration environments, the margin for error shrinks. A single resource spike can cascade into service outages that breach strict Service Level Agreements (SLAs). For instance, high-quality services often measure uptime in “nines,” where three nines translate to nearly 9 hours of downtime per year. This is often acceptable, but a five-nine SLA restricts downtime to just five minutes annually. Achieving this precision requires more than just knowing your server is up; it demands granular control over resource consumption.

The landscape has shifted from simple command-line administration to complex system orchestration. While tools like AI-powered dashboards now offer unified visibility across multiple clusters, the foundational commands remain critical for troubleshooting and understanding low-level behavior. Whether you are managing a containerized environment or optimizing disk I/O for shared storage, the ability to interpret raw metrics is what separates reactive operations from proactive management. This guide outlines essential Linux commands that provide the depth of insight needed to maintain high availability without relying on external abstraction layers. wilo — what I learned online — I have compiled over 50 of the most critical Linux commands for resource monitoring, each with practical examples you can use immediately.

Process and CPU Utilization

When resources are under pressure, identifying which specific process is consuming cycles is often faster than checking aggregate system health. While general-purpose metrics give a snapshot, they lack the granularity required to resolve contention issues in shared environments. You need to understand individual task behavior to prevent runaway processes from starving critical services.

  • top: Provides a dynamic view of running processes sorted by resource usage (CPU or memory). Use Ctrl+C to exit and Shift+M to sort by memory. Example: top -u username shows only processes for a specific user.
  • htop: Offers an enhanced, color-coded interface over standard top, allowing you to switch between CPU and memory sorting easily. It highlights processes with high load averages in red. Example: htop -u username shows only that user’s processes with color-coded CPU usage.
  • ps aux: Lists all running processes with detailed information. Example: ps aux | grep nginx filters processes for nginx.
  • pgrep: Finds process IDs by name. Example: pgrep -u root lists all root-owned process IDs, which you can then pass to kill or ps.
  • pidstat -u 1: Focuses on per-process CPU utilization within a container context, helping you identify if a specific user space application is throttling or overusing kernel time slices. Example: pidstat -u 1 5 samples CPU usage every second for 5 seconds, so you can see a spike and when it happened.
  • uptime: Shows how long the system has been running and the load average. Example: uptime returns load averages for the last 1, 5, and 15 minutes — a load of 3.5 on a 4-core server means the system is slightly overloaded.
  • w: Shows who is logged in and what they are doing, including load averages. Example: w prints a header with uptime, logged-in users, and what each user is running.
  • chkconfig: Manages system services (runlevels) on older Linux distributions like CentOS 6. Example: chkconfig --list | grep nfs checks which runlevels NFS is configured for.
  • lscpu: Displays CPU architecture information. Example: lscpu | grep "CPU(s)" shows the total number of CPUs available.
  • mpstat -P ALL 1: Reports CPU usage per core. Example: mpstat -P ALL 2 3 shows per-core CPU stats every 2 seconds, 3 times — useful for spotting a single hot-core in a multi-core system.

In a multi-cluster environment, knowing the load average is as important as per-process metrics. If a specific cluster experiences latency spikes, correlating this with its individual process list can reveal if a background job is monopolizing threads. The distinction matters when managing dependencies where one service failure affects others across different nodes.

Memory Management and Swap Pressure

Memory leaks are the silent killers of production systems. Unlike CPU usage, which often recovers after a restart, memory allocation errors in containers or virtual machines can accumulate silently until the system runs out of RAM entirely. Monitoring swap activity is critical because it indicates that your physical memory is exhausted, forcing the kernel to slow down access speeds significantly.

  • free -h: Displays current free and used memory, including buffers, cached, and swap space. The -h flag ensures output in human-readable format (KB, MB, GB). Example: free -h shows a clean memory summary, e.g.:

    total used free shared buff/cache available

    Mem: 15Gi 4.2Gi 6.1Gi 320Mi 5.1Gi 10Gi

    Swap: 2.0Gi 128Mi 1.9Gi
  • vmstat 1: Provides a snapshot of virtual memory statistics every second. This shows how much time the system spends waiting for I/O versus processing tasks. Example: vmstat 5 3 takes 3 samples at 5-second intervals, so you can watch memory usage change over time.
  • smem: Provides detailed memory usage statistics including shared memory and cache usage. Example: smem -t shows a breakdown of total, shared, text, data, and dirty memory usage.
  • cat /proc/meminfo: Shows detailed memory information from the kernel. Example: grep -i memtotal /proc/meminfo shows total memory, while grep -i swaptotal /proc/meminfo shows total swap.
  • swapon --show: Lists active swap devices. Example: swapon --show=all displays swap configuration including type, size, and priority.
  • mprof: Memory profiler for Python applications to detect leaks. Example: mprof run python myapp.py starts a Python app under the memory profiler and logs memory usage over time.
  • valgrind --tool=memcheck: Detects memory leaks and errors in C/C++ programs. Example: valgrind --leak-check=full ./mybinary runs the binary and reports every memory leak it finds.
  • iostat -x 2: Shows disk utilization and I/O wait times for each device. Look specifically at await, which represents the average time a process waits to complete an operation on the disk. Example: iostat -x 2 shows disk stats every 2 seconds with detailed await, %util, and queue size metrics.
  • dmidecode -t memory: Displays hardware memory configuration from the SMBIOS/DMI table. Example: dmidecode -t memory | grep -E "Size|Speed" shows installed RAM size and speed per module.
  • smem -k: Shows kernel memory usage. Example: smem -k breaks down kernel vs. user space memory allocation.
  • slabtop: Shows kernel slab cache usage in real time. Example: slabtop -o orders by cache size, helping you identify which kernel data structures are consuming memory.
  • perf mem record: Samples memory access patterns. Example: perf mem record -p <pid> records memory access events for a running process.
  • cat /proc/<pid>/status: Shows memory usage for a specific process. Example: cat /proc/1234/status | grep -E "VmRSS|VmSize" shows the resident and virtual memory size of process 1234.
  • pahole: Disassembles and analyzes memory layout of structures. Example: pahole /path/to/binary shows the memory layout of C structures in the binary.

If you notice that your swap usage is growing rapidly while applications are idle, this signals that the application might be holding onto memory it does not need. In high-performance storage scenarios where latency must be minimized, unnecessary swapping can degrade performance noticeably compared to dedicated persistent disks. Identifying these trends early prevents sudden crashes during peak load periods.

Disk I/O and Storage Health

Storage is frequently the bottleneck in resource-constrained environments. While Network File Shares (NFS) allow multiple instances of an application to serve in high availability modes, traditional NFS implementations are often slower than SAN-based persistent disks. Managed services can mitigate this latency, but you must still monitor the underlying block-level performance.

  • iostat -x 2: Shows disk utilization and I/O wait times for each device. Look specifically at await, which represents the average time a process waits to complete an operation on the disk. Example: iostat -x 2 shows disk stats every 2 seconds with detailed await, %util, and queue size metrics.
  • df -h: Reports filesystem usage in human-readable terms. This helps you identify when storage quotas are approaching limits before they cause write failures. Example: df -h / checks the root partition and shows used/available space in GB.
  • du -sh: Estimates file space usage. Example: du -sh /var/log shows total size of the log directory, so you can see how much disk space your logs are consuming.
  • lsblk: Lists block devices in a tree format. Example: lsblk -f shows file system information for each block device, including mount points and file system type.
  • fdisk -l: Lists disk partitions. Example: sudo fdisk -l shows all partitions on all disks with their sizes, types, and boot flags.
  • smartctl -a /dev/sda: Displays SMART data for disk health monitoring. Example: sudo smartctl -H /dev/sda checks the health status and returns PASS/FAIL, while sudo smartctl -a /dev/sda shows a full report including error counts and temperature.
  • badblocks: Scans a device for bad blocks. Example: sudo badblocks -v /dev/sda1 performs a thorough check and prints every bad block it finds.
  • dmesg | grep -i error: Shows kernel messages related to disk errors. Example: dmesg | grep -i error | tail -20 shows the last 20 disk-related error messages from the kernel log.
  • lsattr: Lists file attributes on a filesystem. Example: lsattr /etc/hostname shows immutable flags — if you see an i in the attribute list, the file cannot be deleted or modified, which is useful to check when a config file won’t update.
  • lsof: Lists open files. Example: lsof /var/log/syslog shows which processes currently have the syslog file open, helping you identify what is writing to it.
  • inotifywait: Monitors filesystem events. Example: inotifywait -m /home monitors home directory changes and prints every create, modify, or delete event in real time.
  • stat: Displays file or file system status. Example: stat /etc/passwd shows detailed file information including size, permissions, and last modification time.
  • dd if=/dev/zero of=temp.bin bs=1M count=100: Creates a test file to simulate disk usage. Example: dd if=/dev/zero of=temp.bin bs=1M count=100 writes 100MB of zeros to a file, which you can use to test disk write performance or fill up a filesystem for testing cleanup scripts.
  • truncate -s 1G testfile: Creates a sparse file of 1GB for testing. Example: truncate -s 1G testfile creates a 1GB file that takes almost no disk space until you actually write into it.
  • find / -type f -size +100M: Finds files larger than 100MB. Example: find / -type f -size +100M -exec ls -lh {} \; finds all files larger than 100MB and prints their sizes, which is useful for locating large files that are wasting space.
  • rsync -avh --progress source/ dest/: Efficiently syncs files with progress tracking. Example: rsync -avh --progress /var/log /backup/logs/ copies the log directory to a backup location while showing a progress bar and preserving all attributes.
  • tar -czvf archive.tar.gz /var/log: Creates a compressed archive of logs. Example: tar -czvf /backup/logs-$(date +%F).tar.gz /var/log creates a dated compressed tarball of the log directory for backup.

In distributed file systems, I/O wait times can correlate with network congestion or storage controller bottlenecks. If your application relies on shared storage for consistency across multiple pods, high await values indicate that the disk subsystem cannot keep up with requests. This is particularly relevant when scaling out; if you mount NFS shares to multiple Pods and experience latency spikes, checking I/O statistics helps determine if it’s a network issue or a hardware limitation.

Network Connectivity and Interface Configuration

Network interfaces are often misconfigured in complex setups, especially when dealing with legacy protocols like IPv6 rapid deployment (6rd) on specific ISP configurations. Understanding how packets traverse your infrastructure is vital for diagnosing connectivity issues that manifest as resource starvation due to timeouts or dropped connections.

  • ss -tunap: Lists all TCP and UDP sockets in non-blocking mode, showing state information more efficiently than netstat. It reveals listening ports and active connections without consuming excessive memory. Example: ss -tuln shows only listening ports, which is the fastest way to see what services are exposed.
  • ip addr show: Displays detailed configuration for network interfaces, including IPv4 and IPv6 addresses. This is crucial when dealing with static assignments or tunneling configurations that require specific prefix delegation from the ISP. Example: ip -s link shows interface statistics; use ip -6 addr to see just IPv6 addresses.
  • ip route: Displays the routing table. Example: ip route get 8.8.8.8 shows the route to Google’s DNS, telling you exactly how a packet to that IP will be routed — useful when troubleshooting why a specific destination is unreachable.
  • netstat -tuln: Lists listening TCP and UDP ports. Example: netstat -an | grep LISTEN shows all listening ports, helping you identify which services are exposed.
  • ping: Tests connectivity to a host. Example: ping -c 4 google.com sends 4 packets to Google with a 1-second interval, so you get a quick reachability test with round-trip time statistics.
  • traceroute: Shows the route packets take to a destination. Example: traceroute google.com traces the path with TTL increments, so you can see every hop (router) between your host and Google.
  • mtr: Combines ping and traceroute for continuous monitoring. Example: mtr google.com provides real-time path analysis, showing packet loss and latency at each hop as it runs continuously.
  • tcpdump: Captures network packets. Example: sudo tcpdump -i eth0 -n captures packets on interface eth0 and prints them as IP addresses only (no DNS lookups), so you can see raw traffic.
  • curl: Transfers data from or to a server. Example: curl -I https://example.com checks HTTP headers for a HEAD request, so you can verify the server responds and what status code it returns.
  • wget: Downloads files from the web. Example: wget https://example.com/file.zip downloads the file to the current directory — use wget -c to resume an interrupted download.
  • host: Performs DNS lookups. Example: host google.com resolves the domain and returns the IP address, plus any MX records or other DNS data.
  • dig: DNS lookup utility. Example: dig google.com shows all DNS records including A, AAAA, CNAME, and NS records — use dig google.com MX to query only mail records.
  • nslookup: Queries DNS to obtain domain name or IP address mapping. Example: nslookup google.com provides a simple DNS query that prints the resolved IP address.
  • route: Manages the IP routing table. Example: route -n shows the routing table with numeric addresses, so you can see the gateway and interface for each subnet.
  • iftop: Displays bandwidth usage in real-time. Example: sudo iftop -i eth0 shows bandwidth per connection, so you can see which remote hosts are consuming your network bandwidth.
  • nload: Network traffic monitor. Example: nload eth0 shows traffic on eth0 with a total, min/max, and current bandwidth graph.
  • bmon: Bandwidth monitor and traffic visualization tool. Example: bmon -p eth0 monitors eth0 with real-time graphs and detailed statistics for each interface.
  • tc: Traffic control utility for configuring network traffic scheduling. Example: tc qdisc show shows queue disciplines on all interfaces, useful when a firewall or bandwidth limit is unexpectedly dropping traffic.
  • iptables: Configures firewall rules. Example: iptables -L -n lists current firewall rules in numeric form, so you can see which ports are open and which chains are active.
  • nstat: Network statistics. Example: nstat displays IPv4/IPv6 protocol statistics including packets received, dropped, and errors per second.
  • conntrack: Netfilter connection tracking tool. Example: conntrack -L lists all active connections tracked by the kernel, which is useful for verifying that NAT and firewall connection tracking is working correctly.

In environments where legacy networks rely on tunneling technologies rather than native IPv6 support, manual configuration can be required to ensure proper traffic flow. While modern tools offer unified visibility across clusters, knowing how interfaces are assigned locally remains essential for troubleshooting packet drops at the ingress point before they impact application logic.

Disk Space and File System Monitoring

Disk space exhaustion is a leading cause of application downtime. Knowing how to find what is consuming space, check filesystem integrity, and manage mount points is a daily operational requirement.

  • df -h: Reports filesystem usage in human-readable terms. Example: df -h / checks the root partition and shows used/available space in GB.
  • du -sh: Estimates file space usage. Example: du -sh /var/log shows total size of the log directory, so you can see how much disk space your logs are consuming.
  • ls -lh: Lists files with human-readable sizes. Example: ls -lh /var/log shows all log files with sizes in KB, MB, or GB.
  • fdisk -l: Lists disk partitions. Example: sudo fdisk -l shows all partitions on all disks with their sizes, types, and boot flags.
  • lsblk: Lists block devices. Example: lsblk -f shows file system information for each block device, including mount points and file system type.
  • mount: Displays mounted filesystems. Example: mount | grep /mnt shows all filesystems currently mounted under /mnt.
  • umount: Unmounts filesystems. Example: umount /mnt/data safely unmounts the /mnt/data filesystem.
  • fsck: File system consistency check. Example: fsck -n /dev/sda1 checks the filesystem without making changes, so you can see if there are errors.
  • tune2fs: Adjusts tunable filesystem parameters. Example: tune2fs -l /dev/sda1 lists filesystem metadata including the volume name and last mounted time.
  • resize2fs: Resizes ext2/ext3/ext4 filesystems. Example: resize2fs /dev/sda1 resizes the filesystem to fill the partition, which is useful after extending a disk with a cloud provider.
  • mkfs: Creates a filesystem. Example: mkfs.ext4 /dev/sdb1 formats the partition as ext4, which you would do after creating a new volume.
  • e2fsck: ext2/ext3/ext4 filesystem check. Example: e2fsck -f /dev/sda1 checks and repairs the filesystem, forcing a check even if the filesystem is clean.
  • dumpe2fs: Displays filesystem information. Example: dumpe2fs /dev/sda1 prints detailed filesystem information including block size, fragment size, and mount count.
  • tune2fs -l: Lists filesystem metadata. Example: tune2fs -l /dev/sda1 shows the volume name, filesystem state, and last mounted directory.
  • lsattr: Lists file attributes. Example: lsattr /etc/hostname shows immutable flags — an i means the file cannot be modified or deleted.
  • chattr: Changes file attributes. Example: chattr +i /etc/hostname makes the hostname immutable, preventing accidental modification.
  • file: Determines file type. Example: file /etc/passwd tells you the file type is “ASCII text” — useful when a file is corrupted or misidentified.
  • head: Outputs the first part of files. Example: head -20 /var/log/syslog shows the first 20 lines of the syslog file, so you can quickly see what happened at startup.
  • tail: Outputs the last part of files. Example: tail -f /var/log/syslog follows the file in real time, so you can watch new log entries as they are written.
  • less: Views file contents page by page. Example: less /var/log/syslog opens the file in a pager where you can search and navigate with arrow keys.
  • more: Views file contents page by page. Example: more /var/log/syslog views the file page by page.
  • sed: Stream editor for filtering and transforming text. Example: sed 's/old/new/g' /var/log/syslog replaces all occurrences of “old” with “new” and prints the result.
  • awk: Pattern scanning and processing language. Example: awk '{print $1}' /etc/passwd prints the first field (username) of every line in the passwd file.
  • grep: Searches text using patterns. Example: grep -i error /var/log/syslog finds all lines containing “error” (case-insensitive), so you can quickly find errors in logs.

System Performance and Resource Monitoring

Beyond the core monitoring commands, these tools give you a complete picture of system health — from CPU and memory to network and disk.

  • top: Dynamic process viewer. Example: top -bn1 runs top in batch mode and prints one snapshot, so you can capture a clean view without it staying open on the terminal.
  • htop: Enhanced process viewer. Example: htop -u username shows only that user’s processes, so you can focus on what a specific user is running.
  • ps: Process status. Example: ps -ef shows all processes in a full-format listing, which is the standard way to see what is running on the system.
  • pidstat: Per-process statistics. Example: pidstat -u 1 shows CPU usage for all processes every second, so you can catch a process that starts consuming CPU.
  • mpstat -P ALL 1: CPU statistics. Example: mpstat -P ALL 1 reports CPU usage for every core every second, so you can spot a single overloaded core.
  • vmstat: Virtual memory statistics. Example: vmstat 2 5 takes 5 samples at 2-second intervals, so you can see how memory and CPU usage change over time.
  • iostat: I/O statistics. Example: iostat -x 2 shows detailed disk utilization and I/O wait every 2 seconds, so you can catch I/O bottlenecks.
  • sar: System activity reporter. Example: sar -u 1 5 reports CPU utilization every 1 second for 5 samples, and sar -r 1 5 reports memory utilization.
  • uptime: System uptime and load. Example: uptime shows how long the system has been running and the load averages for the last 1, 5, and 15 minutes.
  • w: Who is logged in. Example: w shows all logged-in users, what they are running, and the 1-minute load average.
  • dmesg: Kernel ring buffer. Example: dmesg | tail -20 shows the last 20 kernel messages — useful for catching recent hardware or driver issues.
  • journalctl: Systemd journal query. Example: journalctl -u nginx -f follows the nginx service logs in real time, so you can watch what nginx is doing.
  • systemctl: Systemd control. Example: systemctl status nginx shows the status of the nginx service, including whether it is running, its PID, and recent log entries.
  • service: Service control. Example: service nginx restart restarts the nginx service — useful on systems that still use the traditional init system.
  • initctl: Init control. Example: initctl list lists all init jobs and their statuses, which is useful on systems using Upstart.
  • runlevel: System runlevel. Example: runlevel prints the previous and current runlevel, so you can see if the system booted normally.
  • telinit: Change system runlevel. Example: telinit 3 switches the system to runlevel 3 (multi-user, non-graphical).
  • halt: Halt the system. Example: halt stops the system immediately, which you would use when you need to power off.
  • reboot: Reboot the system. Example: reboot restarts the system, so you can apply kernel updates or fix a broken configuration.
  • shutdown: Shut down the system. Example: shutdown -h +5 schedules a shutdown in 5 minutes, giving users warning before the system goes down.
  • poweroff: Power off the system. Example: poweroff powers off the machine immediately — use with caution on production systems.
  • login: Log in to the system. Example: login starts a new login session, which you can use to test a fresh login after a config change.

Container and Orchestration Visibility

As infrastructure moves toward containers, managing resource limits becomes a shared responsibility between the host and the container runtime. You need to monitor not just what is running inside the container, but how it interacts with the underlying kernel. This allows you to enforce fine-grained control over permissions without compromising system integrity.

  • docker stats: Displays real-time resource usage (CPU, Memory) for all containers in your environment. It provides an immediate view of which workloads are consuming the most resources. Example: docker stats --no-stream shows a static snapshot, or docker stats with no arguments gives a live, continuously updating view of every container’s CPU, memory, network I/O, and disk I/O.
  • docker top: Displays running processes in a container. Example: docker top container_name shows all processes running inside the container.
  • docker inspect: Returns low-level information on a container. Example: docker inspect container_name shows configuration, IP address, and resource limits.
  • docker logs: Fetches the logs of a container. Example: docker logs -f container_name follows log output in real time, so you can watch what the container is doing as it happens.
  • kubectl top pods: Shows resource usage for Kubernetes pods. Example: kubectl top pods -n default shows CPU and memory usage for all pods in the default namespace.
  • kubectl top nodes: Shows resource usage for cluster nodes. Example: kubectl top nodes shows CPU and memory usage for every node in the cluster.
  • kubectl get pods: Lists pods. Example: kubectl get pods --all-namespaces shows all pods across every namespace, which is the first command you run when troubleshooting a cluster.
  • kubectl describe pods: Detailed pod information. Example: kubectl describe pod pod_name shows pod details including events, conditions, and resource requests/limits.
  • kubectl logs: Fetches pod logs. Example: kubectl logs pod_name shows the logs of a pod, and kubectl logs -f pod_name follows them in real time.
  • kubectl exec: Runs commands in a container. Example: kubectl exec -it pod_name -- /bin/bash opens a shell inside the container.
  • kubectl port-forward: Forwards local ports to a pod. Example: kubectl port-forward pod_name 8080:80 forwards your local port 8080 to the pod’s port 80.
  • kubectl rollout status: Checks rollout status. Example: kubectl rollout status deployment/deployment_name shows the status of a deployment rollout.
  • kubectl scale: Scales a deployment. Example: kubectl scale deployment/deployment_name --replicas=3 scales the deployment to 3 replicas.
  • kubectl apply: Applies configuration. Example: kubectl apply -f deployment.yaml applies a deployment manifest, and kubectl apply -f . applies all manifests in the current directory.
  • kubectl delete: Deletes resources. Example: kubectl delete pod pod_name deletes the pod.
  • kubectl label: Adds labels. Example: kubectl label node node_name key=value adds a label to the node.
  • kubectl annotate: Adds annotations. Example: kubectl annotate node node_name key=value adds an annotation to the node.
  • kubectl config: Manages kubeconfig files. Example: kubectl config get-contexts lists all contexts, so you can switch between clusters.
  • kubectl cluster-info: Displays cluster information. Example: kubectl cluster-info shows the Kubernetes master and services running in the cluster.
  • kubectl auth: Handles authorization. Example: kubectl auth can-i get pods checks whether your current user has permission to get pods.
  • kubectl debug: Creates debug pods. Example: kubectl debug pod_name -it --image=busybox creates a debug pod with a busybox image, which you can use to inspect a failing pod.
  • kubectl cp: Copies files to/from a container. Example: kubectl cp pod_name:/path /local/path copies files from the pod to your local machine.
  • kubectl attach: Attaches to a running container. Example: kubectl attach pod_name -it attaches to the container’s standard input/output.

When managing multi-cluster Kubernetes operations, unified visibility is key. While external dashboards offer high-level metrics, these CLI tools allow for deep-dive troubleshooting when the dashboard fails to pinpoint the root cause. This combination ensures that if an alert triggers across clusters, you can immediately verify local resource constraints without needing third-party access.

Conclusion

Resource monitoring is not merely about observing numbers; it is about maintaining the integrity of your SLAs and ensuring continuous availability. Whether you are tracking five minutes of allowable downtime per year or managing I/O latency for shared storage, these tools provide the foundation for decision-making. By mastering process identification, memory pressure detection, disk performance metrics, network configuration, and container visibility, you create a defense against resource exhaustion before it becomes an outage. The most effective strategy is not relying solely on automated dashboards but understanding the underlying metrics to validate system health at every layer of complexity. wilo — what I learned online — I encourage you to experiment with these commands in a test environment and build your own monitoring playbook.


Frequently Asked Questions (FAQ)

How can I identify specific processes consuming high system resources?

The top command provides a dynamic view of running tasks sorted by CPU or memory usage, allowing you to pinpoint problematic activities quickly. For enhanced visibility, using htop offers color-coded sorting options that highlight processes with high load averages in red for immediate detection. Example: top -u username limits the view to one user, and ps aux --sort=-%cpu sorts by CPU usage.

What metrics indicate potential memory exhaustion or performance degradation?

You should monitor swap space and buffers using the free -h command to ensure physical memory is not being exhausted by applications. Additionally, observing vmstat output reveals how much time the system spends waiting for I/O versus processing tasks, signaling silent slowdowns before they cause a crash. Example: vmstat 1 gives a continuous snapshot so you can see exactly when memory pressure starts.

Why is monitoring disk I/O critical alongside CPU and Memory metrics?

Storage often acts as the primary bottleneck in resource-constrained environments, especially when utilizing Network File Shares or shared storage solutions. Identifying latency spikes early prevents service outages that could breach strict Service Level Agreements during peak load periods. Example: iostat -x 2 shows await and %util, which tell you if a disk is the bottleneck.

How do these foundational commands compare to modern AI-powered dashboards?

While AI tools provide unified visibility across clusters, these Linux commands remain essential for interpreting raw metrics and understanding low-level system behavior. Relying solely on abstraction layers can obscure the root cause of contention issues in shared environments or containerized systems. Example: kubectl top pods gives you the same data as a dashboard but on demand, without any infrastructure dependencies.

What is the best way to monitor memory leaks in production?

Use vmstat 1 for a continuous snapshot of memory statistics and free -h for a quick overview. For deeper analysis, tools like valgrind --tool=memcheck and smem provide detailed memory usage breakdown for applications and processes. Example: valgrind --leak-check=full ./myapp will report every memory leak it finds in a C/C++ program.

How do I check disk health on Linux?

Use smartctl -a /dev/sda to view comprehensive SMART data including health status, error counts, and disk temperature. The -H flag provides a quick health check summary. Example: sudo smartctl -H /dev/sda returns PASS or FAIL on the health check, so you can catch a failing disk before it crashes.

Can these commands help with Kubernetes resource management?

Yes, kubectl top pods and kubectl top nodes provide real-time resource usage for your cluster. Combined with docker stats for container-level detail, you have a comprehensive view of resource consumption across the stack. Example: kubectl top nodes shows CPU and memory usage per node, so you can see which nodes are under pressure.


Related Articles

0 0 votes
Article Rating
guest
0 Comments
Oldest
Newest Most Voted
Scroll to Top