Skip to content

Task: Debug / troubleshoot

Describe, top, df, ss, curl -v, dig, events, exit codes: find out what's wrong.

IndexUpdated

Also:troubleshoot · debug · triage · not working · broken · slow · high cpu · disk full

Triage order I use: is it up? (status/describe) → what changed? (events, history) → what is it short of? (CPU, memory, disk, network).

80 items

Linux13

Linux: Show errors since last boot

Safe

Only priority err and worse from the current boot: fastest way to see what's wrong on a box.

journalctl -b -p err --no-pager
What each part does
  1. journalctlread the systemd journal
  2. -bthis boot only (-b -1 for the previous one)
  3. -p errpriority err and worse (crit, alert, emerg)
  4. --no-pagerprint directly

Also known as: boot errors · journalctl -p err

Tool page →

Linux: Search a log for an error with context

Safe

Case-insensitive search with line numbers and 3 lines of context around each hit.

grep -n -i -C 3 "<pattern>" <file>
What each part does
  1. grepsearch text
  2. -nshow line numbers
  3. -icase-insensitive
  4. -C 33 lines of context before and after each match
  5. "<pattern>" <file>what to look for, and where
Example
$ grep -n -i -C 3 "timeout" /var/log/app/app.log

Also known as: grep context · find error in log

Tool page →

Linux: Check why a service failed

Safe

Status, last exit code and the most recent log lines of a unit.

systemctl status <service> --no-pager -l
What each part does
  1. systemctl status <service>state, main PID, exit code, and the last log lines of the unit
  2. --no-pagerprint directly instead of opening less
  3. -ldon't truncate long lines

Also known as: service failed · unit failed · systemctl status

Tool page →

Linux: Watch live CPU and memory hogs

Safe

Interactive process view sorted by CPU with full command lines. Press M to sort by memory, 1 for per-core.

top -c -o %CPU
What each part does
  1. toplive view of processes
  2. -cshow the full command line, not just the program name
  3. -o %CPUsort by CPU (press M to switch to memory, q to quit)

My note htop is nicer if installed: htop --sort-key=PERCENT_MEM

Also known as: top · htop · high cpu · high load

Tool page →

Linux: Check disk usage per filesystem

Safe

Size, used and available space per mount, with filesystem type.

df -hT
What each part does
  1. dfdisk free: size, used, available per mounted filesystem
  2. -hhuman-readable sizes (G, M)
  3. -Tshow the filesystem type (ext4, xfs, tmpfs...)
Example
Filesystem     Type  Size  Used Avail Use% Mounted on
/dev/nvme0n1p1 ext4   50G   49G  1.0G  98% /

My note Also run df -i: a disk can be 'full' on inodes with space left.

Also known as: df -h · disk full · no space left on device

Tool page →

Linux: Find the biggest directories

Safe

Top 20 directories by size under a path, staying on one filesystem (-x).

sudo du -xh --max-depth=1 <path> 2>/dev/null | sort -rh | head -20
What each part does
  1. sudo dudisk usage of directories
  2. -xstay on one filesystem (skip other mounts)
  3. -hhuman-readable sizes
  4. --max-depth=1 <path>one total per direct subdirectory of path
  5. 2>/dev/nullhide permission errors
  6. | sort -rhsort human sizes, largest first
  7. | head -20top 20
Example
$ sudo du -xh --max-depth=1 /var 2>/dev/null | sort -rh | head -20

Also known as: du · what is using disk · disk full

Tool page →

Linux: Find deleted files still holding disk space

Safe

Lists open files whose link count is 0: deleted but still held open by a process, so space isn't freed.

sudo lsof -nP +L1
What each part does
  1. sudo lsoflist open files (as root, to see every process)
  2. -nPno DNS or port-name lookups: faster
  3. +L1only files with link count < 1: deleted but still open; restart the process to free the space

My note Restart (or truncate via /proc/<pid>/fd/<n>) the holding process to free the space.

Also known as: df full but du small · deleted files open · lsof +L1

Tool page →

Linux: List listening ports and owning processes

Safe

TCP/UDP listening sockets with the PID/program that owns each one.

