Useful commands for checking server status

When things go wrong it's very tempted in today's cloud based world to simply kill the machine and start again, sometimes however you will really need to figure out exactly where an issue lies, especially for recurring issues. Here is a selection of tools and commands for your tool belt so you can quickly figure out what the issue is when servers start misbehaving.

This list is also available on Github.

General stats tools


Shows average load at a glance.



Print system and kernal messages

# see system error and warning messages
dmesg --level=err,warn


Displays linux process and system stats.

# monitor specific processes
top -p{pid},{pid}
# monitor processes for a user
top -u {username}


Similar to top but with a more detailed UI.



Reports processor and io statistics

# display a report every n seconds
iostat -d {seconds}
# extended report in megabytes
iostat -mx


Shows detailed processor stats

# show details for each processor
mpstat - A
# display a report every n seconds
mpstat -A {seconds}


Per process disk read/write

# monitor processes actively doing IO
iotop -o
# monitor specific processes
top -p{pid},{pid}
# monitor processes for a user
top -u {username}


Network traffic stats for a named interface (defaults to eth0)

# monitor traffic for a specific interface
iftop -i eth0
# disable hostname resolution
iftop -n -i eth0
# show ports
iftop -P -i eth0


System metric collection.

Sysstat must be installed and enabled like so (example is for Ubuntu):

sudo apt-get install sysstat
# activate
vi /etc/defaults/sysstat
# change  ENABLED="false" to ENABLED="true"


System metric reporting.

With sysstat installed and enabled (see above) sar can be used to process and display the logs generated by it.

# memory utilization
sar -r
#CPU stats
sar -t
# IO stats
sar -b
# All stats
sar -A


Stats for a process

pidstat {PID}

Network diagnostics

Note The -n flag will turn off address resolution for many of these commands.


Configure network interfaces, will also display the status of devices.

# display summary of interfaces
# limit to a particular interface
ifconfig eth0
# list all interfaces, including those that are down
ifconfig -a
# bring and interface up or down
ifconfig eth0 up
ifconfig eth0 down


Configure wireless network interfaces, will also display the status of devices. Note that ifconfig can still be used to perform standard configuration on wireless devices, this command covers configuration that applies to wirelss devices such as frequency, mode and channel.

# display summary of interfaces
# limit to a particular interface
iwconfig wlan0
# set frequency
iwconfig wlan0 freq 2.437G


Show and manipulate network routes for local traffic.

# list all static routes
route -n
# add a route via a gateway
route add {Target IP} gw {Gateway}
# delete a routes
route del {Target IP}


Network scanner/discovery tool, can display a range of information from open ports to ssl cert info and more.

# see if port is open
nmap -p 80 {IP or Hostname}


Tool for displaying a wide array of network information.

# List processes listening on ports
sudo netstat -nlp
# Limit to TCP connections
sudo netstat -tnlp


Shows raw fraffic on a network, has many filtering options for narrowing down what raw traffice is displayed.

# show all traffic for an interface
tcpdump -i eth0
# show traffic for a host
tcpdump -n host {host}
# show traffic not involving host
tcpdump -n not {host}
# show traffic for a port
tcpdump -n port {port}
# show traffic for a host and interface,
# use tee to log to a file and display at the same time
tcpdump -n -i {interface} host {host} | tee file

DNS tools


Tool for querying name servers.

# query a domain
nslookup {host}
# query a domain using a specific nameserver
nslookup {host} {nameserver}


More detailed DNS query tool, can be used to show detailed DNS information.

# show DNS information for a host
# show DNS information via a specific name server
dig @
# show the route for a DNS lookup
dig +trace
# query specific DNS information
dig host {NS|MX|TXT

System boot

Run levels

/etc/rc{0-6}.d Cotains scripts for each runlevel, 6 = reboot, 1 = single user mode. Scripts start with letters to denote when they run, S means run when switching to level, K means run when leaving level, D means disabled.

# switch to runlevel
sudo init 0-6

/etc/rcS.d Scripts to run when switching between runlevel

/etc/init.d Scripts for controlling services

/etc/init Upstart scripts (Ubuntu)


Startup control tool for upstart.

# List status of all upstart jobs
initctl list

Disk diagnostics


Disk partition tool.

# list all disks and partitions
fdisk -l


Show disk space usage.

# See iNode usage
df -i


Can be used to show what files are taking disk space.

# show disk usage from current directory
# for a specific directory
du /home/terry
# show disk usage of top level directories, sorted by biggest first
du -ck -d 1 | sort -rn


View and adjust tunable file system parameters

# View details of partitions including reserve disk space
sudo tune2fs -l /dev/sda1