Commands
What you type when it matters
A cheat sheet lists flags. This one gives the reason: why this command rather than the obvious alternative, and what the output actually tells you. Most of them exist because something was broken and nobody knew where to look.
126 of 126
Shell and files
16- pick
rg -n --hidden -g '!.git' 'pattern' path/- search
- ripgrep
rg -t py -A 3 -B 3 'def embed'- search
- context
fd -e parquet -x du -h {} \;- files
- find
- pick
jq -r '.items[] | select(.score > 0.8) | .id' results.json- json
- filtering
jq -c 'select(.status == "error")' traces.jsonl- json
- logs
awk -F',' '{s+=$3} END {print s/NR}' metrics.csv- text
- arithmetic
cut -d' ' -f7 access.log | sort | uniq -c | sort -rn | head -20- text
- analysis
watch -n 2 'nvidia-smi --query-gpu=memory.used --format=csv'- monitoring
lsof -i :8000- processes
- ports
ps aux --sort=-%mem | head- processes
- memory
tmux new -s train && tmux attach -t train- sessions
- remote
rsync -avzP --exclude '.git' ./corpus/ user@host:/data/corpus/- transfer
- remote
du -h --max-depth=1 . | sort -h- disk
python train.py 2>&1 | tee -a run.log- logging
cat urls.txt | xargs -P 8 -I{} curl -sO {}- parallel
- download
timeout 300 python eval.py || echo 'timed out'- reliability
Git
10- pick
git bisect start HEAD v1.2.0 && git bisect run ./check.sh- debugging
- history
git log -S 'chunk_size' --oneline- search
- history
git blame -L 40,60 -- src/retrieval.py- attribution
- pick
git reflog- recovery
git worktree add ../review-branch feature/x- branches
- workflow
git diff main...HEAD --stat- review
git add -p- staging
git stash push -u -m 'wip retrieval'- workflow
git restore --source=HEAD~3 -- path/to/file- recovery
git lfs track '*.safetensors' && git add .gitattributes- large-files
- models
Python and environments
15- pick
uv init myproject && cd myproject && uv add fastapi- packaging
- uv
uv run --with pandas python analyse.py- uv
- ephemeral
uvx ruff check .- uv
- tools
uv pip compile requirements.in -o requirements.txt- uv
- reproducibility
uv python install 3.12 && uv venv --python 3.12- uv
- versions
python -m venv .venv && source .venv/bin/activate- environments
uv pip list --outdated- dependencies
ruff check --fix . && ruff format .- lint
- format
mypy --strict src/- types
pytest -k 'retrieval and not slow' -x --lf- testing
pytest --durations=10- testing
- performance
- pick
py-spy top --pid 12345- profiling
- production
python -m cProfile -s cumtime script.py | head -30- profiling
memray run -o out.bin script.py && memray flamegraph out.bin- memory
- profiling
python -W error::DeprecationWarning script.py- upgrades
Containers
11docker build --progress=plain -t app:dev .- build
- cache
- pick
docker buildx build --platform linux/amd64,linux/arm64 -t app:1.0 --push .- build
- multiarch
docker run --gpus all --rm -it -v $(pwd):/work -w /work nvcr.io/nvidia/pytorch:24.10-py3 bash- gpu
- run
docker exec -it <container> sh- debugging
docker run --rm -it --pid=container:<id> --network=container:<id> nicolaka/netshoot- debugging
- network
docker logs --tail 100 -f --timestamps <container>- logs
docker stats --no-stream- monitoring
docker history --no-trunc app:1.0- size
- optimization
printf '.git\n.venv\ndata/\n*.safetensors\n' >> .dockerignore- build
- security
docker system df && docker system prune -a --filter 'until=168h'- cleanup
docker compose up -d --build && docker compose logs -f api- compose
- local
Kubernetes
12- pick
kubectl describe pod <pod>- triage
- pick
kubectl logs <pod> -c <container> --previous --tail=200- triage
- logs
kubectl get pods -o wide --sort-by=.status.startTime- triage
kubectl top pod --sort-by=memory- resources
kubectl get events --sort-by=.lastTimestamp -A | tail -40- triage
kubectl port-forward svc/vllm 8000:8000- access
- debugging
kubectl exec -it <pod> -- nvidia-smi- debugging
- gpu
kubectl rollout status deploy/api --timeout=5m- deploy
kubectl rollout undo deploy/api- deploy
- rollback
kubectl scale deploy/worker --replicas=0- scaling
kubectl diff -f manifest.yaml- safety
- review
kubectl get nodes -o custom-columns=NAME:.metadata.name,GPU:.status.allocatable.'nvidia\.com/gpu'- gpu
- capacity
Cloud and infrastructure
12aws s3 sync ./corpus s3://bucket/corpus --exclude '*.tmp' --storage-class INTELLIGENT_TIERING- aws
- storage
aws s3 ls s3://bucket/prefix/ --recursive --summarize --human-readable | tail -3- aws
- cost
- pick
aws sts get-caller-identity- aws
- identity
aws logs tail /aws/lambda/fn --follow --since 10m --filter-pattern ERROR- aws
- logs
aws ce get-cost-and-usage --time-period Start=2026-07-01,End=2026-08-01 --granularity MONTHLY --metrics BlendedCost --group-by Type=DIMENSION,Key=SERVICE- aws
- cost
gcloud config list && gcloud auth list- gcp
- identity
gcloud storage rsync -r ./data gs://bucket/data- gcp
- storage
az account show --output table- azure
- identity
az storage blob upload-batch -d container -s ./corpus --account-name acct- azure
- storage
- pick
terraform plan -out=tf.plan && terraform apply tf.plan- terraform
- safety
terraform state list | grep gpu- terraform
terraform fmt -recursive && terraform validate- terraform
- ci
Data and query
11- pick
duckdb -c "SELECT count(*), avg(score) FROM 'data/*.parquet'"- duckdb
- parquet
duckdb -c "INSTALL httpfs; LOAD httpfs; SELECT * FROM 's3://bucket/events/*.parquet' LIMIT 10"- duckdb
- s3
duckdb -c "DESCRIBE SELECT * FROM 'file.parquet'"- duckdb
- schema
duckdb -c "COPY (SELECT * FROM 'big.csv') TO 'big.parquet' (FORMAT PARQUET, COMPRESSION ZSTD)"- duckdb
- conversion
docker run --rm -it -v "$(pwd):/workspace" -w /workspace duckdb/duckdb- duckdb
- containers
- pick
psql -c 'EXPLAIN (ANALYZE, BUFFERS) SELECT ...'- postgres
- performance
psql -c "CREATE INDEX ON items USING hnsw (embedding vector_cosine_ops) WITH (m = 16, ef_construction = 64)"- postgres
- vectors
- index
psql -c "SELECT pid, state, wait_event, query FROM pg_stat_activity WHERE state != 'idle'"- postgres
- triage
psql -c "\copy items FROM 'items.csv' WITH (FORMAT csv, HEADER)"- postgres
- loading
mlr --icsv --ojson head -n 5 data.csv- csv
- conversion
wc -l traces.jsonl && head -1 traces.jsonl | jq keys- json
- inspection
Models and inference
19- pick
hf download meta-llama/Llama-3.1-8B-Instruct --local-dir ./models/llama-8b- huggingface
- download
hf download org/model --include '*.safetensors' '*.json' --exclude '*.bin'- huggingface
- efficiency
hf auth login- huggingface
- auth
hf upload org/my-adapter ./out --repo-type model- huggingface
- publish
hf cache scan- huggingface
- disk
- pick
vllm serve meta-llama/Llama-3.1-8B-Instruct --port 8000 --max-model-len 8192- vllm
- serving
vllm serve <model> --tensor-parallel-size 4 --gpu-memory-utilization 0.92- vllm
- distributed
vllm serve <model> --enable-prefix-caching --max-num-seqs 256- vllm
- cost
- latency
vllm serve --help=max- vllm
- reference
vllm serve TheBloke/model-AWQ --quantization awq --dtype half- vllm
- quantization
ollama run llama3.1:8b- ollama
- local
ollama ps- ollama
- memory
OLLAMA_HOST=0.0.0.0:11434 ollama serve- ollama
- serving
- security
ollama ls && ollama rm <model>- ollama
- disk
llama-server -hf ggml-org/gemma-3-1b-it-GGUF -c 4096 --port 8080- llama.cpp
- local
llama-cli -hf <repo> -t 8 -ngl 99- llama.cpp
- hybrid
llama-quantize model-f16.gguf model-q4_k_m.gguf Q4_K_M- llama.cpp
- quantization
- pick
vllm bench serve --model <model> --dataset-name random --request-rate 8 --num-prompts 500- benchmark
- capacity
lm_eval --model hf --model_args pretrained=<model> --tasks mmlu,gsm8k --batch_size auto- evaluation
- benchmark
GPU and profiling
10- pick
nvidia-smi- monitoring
nvidia-smi --query-gpu=timestamp,memory.used,utilization.gpu,power.draw --format=csv -l 1- monitoring
- logging
nvidia-smi pmon -c 30- monitoring
- processes
nvtop- monitoring
nvidia-smi topo -m- topology
- distributed
python -c 'import torch; print(torch.__version__, torch.cuda.is_available(), torch.cuda.get_device_name(0))'- setup
- pytorch
python -c 'import torch; print(torch.cuda.memory_summary())'- memory
- pytorch
python -m torch.utils.bottleneck script.py- profiling
- pytorch
nsys profile -o report python train.py- profiling
- nsight
dcgmi diag -r 1- diagnostics
- hardware
Network and APIs
10- pick
curl -o /dev/null -s -w 'dns %{time_namelookup} tcp %{time_connect} tls %{time_appconnect} ttfb %{time_starttransfer} total %{time_total}\n' https://api.example.com/v1/health- latency
- diagnosis
curl -N -H 'Content-Type: application/json' -d '{"model":"m","messages":[{"role":"user","content":"hi"}],"stream":true}' http://localhost:8000/v1/chat/completions- llm-api
- streaming
curl --retry 5 --retry-delay 2 --retry-all-errors --max-time 60 <url>- reliability
hey -n 500 -c 20 -m POST -H 'Content-Type: application/json' -D body.json http://localhost:8000/v1/chat/completions- load-testing
dig +short api.example.com && dig +trace api.example.com | tail -20- dns
openssl s_client -connect api.example.com:443 -servername api.example.com </dev/null 2>/dev/null | openssl x509 -noout -dates -subject- tls
ss -tunap | grep 8000- sockets
- diagnosis
mitmproxy --mode reverse:https://api.openai.com -p 8081- debugging
- api
sudo tcpdump -i any -nn port 8000 -c 100 -w capture.pcap- packets
- diagnosis
until curl -sf http://localhost:8000/health; do sleep 2; done- scripting
- readiness