sudo ss -tulpn
What each part does
  1. sudo sssocket statistics (sudo to see other users' processes)
  2. -tuTCP and UDP sockets
  3. -llistening only
  4. -pshow the owning process and PID
  5. -nnumeric ports and addresses, no name lookups

Also known as: netstat -tulpn · port in use · address already in use · EADDRINUSE

Tool page →

Linux: Debug an HTTP request verbosely

Safe

Shows TLS handshake, request/response headers, final status code and total time.

curl -v -sS -o /dev/null -w "%{http_code} %{time_total}s\n" <url>
What each part does
  1. curlmake an HTTP request
  2. -vverbose: DNS, connect, TLS handshake, request and response headers
  3. -sShide the progress bar, still show errors
  4. -o /dev/nullthrow away the response body
  5. -w "%{http_code} %{time_total}s\n"after the request, print the status code and total time
  6. <url>the URL
Example
< HTTP/2 503
< retry-after: 30
503 0.214s

Also known as: curl -v · http debug · ssl handshake · connection refused

Tool page →

Linux: Resolve DNS for a host

Safe

Quick A/CNAME lookup. Use dig @<resolver> <hostname> to compare against a specific DNS server.

dig +short <hostname>
What each part does
  1. digDNS lookup tool
  2. +shortprint only the answers (IPs or CNAME targets)
  3. <hostname>the name to resolve; add @<server> to ask a specific DNS server

Also known as: nslookup · dns lookup · NXDOMAIN · could not resolve host

Tool page →

Linux: Check the OS release and running kernel

Safe

First step before patching: tells you which package manager to use (dnf, yum, apt, zypper, apk) and which kernel is running now.

cat /etc/os-release && uname -r
What each part does
  1. cat /etc/os-releasedistro name and version (NAME, VERSION_ID, e.g. Amazon Linux 2023, Ubuntu 22.04)
  2. uname -rthe kernel that is running right now (not necessarily the newest one installed)
Example
$ cat /etc/os-release && uname -r
NAME="Amazon Linux"
VERSION_ID="2023"
...
6.1.112-122.189.amzn2023.x86_64

Also known as: which distro · os version · kernel version · uname -r · os-release

Tool page →

Linux: Check versions of common runtimes on a host

Safe

Scanners flag these outside the OS package list. Compare each with the "Fixed In" version from the report.

node -v; python3 --version; java -version 2>&1 | head -1; nginx -v; git --version; /opt/splunkforwarder/bin/splunk version 2>/dev/null
What each part does
  1. node -vNode.js
  2. python3 --versionPython
  3. java -version 2>&1 | head -1Java (prints to stderr)
  4. nginx -vnginx
  5. git --versiongit
  6. splunk versionSplunk Universal Forwarder

Also known as: runtime versions · node version · python version · java version · splunk forwarder version

Tool page →

Linux: Check the installed version of a package

Safe

Works on RHEL/Fedora/Amazon Linux, Debian/Ubuntu and Alpine. For installed vs available: apt-cache policy <package> or dnf list --showduplicates <package>.

rpm -q <package> 2>/dev/null || dpkg-query -W -f='${Package} ${Version}
' <package> 2>/dev/null || apk info -v <package>
What each part does
  1. rpm -q <package>RHEL family and SUSE: name-version-release, or 'not installed'
  2. 2>/dev/null ||hide 'command not found' and try the next package manager
  3. dpkg-query -W -f='${Package} ${Version} ' <package>Debian / Ubuntu: name and installed version
  4. apk info -v <package>Alpine: name-version
Example
$ rpm -q openssl 2>/dev/null || dpkg-query -W -f='${Package} ${Version}\n' openssl 2>/dev/null || apk info -v openssl
openssl 3.0.13-0ubuntu3.4

My note To check many servers at once, run the same line through Ansible: ansible all -i <inventory> -m shell -a "...".

Also known as: package version · check version of package · dpkg -l · rpm -q · apt-cache policy · is package installed

Tool page →

Git4

Git: Show compact history graph

Safe

Last 30 commits as a branch graph with tags and branch names.

git log --oneline --graph --decorate -n 30
What each part does
  1. git logcommit history
  2. --onelineone line per commit
  3. --graphdraw branch and merge lines
  4. --decorateshow branch and tag names next to commits
  5. -n 30last 30 commits

Also known as: git lg · history graph

Tool page →

Git: Find who last changed a line

Safe

Author, commit and date for each line in a range.

git blame -L <start>,<end> <file>
What each part does
  1. git blameshow the commit, author and date of the last change to each line
  2. -L <start>,<end>only this line range
  3. <file>the file to annotate

Also known as: blame · who changed this

Tool page →

Git: Search history for when a string was added

Safe

Pickaxe search: commits that added or removed the string.

git log -S "<text>" --oneline
What each part does
  1. git logshow commit history
  2. -S "<text>"pickaxe: only commits that changed how many times the text appears (added or removed it)
  3. --onelineshort SHA + subject per commit

Also known as: pickaxe · git log -S · find commit that removed

Tool page →

Git: Recover a lost commit with reflog

Safe

Every HEAD move, including resets and rebases. Find the SHA, then git branch rescue <sha>.

git reflog -n 20
What each part does
  1. git refloglocal history of where HEAD pointed: commits, resets, checkouts, rebases
  2. -n 20only the last 20 entries; then git checkout -b rescue <sha>

Also known as: reflog · lost commit · undo reset --hard

Tool page →

Docker9

Docker: Show container logs for a time window

Safe

Logs from the last N minutes/hours, e.g. --since 15m or --since 2h.

docker logs --since <duration> <container>
What each part does
  1. docker logsshow a container's output
  2. --since <duration>only lines newer than this: relative (30m, 2h) or a timestamp; pair with --until
  3. <container>container name or ID
Example
$ docker logs --since 15m api

Also known as: logs since

Tool page →

Docker: List containers with status and ports

Safe

All containers (including exited) in a compact table.

docker ps -a --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"
What each part does
  1. docker pslist containers
  2. -ainclude stopped ones
  3. --format "table ..."Go template; table adds a header row and aligns columns
  4. {{.Names}}\t{{.Status}}\t{{.Ports}}the columns: name, status (Up / Exited (code)), port mappings, tab separated

Also known as: docker ps · exited containers

Tool page →

Docker: Open a shell inside a container

Safe

Interactive shell in a running container. Use bash if the image has it.

docker exec -it <container> sh
What each part does
  1. docker execrun a command in a running container
  2. -itinteractive + allocate a terminal
  3. <container>container name or ID
  4. shthe shell to start; use bash if the image has it

Also known as: docker exec · shell into container

Tool page →

Docker: Check exit code and OOM kill

Safe

Why did it stop? 137 + OOMKilled=true means the memory limit was hit.

docker inspect <container> --format '{{.State.ExitCode}} OOMKilled={{.State.OOMKilled}}'
What each part does
  1. docker inspect <container>full JSON details of a container (works on stopped ones too)
  2. --format '...'Go template: print only the fields you ask for
  3. {{.State.ExitCode}}the exit code of the last run (137 = SIGKILL, 143 = SIGTERM)
  4. {{.State.OOMKilled}}true if the kernel killed it for exceeding its memory limit
Example
137 OOMKilled=true

Also known as: exit code 137 · OOMKilled · container keeps restarting

Tool page →

Docker: Show live container resource usage

Safe

One-shot CPU, memory, network and block I/O per container.

docker stats --no-stream
What each part does
  1. docker statsCPU, memory, network and disk I/O per running container
  2. --no-streamprint one snapshot and exit instead of refreshing

Also known as: docker stats · container memory

Tool page →

Docker: Copy a file out of a container

Safe

Grab a config, dump or log file from a container to the current directory.

docker cp <container>:<path> ./
What each part does
  1. docker cpcopy files between a container and the host (works on stopped containers)
  2. <container>:<path>source: a path inside the container
  3. ./destination: the current directory on the host

Also known as: docker cp

Tool page →

Docker: Show disk used by Docker

Safe

Space used by images, containers, local volumes and build cache, and how much is reclaimable.

docker system df
What each part does
  1. docker system dfdisk used by images, containers, volumes and build cache, with how much is reclaimable; add -v for per-item detail

Also known as: docker disk usage · /var/lib/docker full

Tool page →

Docker: Check the base OS of an image

Safe

Tells you which package manager to patch with in the Dockerfile (apt, apk, dnf, microdnf).

docker run --rm --entrypoint cat <image>:<tag> /etc/os-release
What each part does
  1. docker run --rmthrowaway container
  2. --entrypoint catskip the image entrypoint and just run cat
  3. /etc/os-releasedistro name and version

Also known as: image os · base image distro · which distro image

Tool page →

Docker: Print environment variables of a container

Safe

Every env var the running container sees. Stopped container: docker inspect <container> --format '{{range .Config.Env}}{{println .}}{{end}}'.

docker exec <container> env
What each part does
  1. docker exec <container>run a command inside the running container (name or ID)
  2. envprint every environment variable, KEY=value per line; use printenv <VAR> for just one
Example
$ docker exec api env
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
HOSTNAME=4f2a9c1e7b3d
NODE_ENV=production
DATABASE_HOST=db

My note Values passed with -e or --env-file (including secrets) are readable by anyone with docker access. Distroless images have no env binary: use the inspect form.

Also known as: docker print env · docker env vars · show container environment · printenv

Tool page →

Podman1

Podman: List all containers

Safe

Running and exited containers, rootless by default for the current user.

podman ps -a
What each part does
  1. podman pslist containers
  2. -ainclude stopped ones

Also known as: podman ps

Tool page →

Kubernetes10

Kubernetes: List pods

Safe

Pods with status, restarts, age, pod IP and node. po is the short name for pods; -A for all namespaces, -w to watch.

kubectl get po -n <namespace> -o wide
What each part does
  1. kubectl getlist resources of a type
  2. poshort name for pods (pod and pods work too)
  3. -n <namespace>in this namespace; -A for every namespace
  4. -o wideadd the pod IP, the node and nominated node columns
Example
$ kubectl get po -n shop -o wide
NAME                   READY   STATUS    RESTARTS   AGE   IP            NODE
api-7d9f8c6b5d-2xkqp   1/1     Running   0          3h    10.244.1.17   node-a
api-7d9f8c6b5d-9wz4t   1/1     Running   2          3h    10.244.2.9    node-b

Also known as: kubectl get po · kubectl get pods · list pods · show pods

Tool page →

Kubernetes: List services and their endpoints

Safe

Services with type, cluster IP, external IP, ports and selector, then the pod IPs actually behind each one.

kubectl get svc -n <namespace> -o wide && kubectl get endpointslices -n <namespace>
What each part does
  1. kubectl get svclist services (svc is the short name)
  2. -n <namespace>in this namespace; -A for all
  3. -o wideadd the SELECTOR column: the pod labels the service routes to
  4. &&then, if that worked
  5. kubectl get endpointslicesthe ready pod IPs:ports behind each service (kubectl get ep on older clusters)
Example
$ kubectl get svc -n shop -o wide
NAME   TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)   AGE   SELECTOR
api    ClusterIP   10.96.120.15   <none>        80/TCP    3d    app=api

