Skip to main content

[Archive] Linux Commands – What to Check

·466 words·3 mins
Special Note: I wrote this blog post when I was early in my career as a Linux System Administrator; on an older blog back in February 2014. While I still work with Linux, it’s at a much deeper level, helping companies scale large cloud-based systems.

Not sure what to check when troubleshooting Linux systems? Well, don’t waste countless hours at 3AM troubleshooting when you can have the issue resolved in a timely manner.

Simply put – your time is valuable.

Here is a guide of valuable commands to know when troubleshooting.

What Is Running? #

  • pstree -a
    • Returns all running processes in a tree structure
  • ps -aux
    • a lists the processes of all users on the system
    • u provides the information in detail
    • x lists processes with no controlling terminal – like daemons

Listening Services #

  • netstat -a
    • List all ports with active connections
  • netstat -l
    • List all LISTENING ports
  • netstat -t
    • List all TCP ports
  • netstat -u
    • List all UDP ports
  • Combine them:
    • netstat -lt
      • List all LISTENING TCP Ports

CPU and RAM #

  • free -m
    • List available memory in MB
    • -g to list available memory in GB
  • uptime
    • Display system up time
  • top
    • Displays information such as; tasks, memory, cpu and swap
    • q to quit
    • Shift+O to sort
  • htop
    • Similar to top, but it’s a beefed up version

Hardware #

  • lspci
    • List all PCI devices
  • dmidecode
    • Display Hardware and BIOS information
  • ethtool
    • Display and change ethernet card settings

IO Performance #

  • iostat -x 2
    • Display extended disk I/O stats every 2 seconds
  • vmstat 2 10
    • Display virtual memory statistics every 2 seconds up to 10 times
  • mpstat 2 10
    • Display CPU statistics every 2 seconds up to 10 times
  • dstat --top-io --top-bio
    • Display disk stats

Mount Points and Filesystems #

  • mount
    • Mount a file system
  • umount
    • Unmount a filesystem
  • cat /etc/fstab
    • Display File System Tables
  • vgs or vgdisplay
    • Display info about volume groups
  • pvs
    • Display physical volume information
  • lvs or lvdisplay
    • Display logical volume information
  • df -h
    • “disk free,” use it to display disk size
  • lsof +D /
    • List opened files under directory

Kernel, Interrupts and Network Usage #

  • sysctl -a (use with grep)
    • Display all available kernel configuration parameters
  • cat /proc/interrupts
    • Display number of interrupts per IRQ
  • cat /proc/net/ip_conntrack (may take some time on busy servers)
    • Linux Netfilter system (iptables firewall) – Allows for advanced filtering for the state of a connection
  • ss -s
    • Display sockets summary

System Logs and Kernel Messages #

  • dmesg
    • Display message buffer of the kernel
  • less /var/log/messages
    • Display system log messages
  • less /var/log/secure
    • Display messages related to authentication and authorization. Includes failed login attempts
  • less /var/log/auth
    • Display system authorization information

Cronjobs #

  • ls /etc/cron* + cat
    • Display all crons
  • for user in $(cat /etc/passwd | cut -f1 -d:); do crontab -l -u $user; done
    • Display user specific crons