As system administrators routinely maintain server health, mastering disk and memory inspection commands remains critical. This guide explores terminal-based utilities across Windows, Linux, and macOS environments, complete with practical examples and troubleshooting insights.
Understanding Storage Metrics
Before executing commands, administrators should distinguish between physical memory (RAM) and storage drives. While free -h
displays memory allocation in Linux, the df -h
command reveals mounted disk partitions. Windows administrators might prefer PowerShell's Get-Volume
combined with Get-CimInstance Win32_LogicalDisk
.
Linux Environment Tools
For Ubuntu/CentOS servers, the hdparm -I /dev/sda
command provides detailed hard drive specifications including cache size and supported DMA modes. To monitor real-time memory consumption, vmstat -s
generates formatted statistics showing active/inactive memory blocks. Advanced users often combine lsblk
with smartctl
for SSD health checks:
sudo smartctl -a /dev/nvme0n1
Windows PowerShell Techniques
Microsoft's wmic
legacy tool still proves useful for quick checks:
wmic diskdrive get status wmic memorychip get capacity
Modern PowerShell alternatives like Get-PhysicalDisk
offer richer details through pipelines:
Get-PhysicalDisk | Format-Table FriendlyName,Size,HealthStatus
macOS Terminal Approaches
BSD-based systems utilize diskutil list
for partition visualization. To assess memory pressure beyond basic top
outputs, run:
memory_pressure
The sysctl
command reveals hardware-level specifications:
sysctl hw.memsize sysctl hw.disksize
Cross-Platform Solutions
Python scripts using psutil
library create customized monitoring tools:
import psutil print(psutil.disk_usage('/')) print(psutil.virtual_memory())
Interpreting Outputs
When df
shows 90%+ disk usage, consider log rotation or archive migration. Consistently high buff/cache
values in free
outputs indicate efficient memory utilization rather than issues.
Automation Strategies
Scheduled cron jobs (Linux) or Task Scheduler scripts (Windows) can automate storage checks:
# Daily disk check 0 3 * * * /usr/bin/df -h > /var/log/disk_usage.log
Troubleshooting Scenarios
- When
fsck
reports bad sectors, immediately backup data - Mismatched RAM detection often requires reseating modules
- RAID array discrepancies may need
mdadm --examine
Security Considerations
Always sanitize storage reports containing sensitive paths or mount points before sharing. Use chmod
restrictions on log files containing hardware details.
Performance Optimization
Align command choices with monitoring needs - iostat
excels at tracking disk I/O patterns, while dmidecode
deciphers physical memory configurations.
By integrating these commands into daily workflows, administrators gain proactive control over infrastructure health. Regular practice with these tools reduces incident response times and prevents catastrophic failures.