My note No endpoints? The selector matches no ready pods: compare SELECTOR with kubectl get po --show-labels, and check readiness probes.

Also known as: kubectl get svc · kubectl get services · list services · service has no endpoints · kubectl get ep

Tool page →

Kubernetes: Show logs of the previous crashed container

Safe

Logs from the container instance that just died: the one with the actual error.

kubectl logs <pod> -n <namespace> --previous
What each part does
  1. kubectl logs <pod>print container logs
  2. -n <namespace>namespace of the pod
  3. --previouslogs of the last terminated instance, i.e. the one that crashed, not the restarted one

My note First thing to run on CrashLoopBackOff.

Also known as: CrashLoopBackOff · previous logs · container restarted

Tool page →

Kubernetes: Describe a pod to see events

Safe

Conditions, container states, last termination reason and events at the bottom.

kubectl describe pod <pod> -n <namespace>
What each part does
  1. kubectl describe pod <pod>human-readable details: containers, state, last state, reason, probes, and Events at the bottom
  2. -n <namespace>namespace of the pod

Also known as: ImagePullBackOff · ErrImagePull · Pending · FailedScheduling · OOMKilled

Tool page →

Kubernetes: List recent events sorted by time

Safe

Scheduling failures, probe failures, image pulls, evictions: newest last.

