Developer Cheat Sheets
Commands You Actually Use

Git, Bash, Docker, npm, regex, SQL, CSS layout, curl, Markdown, PowerShell, cron, and chmod on one searchable page. Copy any command in one click, see dangerous commands flagged with a safer alternative, and print one topic or all twelve as a reference guide. 100% client-side. Zero data stored.

Developer Cheat Sheets illustration

Searchable Developer Cheat Sheets

Git

Everyday Git commands for branching, committing, syncing, and - most importantly - undoing mistakes safely.

  • git status
    Show changed, staged, and untracked files on the current branch.
  • git add -p
    Stage changes hunk by hunk, reviewing each one before it goes in.
  • git commit -m "Describe the change"
    Commit the staged changes with a message.
  • git commit --amend --no-edit
    Fold staged changes into the last commit. Only before you push it.
  • git switch -c feature/login
    Create a new branch and switch to it.
  • git switch main
    Switch to an existing branch.
  • git log --oneline --graph --decorate --all
    Compact history graph of every branch.
  • git diff --staged
    Show exactly what is staged for the next commit.
  • git fetch --prune
    Download remote changes and forget remote branches that were deleted.
  • git pull --rebase
    Update your branch by replaying your local commits on top of the remote ones.
  • git push -u origin HEAD
    Push the current branch and set it to track the remote branch.
  • git push --force-with-lease
    Force-push after a rebase, but refuse if someone else pushed in the meantime.
  • git restore --staged file.txt
    Unstage a file and keep your edits.
  • git restore file.txt
    Throw away unstaged edits to a file.

    Careful: The discarded edits cannot be recovered. Safer: git stash push file.txt

  • git reset --soft HEAD~1
    Undo the last commit but keep its changes staged.
  • git reset --hard HEAD
    Discard every uncommitted change in the working tree.

    Careful: Uncommitted work is lost for good. Safer: git stash push -m "backup"

  • git revert a1b2c3d
    Create a new commit that undoes an earlier one - safe on shared branches.
  • git stash push -m "wip"
    Shelve uncommitted changes; bring them back with git stash pop.
  • git rebase -i HEAD~3
    Squash, reorder, or reword the last three commits (rewrites history).
  • git cherry-pick a1b2c3d
    Copy a single commit onto the current branch.
  • git reflog
    List where HEAD has been - the way to find "lost" commits after a bad reset.
  • git blame -L 10,20 app.js
    Show who last changed lines 10 to 20 of a file.
  • git bisect start
    Binary-search history for the commit that introduced a bug (mark commits with git bisect good / bad).
  • git tag -a v1.2.0 -m "Release 1.2.0"
    Create an annotated tag; push it with git push origin v1.2.0.
  • git branch -d feature/login
    Delete a branch that has been merged.
  • git clean -fd
    Delete untracked files and folders.

    Careful: Untracked files are deleted permanently. Safer: git clean -nd

Bash & Linux Shell

The shell commands you reach for every day on Linux, macOS, WSL, and servers.

  • ls -lah
    List all files, including hidden ones, with human-readable sizes.
  • cd -
    Jump back to the previous directory.
  • mkdir -p app/src/utils
    Create nested directories in one step.
  • cp -r src/ backup/
    Copy a directory recursively.
  • mv old-name.txt new-name.txt
    Move or rename a file.
  • rm -rf build/
    Delete a directory and everything in it without asking.

    Careful: No recycle bin - a typo in the path can wipe the wrong folder. Safer: rm -ri build/

  • find . -name "*.log" -mtime +7
    Find .log files modified more than 7 days ago.
  • grep -rn "TODO" src/
    Search files recursively and show line numbers.
  • tail -f /var/log/syslog
    Follow a log file as new lines are written.
  • command > out.txt 2>&1
    Send both output and errors to a file.
  • command | tee out.txt
    Show output on screen and save it to a file at the same time.
  • build && deploy
    Run the second command only if the first one succeeds.
  • export NODE_ENV=production
    Set an environment variable for this shell and its child processes.
  • ps aux | grep node
    Find running processes by name.
  • kill -15 12345
    Ask a process to stop gracefully (SIGTERM).
  • kill -9 12345
    Force-kill a process immediately (SIGKILL).

    Careful: The process gets no chance to clean up or save data. Safer: kill -15 12345

  • lsof -i :3000
    See which process is listening on port 3000.
  • df -h
    Show free disk space per filesystem.
  • du -sh *
    Show the size of each file and folder in the current directory.
  • tar -czf site.tar.gz site/
    Create a gzip-compressed archive (extract with tar -xzf site.tar.gz).
  • ssh -i ~/.ssh/id_ed25519 user@server
    Connect to a server with a specific key.
  • rsync -avz --dry-run dist/ user@server:/var/www/
    Preview a sync to a server; remove --dry-run to copy for real.
  • chmod +x deploy.sh
    Make a script executable.
  • history | grep ssh
    Search your command history (or press Ctrl+R to search interactively).

