System Information
Understanding your system's hardware and software configuration
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.
CPU and Memory Diagnostics
Monitoring CPU and memory usage helps in identifying performance bottlenecks.
- htop is an interactive system monitor process viewer and process manager. It is designed as an alternative to the Unix program top. It shows a frequently updated list of the processes running on a computer, normally ordered by the amount of CPU usage.
htop
2. vmstat -s provides a detailed breakdown of memory usage and other related metrics since the last system boot.
vmstat -s 980492 K total memory 480208 K used memory 132040 K active memory 582364 K inactive memory 67924 K free memory 21724 K buffer memory 410636 K swap cache 0 K total swap 0 K used swap 0 K free swap
3. free -h Displays memory usage in "human-readable" format
free -h total used free shared buff/cache available Mem: 7.7G 1.9G 3.9G 487M 1.9G 5.0G Swap: 2.0G 0B 2.0G
Disk Usage and Health
Keeping track of disk usage and health is crucial for preventing data loss and ensuring efficient storage management.
1. df -h # Shows disk space usage in "human-readable" format
df -h Filesystem Size Used Avail Use% Mounted on udev 3.8G 0 3.8G 0% /dev tmpfs 783M 1.7M 781M 1% /run /dev/sda2 233G 25G 197G 12% / tmpfs 3.9G 39M 3.8G 1% /dev/shm tmpfs 5.0M 4.0K 5.0M 1% /run/lock tmpfs 783M 80K 783M 1% /run/user/1000
2. du -sh /path/to/directory Displays the size of a specific directory.
du -sh /path/to/directory 1.1G /path/to/director iostat # Reports CPU and I/O statistics.
3. fdisk -l # List all partitions
fdisk -l Disk /dev/sda: 20 GiB, 21474836480 bytes, 41943040 sectors Disk model: QEMU HARDDISK Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: gpt Disk identifier: XXXXXX-XXX-XXX-XXXX-XXXXXXXXXX Device Start End Sectors Size Type /dev/sda1 2048 4095 2048 1M BIOS boot /dev/sda2 4096 41940607 41936512 20G Linux filesystem
Process and Service Management
Managing processes and services is essential for maintaining system stability.
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.
Logs and Monitoring
Analyzing logs and monitoring system activities can help in identifying issues and tracking system performance.
dmesg # Prints kernel ring buffer messages. journalctl # Views systemd logs. journalctl -u service_name # Views logs for a specific service. 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.