kubectl get events -n <namespace> --sort-by=.lastTimestamp
What each part does
  1. kubectl get eventslist events: scheduling, pulls, probe failures, kills
  2. -n <namespace>in this namespace
  3. --sort-by=.lastTimestampoldest first, newest at the bottom

Also known as: k8s events · Back-off restarting failed container · Readiness probe failed

Tool page →

Kubernetes: Find pods that are not running

Safe

Every pod in the cluster that is Pending, Failed, Succeeded or Unknown.

kubectl get pods -A --field-selector=status.phase!=Running
What each part does
  1. kubectl get podslist pods
  2. -Ain all namespaces
  3. --field-selector=status.phase!=Runningphase is not Running: Pending, Failed, Succeeded, Unknown (CrashLoopBackOff pods are still Running)

Also known as: broken pods · pending pods

Tool page →

Kubernetes: Show pod CPU and memory usage

Safe

Live usage from metrics-server, highest memory first.

kubectl top pod -n <namespace> --sort-by=memory
What each part does
  1. kubectl top podcurrent CPU and memory per pod (needs metrics-server)
  2. -n <namespace>in this namespace
  3. --sort-by=memorybiggest memory users first (or cpu)

Also known as: kubectl top · memory usage · OOMKilled

Tool page →

Kubernetes: Exec into a pod

Safe

Interactive shell inside the pod's (first) container.

kubectl exec -it <pod> -n <namespace> -- sh
What each part does
  1. kubectl execrun a command in a container of a running pod
  2. -itinteractive + terminal
  3. <pod>the pod (add -c <container> if it has several)
  4. -n <namespace>namespace of the pod
  5. -- sheverything after -- is the command to run; use bash if the image has it

Also known as: kubectl exec · shell into pod

Tool page →

Kubernetes: Port-forward to a service

Safe

Reach a ClusterIP service from your laptop on localhost:<local-port>.

kubectl port-forward svc/<service> <local-port>:<remote-port> -n <namespace>
What each part does
  1. kubectl port-forwardtunnel a local port to a pod through the API server
  2. svc/<service>pick a pod behind this service
  3. <local-port>:<remote-port>listen locally on the first, forward to the second
  4. -n <namespace>namespace of the service
Example
$ kubectl port-forward svc/prometheus-operated 9090:9090 -n monitoring
# then open http://localhost:9090

Also known as: port forward · kubectl port-forward · prometheus ui · grafana ui

Tool page →

Kubernetes: Print environment variables of a pod

Safe

Every env var the running container sees. Without exec access: kubectl set env deploy/<deployment> --list.

kubectl exec <pod> -n <namespace> -- env
What each part does
  1. kubectl exec <pod>run a command in the pod (add -c <container> if it has several)
  2. -n <namespace>namespace of the pod
  3. -- enveverything after -- runs in the container: print all environment variables

My note kubectl set env deploy/<deployment> --list shows what the deployment defines, including which values come from ConfigMaps and Secrets.

Also known as: kubectl print env · pod env vars · kubectl exec env · printenv

Tool page →

OpenShift1

OpenShift: Debug a crashing pod with a shell

Safe

Starts a copy of the pod with a shell instead of its entrypoint, so you can poke around.

oc debug pod/<pod>
What each part does
  1. oc debugstart a copy of the pod with the command replaced by a shell, so it doesn't crash
  2. pod/<pod>the pod to copy (also works with deployment/<name> or node/<name>)

My note oc debug node/<node> gives a root shell on a node (chroot /host).

Also known as: CrashLoopBackOff · oc debug

Tool page →

AWS1

AWS: Check which identity you are using

Safe

Account, ARN and user/role the CLI is authenticated as.