Unix permission numbers and symbols. Each digit is owner, group, others: read = 4, write = 2, execute = 1. Use the calculator below to convert.

chmod Calculator

Who Read Write Execute
Owner
Group
Others

Symbolic rwxr-xr-x

Command chmod 755 file

  • chmod 755 deploy.sh
    rwxr-xr-x: owner can do everything; group and others can read and run. Scripts and directories.
  • chmod 644 index.html
    rw-r--r--: owner reads and writes; everyone else reads. Regular files.
  • chmod 600 ~/.ssh/id_ed25519
    rw-------: owner only. SSH refuses private keys that others can read.
  • chmod 700 ~/.ssh
    rwx------: a directory only its owner can enter.
  • chmod u+x run.sh
    Add execute permission for the owner only.
  • chmod g-w shared.txt
    Remove write permission from the group.
  • chmod -R 755 site/
    Apply permissions recursively to a whole tree.

    Careful: Marks every file as executable, not just directories. Safer: find site/ -type f -exec chmod 644 {} +

  • chmod 777 upload/
    Give everyone full access.

    Careful: Any user or compromised process can change or replace the files. Safer: chmod 775 upload/

  • chown www-data:www-data -R /var/www
    Change the owner and group of files.
  • umask 022
    Default permissions for new items: files 644, directories 755.
  • chmod 1777 /tmp
    Sticky bit: anyone can create files, but only owners can delete theirs.
  • chmod 2775 shared/
    Setgid on a directory: new files inherit the directory's group.

Docker

Run, inspect, and clean up containers and images, plus the Docker Compose commands for multi-container apps.

  • docker ps -a
    List all containers, including stopped ones.
  • docker run -d -p 8080:80 --name web nginx
    Run a container in the background, mapping host port 8080 to container port 80.
  • docker run --rm -it ubuntu bash
    Start a throwaway interactive container that is deleted on exit.
  • docker exec -it web sh
    Open a shell inside a running container.
  • docker logs -f --tail 100 web
    Follow the last 100 log lines of a container.
  • docker build -t myapp:1.0 .
    Build an image from the Dockerfile in the current directory.
  • docker images
    List local images and their sizes.
  • docker stop web && docker rm web
    Stop and remove a container.
  • docker cp web:/app/logs/app.log .
    Copy a file out of a container.
  • docker inspect web
    Show full configuration, IP address, mounts, and state as JSON.
  • docker stats
    Live CPU, memory, and network usage per container.
  • docker compose up -d
    Start every service in compose.yaml in the background.
  • docker compose logs -f api
    Follow the logs of one Compose service.
  • docker compose down
    Stop and remove the Compose containers and networks (volumes are kept).
  • docker compose build --no-cache
    Rebuild service images from scratch.
  • docker system df
    Show how much disk space images, containers, and volumes use.
  • docker system prune
    Remove stopped containers, unused networks, and dangling images.

    Careful: Adding -a or --volumes also deletes unused images and data volumes. Safer: docker system df

npm & Node.js

