Skip to content
‹ 30-Day Drill

Command Sheet

Illustrative interview practice. Generic company names and hostnames do not represent any specific organization.

Command Sheet

These are the commands the drills use, grouped by what you are trying to find out. You do not need to memorise the options. You do need to know what each one tells you.

Where a command contains <pid>, put the number of the process you are looking at in its place.

Is the computer busy?

CommandWhat it shows you
topA live list of processes with the processor and memory each is using
uptimeThe load average: roughly how many processes want to do something right now
vmstat 1Once a second: processes waiting for the processor, processes waiting on a disk, and memory in use
iostat -x 1How busy each disk is and how long requests to it wait
pidstat -w 1How often each process is put down and picked up again
free -mMemory used, free and available, in megabytes
dmesg -T | grep -i oomWhether the system has stopped a program for running out of memory
ps -eo state,pid,cmdEvery process with its state, such as running, sleeping or waiting on a disk
ps -eLf | wc -lA count of every thread on the computer

Has a limit been reached?

CommandWhat it shows you
ulimit -nHow many files one process may have open
ulimit -uHow many processes this user may run
cat /proc/sys/fs/file-nrOpen files in use against the maximum, for the whole computer
lsof -p <pid>Every file and connection one process has open
sysctl net.core.somaxconnThe longest the waiting line for new connections may be
cat /proc/sys/net/ipv4/ip_local_port_rangeThe range of port numbers that outgoing connections may borrow
sysctl net.netfilter.nf_conntrack_countHow many connections the firewall is tracking right now
sysctl net.netfilter.nf_conntrack_maxThe most connections the firewall can track

What are the connections doing?

CommandWhat it shows you
ss -sA summary of network connections by state
ss -tan state close-waitConnections the other side has closed but this program has not
ss -tan state time-waitConnections that have closed and are waiting out a short safety period
ss -tiFor each connection, its round-trip time and how often data was sent again
ss -tlnWhich ports this computer is listening on
netstat -sRunning totals of dropped, refused and re-sent traffic
nstat -az TcpExtListenOverflows TcpExtListenDropsHow many new connections were dropped because the waiting line was full
sar -n DEV 1Traffic and errors on each network interface, once a second
tcpdump -ni any port 443The packets arriving and leaving on one port, as they happen

Can users find and reach the service?

CommandWhat it shows you
dig app.example.com +shortThe addresses a name leads to right now
nslookup app.example.comThe same lookup, with a tool found on most computers
traceroute app.example.comEach hop on the way to a server
mtr -rw app.example.comEach hop, with the delay and loss at every one
curl -sv https://app.example.com/ -o /dev/nullThe connection, the handshake and the status code of one request
curl -sI https://app.example.com/Only the headers of the reply
curl -s --http1.1 https://app.example.com/ -o /dev/nullWhether a request works when the older HTTP version is forced
curl -s -o /dev/null -w '%{time_connect} %{time_appconnect} %{time_total}\n' https://app.example.com/How long connecting, the handshake and the whole request took

Is the secure connection sound?

CommandWhat it shows you
openssl s_client -connect app.example.com:443 -servername app.example.com -showcertsThe handshake and every certificate the server presents
openssl x509 -noout -datesThe start and expiry dates of a certificate passed to it
openssl x509 -noout -subject -ext subjectAltNameThe names a certificate is valid for

What runs on a schedule?

CommandWhat it shows you
crontab -lThe jobs this user has set to run at fixed times
systemctl list-timersEvery timed job the system manages, with its next run

Containers and Java

CommandWhat it shows you
kubectl describe pod <name>Why a container last stopped, among much else
kubectl get hpaWhat the autoscaler wants and how many copies are running
kubectl rollout status deployment/<name>How far a release has got
kubectl rollout undo deployment/<name>Goes back to the previous version
jstat -gcutil <pid> 1000How full a Java program's memory is and how long clean-up is taking
jcmd <pid> Thread.printWhat every thread in a Java program is doing
jmap -histo <pid>Which kinds of object are filling a Java program's memory