aws sts get-caller-identity
What each part does
  1. aws stsSecurity Token Service commands
  2. get-caller-identityprint the account ID, user/role ARN and user ID of the current credentials; needs no permissions

Also known as: whoami aws · AccessDenied · ExpiredToken

Tool page →

GCP1

GCP: Read recent error logs

Safe

Errors from Cloud Logging in the last hour across the project.

gcloud logging read 'severity>=ERROR' --freshness=1h --limit=50
What each part does
  1. gcloud logging readquery Cloud Logging
  2. 'severity>=ERROR'filter: ERROR, CRITICAL, ALERT, EMERGENCY
  3. --freshness=1honly entries from the last hour
  4. --limit=50return at most 50 entries

Also known as: stackdriver · cloud logging

Tool page →

Terraform3

Terraform: Inspect state for a resource

Safe

All attributes Terraform has recorded for one resource.

terraform state show <resource-address>
What each part does
  1. terraform state showprint every attribute Terraform has stored for one resource
  2. <resource-address>e.g. aws_instance.web or module.vpc.aws_subnet.private[0] (see terraform state list)
Example
$ terraform state show 'module.vpc.aws_subnet.private[0]'

Also known as: tf state show · terraform state list

Tool page →

Terraform: Release a stuck state lock

Destructive

Removes a lock left behind by a crashed run. Make sure nothing else is running first.

terraform force-unlock <lock-id>
What each part does
  1. terraform force-unlockremove a state lock left by a crashed or killed run
  2. <lock-id>the ID shown in the Error acquiring the state lock message; make sure no one else is running

My note The lock ID is in the error message. See the gotcha on state locks.

Also known as: Error acquiring the state lock · state lock · ConditionalCheckFailedException · tf lock

Tool page →

Terraform: Enable debug logging

Safe

Write provider/API level debug logs to a file.

TF_LOG=DEBUG TF_LOG_PATH=./tf-debug.log terraform plan
What each part does
  1. TF_LOG=DEBUGlog level for this run: TRACE, DEBUG, INFO, WARN, ERROR
  2. TF_LOG_PATH=./tf-debug.logwrite the log to a file instead of stderr
  3. terraform planthe command to debug

Also known as: TF_LOG · tf debug

Tool page →

Ansible4

Ansible: Ping all hosts in an inventory

Safe

Checks SSH connectivity and Python on every host (not ICMP ping).

ansible all -i <inventory> -m ping
What each part does
  1. ansiblerun a single ad-hoc module (no playbook)
  2. allhost pattern: every host in the inventory
  3. -i <inventory>inventory file or directory
  4. -m pingthe ping module: checks SSH login + Python on the host (not ICMP); success prints pong

Also known as: UNREACHABLE · ansible ping

Tool page →

Ansible: Dry-run a playbook with diff

Safe

Shows what would change, file diffs included, without changing anything.

ansible-playbook -i <inventory> <playbook> --check --diff
What each part does
  1. ansible-playbookrun a playbook (a YAML list of plays and tasks)
  2. -i <inventory>inventory file or directory listing the hosts
  3. <playbook>the playbook file, e.g. site.yml
  4. --checkdry run: report what would change, change nothing
  5. --diffshow a before/after diff for templated and edited files

Also known as: check mode · dry run

Tool page →

Ansible: Run an ad-hoc command as root

Caution

Quick one-off command on many hosts with privilege escalation.

ansible <host-pattern> -i <inventory> -b -m shell -a "<command>"
What each part does
  1. ansible <host-pattern>run an ad-hoc module against matching hosts
  2. -i <inventory>inventory file or directory
  3. -bbecome: escalate privileges (sudo to root by default)
  4. -m shellshell module: runs through /bin/sh, so pipes and redirects work
  5. -a "<command>"the module arguments: the command line to run
Example
$ ansible web -i inventory/prod -b -m shell -a "df -h /"

Also known as: ad-hoc · ansible shell

Tool page →

Ansible: Show facts for a host

Safe

Gathered facts (OS, IPs, mounts…). Filter with a glob like ansible_distribution*.

ansible <host> -i <inventory> -m setup -a "filter=<fact-filter>"
What each part does
  1. ansible <host>run an ad-hoc module on one host (or pattern)
  2. -i <inventory>inventory file or directory
  3. -m setupsetup module: gathers the facts Ansible knows about the host
  4. -a "filter=<fact-filter>"only return matching facts, e.g. ansible_distribution* or ansible_default_ipv4

Also known as: ansible facts · setup module

Tool page →

Helm1

Helm: Show release history

Safe

Revisions, status and chart/app versions of a release.

helm history <release> -n <namespace>
What each part does
  1. helm history <release>every revision: number, date, status, chart and app version, description
  2. -n <namespace>namespace of the release

Also known as: helm history · another operation (install/upgrade/rollback) is in progress

Tool page →

GitHub Actions1

GitHub Actions: Show logs of failed steps

Safe

Only the log output of failed steps. gh run list shows recent run ids.

gh run view <run-id> --log-failed
What each part does
  1. gh run view <run-id>show a workflow run (gh run list gives the IDs)
  2. --log-failedprint only the logs of the failed steps

