Essential Linux Commands for Monitoring System Health
This guide introduces key Linux commands—such as uptime, who, uname, du, df, free, pmap, vmstat, ifconfig, ip, netstat, top, and pstree—to help you quickly assess system status, resource usage, and process relationships, enabling effective troubleshooting and maintenance.
Viewing system uptime and load – uptime
The uptime command shows the current time, how long the system has been running, the number of logged‑in users, and the 1‑, 5‑, and 15‑minute load averages. uptime Typical output: 20:47:06 up 50 min, 1 user, load average: 0.75, 0.84, 0.93. The fields from left to right are current time, uptime, user count, and the three load averages.
Listing logged‑in users – who -a
who -adisplays each user, the terminal they are using, login time, and originating IP address.
who -aChecking OS and kernel details – uname -a
uname -aprints the operating system name, kernel version, hardware architecture, and other system information. uname -a Example output reveals Ubuntu 16.04, x86_64 architecture, and kernel build details.
Viewing environment variables – export
Running export without arguments lists all current environment variables, which can affect program behavior.
exportInspecting directory and file sizes – du -h --max-depth=1
The du command reports disk usage for each subdirectory. The -h flag makes sizes human‑readable, and --max-depth=1 limits the output to the immediate children of the current directory. du -h --max-depth=1 Adding du -sh shows only the total size of the current directory.
Displaying mounted filesystems – df -h
df -hlists each mounted filesystem, its total capacity, used space, available space, usage percentage, and mount point. df -h This information helps identify disks that are near full capacity and may need cleaning.
Checking memory usage – free -h
The free command shows total, used, and free physical memory, as well as swap usage and buffers/cache. free -h High memory consumption can cause system slowdowns or application failures.
Examining a process's memory map – pmap <pid>
pmapdisplays the memory regions used by a specific process, identified by its PID (obtainable via ps). pmap 6030 Analyzing the output helps optimise a program's memory footprint.
Viewing virtual memory statistics – vmstat
vmstatprovides a snapshot of system performance, including processes, memory, swap, I/O, and CPU usage. vmstat Values such as high si / so indicate swap activity, while a high us percentage shows CPU time spent in user space.
Getting the external IP address – curl ifconfig.me
Use curl ifconfig.me to retrieve the public IP address of the host.
curl ifconfig.meInspecting network interfaces – ifconfig -a
ifconfig -alists all network interfaces, their IP addresses, and other details.
ifconfig -aShowing IP addresses – ip addr
The modern ip addr command provides comprehensive interface and address information, often more complete than ifconfig.
ip addrChecking network connections – netstat
netstatdisplays active network connections, listening ports, and routing tables, useful for diagnosing network issues.
netstat -tulnpMonitoring CPU and memory usage – top
The interactive top utility shows real‑time CPU load, memory consumption, running tasks, and per‑process statistics.
topViewing process hierarchy – pstree
pstreeprints a tree view of processes, revealing parent‑child relationships.
pstreeDynamic monitoring with watch
Combine watch with other commands to refresh output at regular intervals, e.g., every second.
watch -n 1 cat /proc/meminfo watch -n 1 cat /proc/net/devThis allows continuous observation of memory or network statistics.
Conclusion
These built‑in Linux commands provide a quick and effective way to monitor system health, diagnose problems, and maintain performance. For deeper details, consult the corresponding manual pages with man <command>.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
