Skip to content

Just some handy commands for checking and diagnosing servers

Notifications You must be signed in to change notification settings

lobsterdore/ops-tools

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 

Repository files navigation

Ops tools

Some handy commands for checking and diagnosing servers

General stats tools

uptime

Shows average load at a glance.

uptime

dmesg

Print system and kernal messages

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

Top

Displays linux process and system stats.

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

htop

Similar to top but with a more detailed UI.

htop

iostat

Reports processor and io statistics

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

mpstat

Shows detailed processor stats

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

iotop

Per process disk read/write

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

iftop

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

Sysstat

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"

Sar

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

pidstat

Stats for a process

pidstat {PID}

Network diagnostics

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

ifconfig

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

# display summary of interfaces
ifconfig
# 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

iwconfig

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
iwconfig
# limit to a particular interface
iwconfig wlan0
# set frequency
iwconfig wlan0 freq 2.437G

route

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}

nmap

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}

netstat

Tool for displaying a wide array of network information.

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

tcpdump

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

nslookup

Tool for querying name servers.

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

dig

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

# show DNS information for a host
dig google.com
# show DNS information via a specific name server
dig google.com @216.239.38.10
# show the route for a DNS lookup
dig google.com +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)

initctl

Startup control tool for upstart.

# List status of all upstart jobs
initctl list

Disk diagnostics

fdisk

Disk partition tool.

# list all disks and partitions
fdisk -l

df

Show disk space usage.

df
# See iNode usage
df -i

du

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

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

tune2fs

View and adjust tunable file system parameters

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

About

Just some handy commands for checking and diagnosing servers

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published