Also known as: gha logs · workflow failed · gh run view

Tool page →

GitLab CI3

GitLab CI: Watch the pipeline for this branch

Safe

Live status of the current branch's pipeline from the terminal.

glab ci status --live
What each part does
  1. glab ci statusstatus of the latest pipeline on the current branch, job by job
  2. --livekeep refreshing until the pipeline finishes

Also known as: glab ci · pipeline status

Tool page →

GitLab CI: Show a job's log

Safe

Stream the log of a CI job (pick interactively if you omit the id).

glab ci trace <job-id>
What each part does
  1. glab ci tracestream a CI job's log (follows it while running)
  2. <job-id>the job ID; leave it out to pick a job interactively

Also known as: job log · glab trace

Tool page →

GitLab CI: Lint .gitlab-ci.yml

Safe

Validate the CI config against the GitLab instance before pushing.

glab ci lint
What each part does
  1. glab ci lintsend .gitlab-ci.yml to the GitLab CI lint API and report syntax / config errors

Also known as: yaml invalid · ci lint

Tool page →

Jenkins1

Jenkins: Tail a build's console log

Safe

Last 100 lines of the latest build's console without opening the UI.

curl -sS -u <user>:<api-token> "<jenkins-url>/job/<job>/lastBuild/consoleText" | tail -n 100
What each part does
  1. curl -sSquiet, but still show errors
  2. -u <user>:<api-token>basic auth with a Jenkins API token
  3. /job/<job>/lastBuild/consoleTextplain-text console output of the latest build (use a build number instead of lastBuild)
  4. | tail -n 100only the last 100 lines

Also known as: jenkins console · build log

Tool page →

Prometheus5

Prometheus: Check which targets are down

Safe

Every scrape target currently failing, as job + instance.

curl -s "<prometheus-url>/api/v1/query?query=up==0" | jq -r '.data.result[].metric | "\(.job) \(.instance)"'
What each part does
  1. curl -sHTTP request, quiet
  2. /api/v1/query?query=up==0instant query: targets whose last scrape failed
  3. | jq -rparse the JSON, print raw strings
  4. '.data.result[].metric | "\(.job) \(.instance)"'for each result, print its job and instance

Also known as: target down · up == 0 · scrape failed

Tool page →

Prometheus: Validate config and rule files

Safe

Checks prometheus.yml and every rule file it references. Run it in CI before deploying.

promtool check config <config-file>
What each part does
  1. promtool check configvalidate prometheus.yml and the rule files it references
  2. <config-file>path to the config; use promtool check rules <file> for a rule file alone

Also known as: promtool · rule syntax

Tool page →

Prometheus: Run a PromQL query from the CLI

Safe

Evaluate an instant query without opening the UI.

promtool query instant <prometheus-url> '<query>'
What each part does
  1. promtool query instantevaluate a PromQL query at the current time
  2. <prometheus-url>the Prometheus server
  3. '<query>'the PromQL expression, in single quotes so the shell leaves it alone
Example
$ promtool query instant http://localhost:9090 'sum by (pod) (rate(container_cpu_usage_seconds_total[5m]))'

Also known as: promql

Tool page →

Prometheus: List firing alerts

Safe

Names of all alerts that are firing right now.

curl -s <prometheus-url>/api/v1/alerts | jq -r '.data.alerts[] | select(.state=="firing") | .labels.alertname'
What each part does
  1. curl -s <prometheus-url>/api/v1/alertsall active alerts (pending and firing)
  2. | jq -rparse the JSON, print raw strings
  3. '.data.alerts[] | select(.state=="firing") | .labels.alertname'keep firing alerts and print their names

Also known as: firing alerts · alerts api

Tool page →

Prometheus: Silence an alert with amtool

Caution

Mute an alert during maintenance. amtool silence query lists active silences.

amtool silence add alertname=<alert> --duration=<duration> --comment="<reason>" --alertmanager.url=<alertmanager-url>
What each part does
  1. amtool silence addcreate a silence in Alertmanager
  2. alertname=<alert>matcher: which alerts to mute (add more label=value matchers to narrow)
  3. --duration=<duration>how long, e.g. 2h
  4. --comment="<reason>"why: shown to everyone in the UI
  5. --alertmanager.url=<alertmanager-url>the Alertmanager to talk to
Example
$ amtool silence add alertname=KubeNodeNotReady --duration=2h --comment="node drain" --alertmanager.url=http://localhost:9093

Also known as: alertmanager · silence · maintenance window

Tool page →

Grafana1

Grafana: Check health

Safe

Returns version and database status. Handy for load balancer checks.

curl -s <grafana-url>/api/health
What each part does
  1. curl -sHTTP request, quiet
  2. <grafana-url>/api/healthunauthenticated health endpoint: database ok + version

Also known as: grafana down

Tool page →

Elasticsearch5

Elasticsearch: Check cluster health

Safe

Status green / yellow / red, node count and unassigned shards.