Install, update, audit, and run JavaScript packages with npm and npx.

  • npm ci
    Clean install exactly what package-lock.json says. Use it in CI.
  • npm install express
    Add a dependency.
  • npm install -D eslint
    Add a development-only dependency.
  • npm uninstall express
    Remove a dependency.
  • npm run build
    Run a script from package.json (npm test and npm start need no "run").
  • npm outdated
    List packages that have newer versions.
  • npm update
    Update packages within the version ranges in package.json.
  • npm ls lodash
    Show why a package is installed and which version.
  • npm audit
    Check dependencies for known vulnerabilities.
  • npm audit fix --force
    Fix vulnerabilities even when it needs breaking upgrades.

    Careful: Can install new major versions that break your app. Safer: npm audit fix

  • npx create-vite@latest
    Run a package command without installing it globally.
  • npm version patch
    Bump the patch version, then commit and tag it.
  • npm publish --dry-run
    See exactly what would be published without publishing.
  • node --watch server.js
    Restart a Node.js script whenever its files change.
  • npm init -y
    Create a package.json with default values.

JavaScript regex syntax with the patterns you need most. Try any of them live in the Regex Tester.

  • .
    Any character except a line break (any character at all with the s flag).
  • \d \w \s
    A digit, a word character [A-Za-z0-9_], whitespace. Uppercase (\D \W \S) negates.
  • \b
    A word boundary - \bcat\b matches "cat" but not "concat".
  • ^ $
    Start and end of the string (of each line with the m flag).
  • * + ? {2,5}
    Zero or more, one or more, optional, between 2 and 5 times.
  • .*?
    Lazy: match as little as possible instead of as much as possible.
  • [abc] [^abc] [a-z]
    One of the listed characters, anything except them, or a range.
  • (abc) (?:abc)
    Capturing group, and a group that does not capture.
  • (?<year>\d{4})
    Named group - read it as match.groups.year.
  • cat|dog
    Alternation: either side.
  • (?=px) (?!px)
    Lookahead: followed by px, or not followed by px.
  • (?<=\$)\d+
    Lookbehind: digits that come right after a dollar sign.
  • \1 \k<year>
    Backreference to an earlier group: (\w)\1 finds doubled letters.
  • /pattern/gimsuy
    Flags: global, ignore case, multiline, dotAll, unicode, sticky.
  • \. \* \( \[ \\
    Escape special characters to match them literally.
  • ^\d{4}-\d{2}-\d{2}$
    An ISO date shape, YYYY-MM-DD (shape only, not a valid-date check).
  • str.replace(/(\w+) (\w+)/, "$2 $1")
    Swap two words using group references in the replacement.
  • [...str.matchAll(/\d+/g)]
    Every match with its groups and index (needs the g flag).

SQL

Standard SQL for querying and changing data. Syntax shown works in PostgreSQL, MySQL, SQLite, and SQL Server unless noted.

  • SELECT id, name FROM users WHERE active = 1 ORDER BY name;
    Filter and sort rows.
  • SELECT DISTINCT country FROM users;
    Unique values only.
  • WHERE name LIKE 'Ada%' AND age BETWEEN 18 AND 65
    Pattern match and inclusive range.
  • WHERE deleted_at IS NULL
    Test for NULL - "= NULL" never matches.
  • SELECT * FROM orders o JOIN users u ON u.id = o.user_id;
    Inner join: only rows that match on both sides.
  • LEFT JOIN payments p ON p.order_id = o.id
    Keep every left row, with NULLs where nothing matches.
  • SELECT country, COUNT(*) FROM users GROUP BY country HAVING COUNT(*) > 10;
    Aggregate per group and filter the groups.
  • INSERT INTO users (name, email) VALUES ('Ada', '[email protected]');
    Insert a row.
  • UPDATE users SET active = 0 WHERE id = 42;
    Change existing rows.

    Careful: Without WHERE, every row in the table is updated. Safer: SELECT * FROM users WHERE id = 42;

  • DELETE FROM sessions WHERE expires_at < CURRENT_TIMESTAMP;
    Delete matching rows.

    Careful: Without WHERE, every row is deleted. Run the same WHERE as a SELECT first. Safer: BEGIN; DELETE ...; ROLLBACK;

  • CREATE INDEX idx_users_email ON users (email);
    Speed up lookups and joins on a column.
  • ALTER TABLE users ADD COLUMN last_login TIMESTAMP;
    Add a column to an existing table.
  • WITH recent AS (SELECT * FROM orders WHERE total > 100) SELECT COUNT(*) FROM recent;
    Common table expression: a named subquery.
  • ROW_NUMBER() OVER (PARTITION BY user_id ORDER BY created_at DESC)
    Window function: number rows within each group.
  • COALESCE(nickname, name, 'Anonymous')
    First non-NULL value.
  • CASE WHEN total > 100 THEN 'big' ELSE 'small' END
    Conditional value in a query.
  • BEGIN; ... COMMIT;
    Run several statements as one transaction (ROLLBACK to undo).
  • SELECT ... ORDER BY id OFFSET 20 ROWS FETCH NEXT 10 ROWS ONLY;
    Standard paging (LIMIT 10 OFFSET 20 in PostgreSQL, MySQL, SQLite).

CSS Flexbox & Grid

Layout recipes for modern CSS - centering, spacing, responsive grids, and the overflow fixes nobody remembers.

  • display: grid; place-items: center;
    Center anything horizontally and vertically.
  • display: flex; justify-content: space-between; align-items: center;
    A row with items pushed to both ends and vertically centered.
  • flex-direction: column; gap: 1rem;
    Stack items vertically with even spacing.
  • flex-wrap: wrap;
    Let flex items wrap onto new lines.
  • flex: 1;
    Let an item grow to fill the remaining space.
  • flex-shrink: 0;
    Stop an item (an icon or avatar) from being squeezed.
  • margin-left: auto;
    Push one flex item, and everything after it, to the right.
  • min-width: 0;
    Let a flex or grid child shrink so long text truncates instead of overflowing.
  • grid-template-columns: repeat(3, 1fr);
    Three equal columns.
  • grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    Responsive card grid with no media queries.
  • grid-column: 1 / -1;
    Make a grid item span the full width.
  • grid-template-areas: "header header" "sidebar main";
    Name layout regions and place items with grid-area.
  • align-self: end; justify-self: start;
    Align a single item differently from the rest.
  • order: -1;
    Move an item first visually (screen readers keep source order).
  • aspect-ratio: 16 / 9;
    Keep a box at a fixed ratio, such as a video placeholder.
  • position: sticky; top: 0;
    Stick an element to the top while its container scrolls.

curl & HTTP

Test APIs, inspect headers, and debug redirects and TLS from the command line. Pair it with the HTTP Status Codes reference.

  • curl -I https://rjl.io
    Fetch only the response headers (a HEAD request).
  • curl -iL https://rjl.io
    Show headers and body, and follow redirects.
  • curl -sS -o report.pdf "$URL"
    Download quietly to a file, still showing errors.
  • curl -X POST "$URL" -H "Content-Type: application/json" -d '{"name":"Ada"}'
    POST a JSON body.
  • curl -H "Authorization: Bearer $TOKEN" "$URL"
    Send a bearer token from an environment variable.
  • curl -u ada:secret "$URL"
    Basic authentication with the password on the command line.

    Careful: The password ends up in shell history and process lists. Safer: curl -u ada "$URL"

  • curl -F "[email protected]" "$URL"
    Upload a file as multipart form data.
  • curl -s -o /dev/null -w "%{http_code} %{time_total}s\n" "$URL"
    Print only the status code and total time.
  • curl -v "$URL"
    Verbose: see the TLS handshake, request headers, and response headers.
  • curl --resolve rjl.io:443:203.0.113.10 https://rjl.io
    Test a new server before changing DNS.
  • curl --retry 3 --max-time 10 "$URL"
    Retry transient failures and give up after 10 seconds.
  • curl --compressed "$URL"
    Ask for gzip or brotli and decompress automatically.
  • curl -k https://localhost:8443
    Skip TLS certificate checks.

    Careful: Disables protection against man-in-the-middle attacks. Safer: curl --cacert dev-ca.pem https://localhost:8443

Markdown

GitHub-flavored Markdown for READMEs, issues, and docs. Preview it in the Markdown Viewer.

  • # Heading 1 ... ###### Heading 6
    Headings - one # per level.
  • **bold** *italic* ~~strikethrough~~
    Text emphasis.
  • [link text](https://rjl.io)
    A link.
  • ![Alt text](screenshot.png)
    An image - always write meaningful alt text.
  • - item - nested item
    Bulleted list; indent two spaces to nest.
  • 1. first 2. second
    Numbered list.
  • - [ ] todo - [x] done
    Task list checkboxes.
  • > Quoted text
    Blockquote.
  • `inline code`
    Inline code.
  • ```js console.log("hi"); ```
    Fenced code block with syntax highlighting.
  • | Name | Role | | ---- | ---- | | Ada | Dev |
    A table.
  • ---
    Horizontal rule.
  • Line one<br>Line two
    Line break inside a paragraph (or end the line with two spaces).
  • <details><summary>More</summary>Hidden text</details>
    Collapsible section on GitHub.
  • [Jump to setup](#setup)
    Link to a heading anchor on the same page.

PowerShell

PowerShell 7 equivalents for common Unix commands, for developers working on Windows.

  • Get-ChildItem -Recurse -Filter *.log
    Find files recursively (like find . -name "*.log").
  • Get-Content app.log -Tail 20 -Wait
    Follow a log file (like tail -f).
  • Select-String -Path *.js -Pattern "TODO"
    Search file contents (like grep).
  • Get-Command git | Select-Object Source
    Where a command lives (like which).
  • $env:NODE_ENV = "production"
    Set an environment variable for this session.
  • New-Item -ItemType Directory -Force .\app\src
    Create nested folders (like mkdir -p).
  • Test-Path .\package.json
    Check whether a file or folder exists.
  • Copy-Item -Recurse .\src .\backup
    Copy a folder.
  • Remove-Item -Recurse -Force .\dist
    Delete a folder and its contents.

    Careful: Skips the Recycle Bin - deleted files are gone. Safer: Remove-Item -Recurse -Force .\dist -WhatIf

  • Get-NetTCPConnection -LocalPort 3000 | Select-Object OwningProcess
    Find which process is using a port.
  • Stop-Process -Name node
    Stop processes by name.

    Careful: Stops every node process, not just the one you meant. Safer: Stop-Process -Id 12345

  • Invoke-RestMethod -Uri $url -Method Post -Body ($data | ConvertTo-Json) -ContentType "application/json"
    Call a JSON API and get parsed objects back.
  • Get-Content data.json -Raw | ConvertFrom-Json
    Read a JSON file into objects.
  • (Get-Content file.txt | Measure-Object -Line).Lines
    Count lines (like wc -l).
  • npm run build && npm test
    Run the second command only if the first succeeds (PowerShell 7+).
  • Get-Help Get-ChildItem -Examples
    Show usage examples for any command.

Cron

Five-field cron syntax: minute, hour, day of month, month, day of week. Build and explain expressions in the Cron Expression Generator.

  • * * * * *
    Every minute.
  • */15 * * * *
    Every 15 minutes.
  • 0 * * * *
    At the start of every hour.
  • 30 2 * * *
    Every day at 02:30.
  • 0 9 * * 1-5
    Weekdays at 09:00.
  • 0 0 1 * *
    At midnight on the first day of every month.
  • 0 0 * * 0
    Every Sunday at midnight (0 and 7 both mean Sunday).
  • @reboot /home/ada/start.sh
    Run once at system startup (cron daemons that support @ shortcuts).
  • crontab -e
    Edit the current user's crontab.
  • crontab -l
    List the current user's scheduled jobs.
  • crontab -r
    Remove the current user's crontab.

    Careful: Deletes every job with no confirmation - it sits next to -e on the keyboard. Safer: crontab -l > crontab-backup.txt

HTTP Headers

The request and response headers you set, read and debug most. Look up the numbers in HTTP Status Codes and inspect real responses with the curl topic below.

  • Cache-Control: no-store
    Tell browsers and shared caches never to store the response (use it for private data).
  • Cache-Control: no-cache
    Caches may store the response but must revalidate it with the server before every reuse.
  • Cache-Control: public, max-age=31536000, immutable
    Cache a fingerprinted file for a year; the browser will not revalidate it.
  • ETag: "33a64df5"
    Response: a version tag for this content, used for conditional requests.
  • If-None-Match: "33a64df5"
    Request: send the cached ETag; the server answers 304 Not Modified if it still matches.
  • Content-Type: application/json
    Declare the media type of the body you are sending or returning.
  • Accept: application/json
    Request: the media types the client wants back.
  • Accept-Encoding: gzip, br
    Request: the compression formats the client can decode (the response names its choice in Content-Encoding).
  • Authorization: Bearer <token>
    Request: send an access token (RFC 6750).
  • Location: https://rjl.io/new-page
    Response: where a 201 Created or a 3xx redirect points the client.
  • Set-Cookie: sid=abc123; HttpOnly; Secure; SameSite=Lax; Path=/
    Set a cookie that scripts cannot read and that is only sent over HTTPS.
  • Strict-Transport-Security: max-age=31536000; includeSubDomains
    Tell browsers to use HTTPS only for this domain and its subdomains for a year.
  • Content-Security-Policy: default-src 'self'
    Restrict where scripts, images, styles and other resources may load from.
  • X-Content-Type-Options: nosniff
    Stop browsers from guessing a different type than the one in Content-Type.
  • X-Frame-Options: DENY
    Block other sites from showing the page in a frame (CSP frame-ancestors is the modern form).
  • Referrer-Policy: strict-origin-when-cross-origin
    Send the full URL for same-origin requests and only the origin to other sites.
  • Permissions-Policy: camera=(), microphone=(), geolocation=()
    Turn off browser features for the page and the frames inside it.
  • Access-Control-Allow-Origin: https://rjl.io
    CORS: the one origin allowed to read this response from JavaScript.
  • Access-Control-Allow-Origin: *
    CORS: let any website read this response from JavaScript.

    Careful: Any site can read the response. Use it only for public data. Safer: Access-Control-Allow-Origin: https://rjl.io

  • Vary: Accept-Encoding
    Tell caches which request headers change the response, so they store one copy per value.
  • Range: bytes=0-1023
    Request: ask for the first 1,024 bytes; the server replies 206 Partial Content.
  • Retry-After: 120
    With a 429 or 503: how many seconds to wait before trying again (a date is also allowed).
  • Content-Disposition: attachment; filename="report.pdf"
    Make the browser download the response as a file instead of displaying it.
  • Link: </style.css>; rel=preload; as=style
    Hint that the browser should fetch this resource early.

Vim

Modal editing in Vim: press Esc to get back to Normal mode, then use these keys. Type :help inside Vim for the full manual.

  • i
    Insert before the cursor.
  • a
    Append after the cursor.
  • o
    Open a new line below and start inserting.
  • O
    Open a new line above and start inserting.
  • Esc
    Return to Normal mode (Ctrl-[ does the same).
  • :w
    Write (save) the file.
  • :wq
    Save and quit (ZZ does the same).
  • :q
    Quit; Vim refuses if there are unsaved changes.
  • :q!
    Quit and throw away every unsaved change.

    Careful: Discards all unsaved edits with no way back. Safer: :wq

  • h j k l
    Move left, down, up, right.
  • w b e
    Jump to the next word start, the previous word start, the word end.
  • 0 ^ $
    Jump to the line start, the first non-blank character, the line end.
  • gg G
    Jump to the first line, the last line.
  • 42G
    Jump to line 42 (:42 does the same).
  • Ctrl-d Ctrl-u
    Scroll half a screen down, up.
  • %
    Jump to the matching bracket, brace or parenthesis.
  • { }
    Jump to the previous, next blank line (paragraph).
  • x
    Delete the character under the cursor.
  • dd
    Delete (cut) the current line.
  • yy
    Yank (copy) the current line.
  • p P
    Paste after, before the cursor.
  • u
    Undo.
  • Ctrl-r
    Redo.
  • .
    Repeat the last change.
  • cw
    Change from the cursor to the end of the word.
  • ciw
    Change the whole word under the cursor.
  • ci"
    Change the text inside the double quotes around the cursor.
  • D
    Delete from the cursor to the end of the line.
  • J
    Join the next line onto this one.
  • >> <<
    Indent, outdent the current line.
  • v V Ctrl-v
    Start a character, line or block selection.
  • /text
    Search forward for text (?text searches backward).
  • n N
    Jump to the next, previous search match.
  • *
    Search for the word under the cursor.
  • :noh
    Clear the search highlighting.
  • :%s/old/new/g
    Replace every old with new in the whole file.
  • :%s/old/new/gc
    Same, but ask before each replacement.
  • :e notes.txt
    Open another file.
  • :split :vsplit
    Split the window horizontally, vertically.
  • Ctrl-w w
    Move to the next window (Ctrl-w then h, j, k or l moves by direction).
  • :tabnew
    Open a new tab (gt moves to the next tab).
  • qa ... q then @a
    Record a macro into register a, stop recording, replay it.
  • :set number
    Show line numbers (:set nonumber hides them).
  • :!ls
    Run a shell command without leaving Vim.
  • "+y
    Yank to the system clipboard (needs a Vim built with clipboard support).

kubectl

Inspect and manage a Kubernetes cluster. Commands act on the current context and namespace; add -n NAME to target another namespace. Manifests are YAML, so the YAML / JSON Converter helps when you need to check one.

  • kubectl get pods
    List the pods in the current namespace.
  • kubectl get pods -A
    List pods in every namespace (-A is --all-namespaces).
  • kubectl get pods -o wide
    Add the node and pod IP to the listing.
  • kubectl get pods -l app=web
    Only pods that carry the label app=web.
  • kubectl get deploy,svc
    List several resource types at once (deploy and svc are short names).
  • kubectl get pod web-7d9c -o yaml
    Print the full live manifest of a pod.
  • kubectl describe pod web-7d9c
    Show a pod's details and its recent events (the first stop for a pod that will not start).
  • kubectl logs web-7d9c
    Print a pod's logs.
  • kubectl logs -f web-7d9c
    Stream the logs as they are written.
  • kubectl logs web-7d9c -c sidecar
    Logs from one container of a multi-container pod.
  • kubectl logs --previous web-7d9c
    Logs from the previous, crashed instance of the container.
  • kubectl exec -it web-7d9c -- sh
    Open an interactive shell inside a pod.
  • kubectl cp web-7d9c:/var/log/app.log ./app.log
    Copy a file out of a pod.
  • kubectl port-forward svc/web 8080:80
    Forward local port 8080 to port 80 of the web service.
  • kubectl apply -f deployment.yaml
    Create or update resources from a manifest.
  • kubectl diff -f deployment.yaml
    Show what apply would change, without changing anything.
  • kubectl delete -f deployment.yaml
    Delete the resources a manifest defines.

    Careful: Removes everything the file defines, in one go. Safer: kubectl delete -f deployment.yaml --dry-run=server

  • kubectl delete pod web-7d9c
    Delete one pod; a Deployment usually starts a replacement.
  • kubectl create deployment web --image=nginx
    Create a Deployment without writing YAML.
  • kubectl expose deployment web --port=80
    Create a Service in front of a Deployment.
  • kubectl run tmp --rm -it --image=busybox -- sh
    Start a throwaway pod with a shell; it is deleted on exit.
  • kubectl scale deployment web --replicas=3
    Set the number of replicas.
  • kubectl set image deployment/web web=nginx:1.27
    Change the image of the container named web.
  • kubectl rollout status deployment/web
    Wait for a rollout and report whether it finished.
  • kubectl rollout history deployment/web
    List a Deployment's revisions.
  • kubectl rollout undo deployment/web
    Roll back to the previous revision.
  • kubectl rollout restart deployment/web
    Restart every pod of a Deployment, one batch at a time.
  • kubectl get events --sort-by=.metadata.creationTimestamp
    Show cluster events in the order they happened.
  • kubectl top pods
    Show CPU and memory use per pod (needs metrics-server in the cluster).
  • kubectl get secret db -o jsonpath='{.data.password}' | base64 -d
    Read one value from a Secret (values are stored base64-encoded).
  • kubectl config get-contexts
    List the clusters and users in your kubeconfig.
  • kubectl config use-context staging
    Switch to the staging context.
  • kubectl config set-context --current --namespace=dev
    Make dev the default namespace for the current context.
  • kubectl auth can-i delete pods
    Check whether you are allowed to do something.
  • kubectl explain pod.spec.containers
    Show the documented fields of a resource.
  • kubectl api-resources
    List every resource type the cluster serves.
  • kubectl drain node-1 --ignore-daemonsets
    Evict the pods from a node so you can maintain it.

    Careful: Evicts every pod on the node; pods without a controller are not recreated. Safer: kubectl cordon node-1

Common Use Cases

Undoing a Git Mistake

Committed to the wrong branch or reset too far? Search "undo" to find the right command - and the reflog to get lost work back.

Server Troubleshooting

Find what is using a port, follow a log, check disk space, or fix SSH key permissions - on Linux or Windows.

Container Work

Shell into a container, follow its logs, rebuild a Compose service, and reclaim disk space without deleting the wrong thing.

Writing Queries

Remember join, group, window function, and paging syntax - with warnings on the UPDATE and DELETE statements that need a WHERE.

Building Layouts

Center an element, build a responsive card grid, or fix a flex child that refuses to shrink, with copy-ready CSS.

Onboarding

Send a new teammate a link straight to the Git or Docker topic, or print one as a desk reference.

Safer Alternatives at a Glance

Instead of Try first Why
git push --forcegit push --force-with-leaseRefuses to overwrite commits you have not seen
git reset --hardgit stashKeeps a recoverable copy of your changes
git clean -fdgit clean -ndLists what would be deleted
rm -rf dir/rm -ri dir/Asks before each deletion
Remove-Item -Recurse -Force... -WhatIfShows what would happen without doing it
DELETE FROM t WHERE ...SELECT * FROM t WHERE ...Confirms exactly which rows match
chmod 777chmod 775 / 755Others can still read but not modify
kill -9kill -15Lets the process shut down cleanly
curl -kcurl --cacert ca.pemKeeps TLS verification on

Pro Tip: Link to a Topic or a Search

/cheat-sheets/#docker opens the Docker sheet on its own, and /cheat-sheets/?q=port opens a search across every topic.

Press / anywhere on the page to jump to the search box.

Frequently Asked Questions

Why We Built These Developer Cheat Sheets

Every developer keeps a mental list of commands they look up again and again - how to undo a commit, which flag shows a port, the exact grid syntax for a responsive layout. Most cheat sheets online are either a single tool or so long that the answer is buried. We put the commands developers actually use across a dozen tools on one fast, searchable page.

Search runs across every topic at once, so "port" finds the Bash, PowerShell, and Docker answers together. Every command copies in one click. Commands that delete data or weaken security are marked with a safer alternative to run first, because a cheat sheet that hands you rm -rf without a warning is not doing its job. Each topic has its own link and a clean print layout, and nothing you type leaves your browser.

The Developer Cheat Sheets are part of RJL.io's collection of free developer tools. Test patterns in the Regex Tester, look up responses in the HTTP Status Codes reference, and check workflow files with the GitHub Actions Validator.

Is your site ready for Google and AI search?

The free SEO Analyzer checks any page in seconds - meta tags, structured data, AI crawler access - and tells you exactly how to fix each issue on your platform.