Skip to content

Linux diagnostics

System Information

  • Display general information about the system:

    uname -a
    
  • Show system architecture and kernel version:

    lscpu
    
  • Check OS version and distribution:

    cat /etc/os-release
    

Disk and Filesystem Diagnostics

  • Check disk usage by filesystem:

    df -h
    
  • Check filesystem errors:

    fsck /dev/sdX
    
  • Display file and directory disk space usage:

    du -h --max-depth=1
    
  • View disk partitions:

    lsblk
    
  • Test disk I/O speed:

    hdparm -tT /dev/sdX
    

Memory Diagnostics

  • Check free and used memory:

    free -h
    
  • Real-time memory usage summary:

    watch -n 1 free -h
    
  • Analyze memory usage by process:

    smem
    

    Install smem using sudo apt install smem or your package manager.


CPU Performance

  • Monitor real-time processes and CPU usage:

    top
    
  • Show live CPU usage per core:

    htop
    

    Install htop using sudo apt install htop or your package manager.

    • Display CPU frequencies:
    cpufreq-info
    

    Install cpufrequtils if not pre-installed.


Network Diagnostics

  • Display active network interfaces:

    ip a
    
  • Test connectivity (ping a server):

    ping google.com
    
  • Display open ports and listening services:

    netstat -tuln
    

    Use ss -tuln on modern systems (preferred).

    • Check network speed:
    speedtest-cli
    

    Install speedtest-cli using sudo apt install speedtest-cli.


Logs and Errors

  • View system logs:

    journalctl -xe
    
  • Display kernel messages:

    dmesg | tail -n 50
    
  • Check authentication logs:

    cat /var/log/auth.log
    

Process Diagnostics

  • Display active processes (real-time):

    ps aux
    
  • Kill a hung process (replace <pid> with the process ID):

    kill -9 <pid>
    
  • Find and debug a specific process:

    pgrep -a <process_name>
    

Hardware Information

  • Check hardware (detailed overview):

    lshw
    
  • Check battery status (for laptops):

    upower -i /org/freedesktop/UPower/devices/battery_BAT0
    
  • Show PCI devices:

    lspci
    
  • List USB devices:

    lsusb
    

System Load and Uptime

  • Check system uptime:

    uptime
    
  • Analyze load averages:

    w
    
  • Read detailed stats of CPU load:

    vmstat 1
    

Package Management

  • Check installed packages (Debian-based):

    dpkg --get-selections
    
  • Search for a package:

    apt search <package_name>
    
  • Update and upgrade packages:

    sudo apt update && sudo apt upgrade
    

Debugging Kernel Issues

  • Debug kernel modules:

    lsmod
    dmesg | grep <module_name>
    
  • Remove a kernel module:

    sudo modprobe -r <module_name>
    

Storage Device Health

  • SMART disk health check:

    sudo smartctl -a /dev/sdX
    

    Install smartmontools for smartctl if not installed.

  • Test for bad blocks:

    sudo badblocks -v /dev/sdX
    

Backup and Recovery

  • Create disk or partition backup:

    dd if=/dev/sdX of=backup.img bs=64K conv=noerror,sync
    
  • Compress backup:

    gzip backup.img
    

Security Diagnostics

  • Check open ports for services:

    sudo nmap -sT localhost
    
  • Check file permissions and ownership:

    ls -l
    
  • Detect SUID binaries:

    find / -perm -4000
    

Useful Extras

  • Show the last system reboot:

    last reboot
    
  • Monitor all system services:

    systemctl list-units --type=service
    
  • Check a service's status:

    systemctl status <service_name>