curl -s "<es-url>/_cluster/health?pretty"
What each part does
  1. curl -sHTTP request, no progress bar
  2. <es-url>cluster address, e.g. http://localhost:9200 (add -u user:pass if secured)
  3. /_cluster/healthcluster status: green / yellow (replicas unassigned) / red (primaries missing), shard counts
  4. ?prettyindent the JSON

Also known as: cluster red · cluster yellow · _cluster/health

Tool page →

Elasticsearch: Explain unassigned shards

Safe

Why the first unassigned shard can't be allocated (disk watermark, node left…).

curl -s "<es-url>/_cluster/allocation/explain?pretty"
What each part does
  1. curl -sHTTP request, quiet
  2. /_cluster/allocation/explainexplains why the first unassigned shard can't be placed (disk, filters, node left...)
  3. ?prettyindent the JSON

Also known as: unassigned shards · cluster yellow · allocation explain

Tool page →

Elasticsearch: List indices by size

Safe

Biggest indices first, with doc count and health.

curl -s "<es-url>/_cat/indices?v&s=store.size:desc" | head -20
What each part does
  1. curl -sHTTP request, quiet
  2. /_cat/indicesone line per index: health, status, docs, size
  3. ?vadd a header row
  4. &s=store.size:descsort by size, biggest first
  5. | head -20keep the header + top 19

Also known as: _cat/indices · index size

Tool page →

Elasticsearch: Search recent error logs

Safe

Last 20 error-level documents. Change the field to match your log schema.

curl -s "<es-url>/<index-pattern>/_search?q=level:error&size=20&sort=@timestamp:desc&pretty"
What each part does
  1. curl -sHTTP request, quiet
  2. <index-pattern>/_searchsearch across matching indices, e.g. logs-*
  3. q=level:errorLucene query string: documents where level is error
  4. size=20return 20 hits
  5. sort=@timestamp:descnewest first
  6. prettyindent the JSON

Also known as: kibana search · elk logs

Tool page →

Elasticsearch: Clear read-only block after disk full

Caution

Re-enables writes once you've freed disk space below the flood-stage watermark.

curl -X PUT "<es-url>/_all/_settings" -H 'Content-Type: application/json' -d '{"index.blocks.read_only_allow_delete": null}'
What each part does
  1. curl -X PUTHTTP PUT: update settings
  2. "<es-url>/_all/_settings"the settings of every index
  3. -H 'Content-Type: application/json'tell ES the body is JSON
  4. -d '{"index.blocks.read_only_allow_delete": null}'body: reset the block ES set when disk hit the flood-stage watermark

My note Recent versions clear the block automatically once disk drops under the high watermark.

Also known as: FORBIDDEN/12/index read-only / allow delete (api) · flood stage disk watermark · read_only_allow_delete

Tool page →

Trivy4

Trivy: Scan an image for high and critical CVEs

Safe

Only vulnerabilities that actually have a fix available.

trivy image --severity HIGH,CRITICAL --ignore-unfixed <image>:<tag>
What each part does
  1. trivy imagescan a container image (OS packages + app dependencies)
  2. --severity HIGH,CRITICALonly show these severities
  3. --ignore-unfixedhide vulnerabilities with no fix available
  4. <image>:<tag>the image

Also known as: cve scan · image scan

Tool page →

Trivy: Scan a repo for secrets and misconfigurations

Safe

Dependencies, hard-coded secrets and IaC misconfigurations in a directory.

trivy fs --scanners vuln,secret,misconfig <path>
What each part does
  1. trivy fsscan a local directory
  2. --scanners vuln,secret,misconfigdependency CVEs, hard-coded secrets, and IaC / Dockerfile misconfigurations
  3. <path>the directory, e.g. .

Also known as: leaked secret · secret scanning

Tool page →

Trivy: Scan Terraform or Kubernetes manifests

Safe

Misconfiguration checks for Terraform, Kubernetes YAML, Helm charts and Dockerfiles.

trivy config <path>
What each part does
  1. trivy configscan IaC files: Terraform, Kubernetes YAML, Helm, Dockerfiles, CloudFormation
  2. <path>directory or file to scan

Also known as: tfsec · iac scan · kubernetes misconfig

Tool page →

Trivy: Scan the current Kubernetes cluster

Safe

Vulnerabilities and misconfigurations across workloads in the current kube context.

trivy k8s --report summary
What each part does
  1. trivy k8sscan the cluster in the current kubeconfig context: workload images, configs, RBAC
  2. --report summaryone table of counts per resource instead of every finding (all for full detail)

Also known as: cluster scan · k8s

Tool page →

SonarQube1

SonarQube: Check the quality gate status

Safe

OK or ERROR for the latest analysis. Add -Dsonar.qualitygate.wait=true to the scanner to block CI instead.

curl -s -u "$SONAR_TOKEN:" "<sonar-url>/api/qualitygates/project_status?projectKey=<project-key>" | jq -r .projectStatus.status
What each part does
  1. curl -sHTTP request, quiet
  2. -u "$SONAR_TOKEN:"token as the user name, empty password
  3. /api/qualitygates/project_status?projectKey=<project-key>quality gate result for the project
  4. | jq -r .projectStatus.statusprint just OK, WARN, ERROR or NONE

