1. System Information
Understanding your system's hardware and software configuration is the first step in diagnostics.
uname -a # Displays kernel version and system architecture. lscpu # Provides detailed information about the CPU. lsblk # Lists all available block devices. lsusb # Shows USB devices connected to the system. lspci # Lists PCI devices.
2. CPU and Memory Diagnostics
Monitoring CPU and memory usage helps in identifying performance bottlenecks.
top/htop # Real-time process monitoring. vmstat # Reports virtual memory statistics. free -h Displays memory usage. mpstat: Reports CPU usage.
3. Disk Usage and Health
Keeping track of disk usage and health is crucial for preventing data loss and ensuring efficient storage management.
df -h # Shows disk space usage. du -sh /path/to/directory # Displays the size of a specific directory. fdisk -l # Lists all partitions. smartctl -a /dev/sda # Checks the health of a disk (requires smartmontools). iostat # Reports CPU and I/O statistics.
5. Process and Service Management
Managing processes and services is essential for maintaining system stability.
Commands:
ps aux: Lists all running processes.
systemctl status service_name: Checks the status of a service.
journalctl -u service_name: Views logs for a specific service.
kill -9 process_id: Forces termination of a process.
nice and renice: Adjusts process priority.
bash
ps aux
systemctl status service_name
journalctl -u service_name
kill -9 process_id
nice -n 10 process_name
renice -n 10 process_id
6. Logs and Monitoring
Analyzing logs and monitoring system activities can help in identifying issues and tracking system performance.
Commands:
dmesg: Prints kernel ring buffer messages.
journalctl: Views systemd logs.
tail -f /var/log/syslog: Continuously displays system log updates.
sar: Collects, reports, and saves system activity information (requires sysstat).
uptime: Shows how long the system has been running and load averages.