Also known as: quality gate failed · sonar gate

Tool page →

Istio3

Istio: Check proxy sync status

Safe

Whether every sidecar is in sync with istiod (SYNCED vs STALE).

istioctl proxy-status
What each part does
  1. istioctl proxy-statusevery sidecar and whether its config (CDS, LDS, EDS, RDS) is SYNCED or STALE with istiod

Also known as: STALE · proxy-status · envoy sync

Tool page →

Istio: Analyze a namespace for config problems

Safe

Finds broken VirtualServices, missing gateways, sidecar injection issues.

istioctl analyze -n <namespace>
What each part does
  1. istioctl analyzecheck Istio config for errors: missing gateways, bad hosts, conflicting rules
  2. -n <namespace>namespace to analyze; -A for all

Also known as: istio analyze · virtualservice

Tool page →

Istio: Show Envoy routes for a pod

Safe

The routes the sidecar actually received. Use clusters/listeners/endpoints for other views.

istioctl proxy-config routes <pod>.<namespace>
What each part does
  1. istioctl proxy-config routesshow the HTTP routes the pod's Envoy sidecar has
  2. <pod>.<namespace>the pod, written as name.namespace

Also known as: 404 NR · no healthy upstream · proxy-config

Tool page →

Linkerd3

Linkerd: Check control plane health

Safe

Validates the install, certificates and data plane. Add --proxy -n <ns> for workloads.

linkerd check
What each part does
  1. linkerd checkrun checks on the CLI, cluster, control plane and certificates; add --proxy to check data-plane proxies

Also known as: linkerd check

Tool page →

Linkerd: Show live traffic stats for deployments

Safe

Success rate, RPS and latency percentiles per deployment.

linkerd viz stat deploy -n <namespace>
What each part does
  1. linkerd viz statgolden metrics: success rate, RPS, latency p50/p95/p99 (needs the viz extension)
  2. deployresource type: per deployment
  3. -n <namespace>in this namespace

Also known as: golden metrics · success rate

Tool page →

Linkerd: Tap live requests to a deployment

Safe

Stream individual requests and responses flowing through the proxies.

linkerd viz tap deploy/<deployment> -n <namespace>
What each part does
  1. linkerd viz tapstream live requests and responses passing through the proxies
  2. deploy/<deployment>the deployment to watch
  3. -n <namespace>its namespace

Also known as: linkerd tap

Tool page →

Consul2

Consul: List cluster members

Safe

Agents in the cluster with status (alive, failed, left).

consul members
What each part does
  1. consul memberslist the agents in the gossip pool: node, address, status (alive / failed / left), type, datacenter

Also known as: consul members · agent failed

Tool page →

Consul: Look up a service via Consul DNS

Safe

Healthy instances and ports as Consul DNS returns them.

dig @127.0.0.1 -p 8600 <service>.service.consul SRV
What each part does
  1. digDNS lookup tool
  2. @127.0.0.1ask the local Consul agent instead of the system resolver
  3. -p 8600Consul's DNS port
  4. <service>.service.consulname of a registered service; only healthy instances are returned
  5. SRVrecord type: returns the port as well as the host

Also known as: service discovery · consul dns

Tool page →

Envoy3

Envoy: Dump the running config

Safe

Full listeners/clusters/routes config from the admin API (Istio sidecars: port 15000).

curl -s localhost:<admin-port>/config_dump > envoy-config.json
What each part does
  1. curl -s localhost:<admin-port>/config_dumpthe full config Envoy is running now: listeners, routes, clusters, secrets (redacted)
  2. > envoy-config.jsonsave it to a file (it's large)

Also known as: config_dump · envoy admin

Tool page →

Envoy: Check upstream cluster health

Safe

Shows which upstream hosts are failing health checks or ejected.

curl -s localhost:<admin-port>/clusters | grep -E 'health_flags|cx_active'
What each part does
  1. curl -s localhost:<admin-port>/clustersEnvoy admin API: stats for every upstream host (admin port is often 15000 or 9901)
  2. | grep -Ekeep only lines matching the regex
  3. 'health_flags|cx_active'health flags (healthy or /failed_active_hc etc.) and active connections

Also known as: no healthy upstream · 503 UH · outlier detection

Tool page →

Envoy: Raise the log level at runtime

Caution

Turn on debug logs without a restart. Set it back to info afterwards.

curl -X POST "localhost:<admin-port>/logging?level=debug"
What each part does
  1. curl -X POSTadmin API changes need POST
  2. localhost:<admin-port>/loggingthe logging endpoint
  3. ?level=debugset every logger to debug; set it back to info when done, or use ?<logger>=debug for one

Also known as: envoy debug logs

Tool page →

My DevOps Playbook by Angelo John Calleja

New runbook

GitHub not connected

Saving is handled by the site: the GitHub token is stored in Cloudflare, not in your browser. Enter the editor password (the EDITOR_PASSWORD secret) to unlock saving in this browser.

Saving commits to gelogrammer/My_DevOps_Playbook. Create a fine-grained token with access to only this repo andContents: Read and write, then paste it here. It is stored only in this browser.

src/content/docs/…