Searchable terminal commands for Git, Node, Python, Docker, mobile and more.
892 commands in 42 sections · 554 hidden in collapsed sections · <placeholders> need replacing before you run a command
git statusShow changed, staged and untracked files
git add -pStage changes hunk by hunk, interactively
git commit -m "<message>"Commit staged changes with a message
git diffShow unstaged changes
git diff --stagedShow what is about to be committed
git diff main...HEADShow everything changed since the branch left main
git diff --statSummarise changes per file
git pull --rebasePull without creating a merge commit
git restore <file>destructiveDiscard unstaged changes in a file
git restore --staged <file>Unstage a file but keep the changes
git commit --amend --no-editAdd staged changes to the last commit
git commit --amend -m "<message>"Rewrite the last commit message
git reset --soft HEAD~1Undo the last commit, keep its changes staged
git reset HEAD~1Undo the last commit, keep its changes unstaged
git reset --hard HEADdestructiveThrow away every uncommitted change
git reset --hard origin/maindestructiveMake the branch exactly match the remote
git log --oneline --graph --allCompact commit tree across every branch
git log -p <file>Full change history of one file
git log -S "<text>"Find commits that added or removed some text
git log --author="<name>" --since="2 weeks ago"Filter history by author and date
git show <sha>Show one commit's message and diff
git blame -L 10,20 <file>Who last changed lines 10 to 20
git bisect startBinary-search commits to find the one that broke something
git shortlog -snContributors ranked by commit count
git config --global user.name "<name>"Set your commit author name
git config --global user.email "<email>"Set your commit author email
git config --global init.defaultBranch mainUse main for new repositories
git config --global pull.rebase trueRebase instead of merge on every pull
git config --global push.autoSetupRemote trueFirst push creates the upstream automatically
git config --global rerere.enabled trueRemember how you resolved a conflict and reuse it
git config --global core.editor "code --wait"Use VS Code for commit messages and rebases
git config --global alias.st statusCreate a shortcut: git st
gh auth loginSign in to GitHub from the terminal
gh auth statusShow which account and scopes are active
gh repo create <name> --private --source=. --pushCreate a GitHub repo from the current folder and push it
gh repo clone <owner/repo>Clone a repository
gh repo fork --cloneFork the current repo and clone your fork
gh browseOpen the current repo in the browser
gh pr create --fillOpen a PR using your commit messages as title and body
gh pr create --draftOpen a draft PR
ls -lahList files with sizes, permissions and hidden files
tree -L 2 -I node_modulesFolder tree two levels deep, skipping node_modules
grep -rn "<text>" .Search text in every file, with line numbers
rg "<text>"Same search, much faster, respects .gitignore (ripgrep)
rg -l "<text>" -g "*.ts"Only list TypeScript files that contain the text
find . -name "*.log"Find files by name pattern
find . -type f -size +100MFind files larger than 100 MB
find . -name "node_modules" -type d -prune -exec rm -rf {} +destructiveDelete every node_modules folder below here
lsof -i :<port>Which process is using a port
lsof -ti :<port> | xargs kill -9destructiveKill whatever is using a port
lsof -iTCP -sTCP:LISTEN -n -PmacOSEvery port that is listening
ss -tulpnLinuxEvery listening port and its process
netstat -ano | findstr :<port>WindowsWhich PID is using a port
taskkill /PID <pid> /FWindowsdestructiveForce-stop a process
npx kill-port <port>Free a port on any OS
kill <pid>Ask a process to stop
curl -I <url>Fetch only the response headers
curl -L <url>Follow redirects
curl -sS <url> | jqFetch JSON and pretty-print it
curl -X POST <url> -H "Content-Type: application/json" -d '{"a":1}'Send a JSON POST request
curl -o /dev/null -s -w "%{http_code} %{time_total}s\n" <url>Only the status code and total time
curl -o <file> <url>Download a file
ping <host>Is the host reachable, and how fast
dig <domain>DNS lookup
Ctrl+RSearch your command history as you type
!!Repeat the last command; sudo !! reruns it as root
cd -Go back to the previous folder
Ctrl+A / Ctrl+EJump to the start / end of the line
Ctrl+U / Ctrl+KDelete to the start / end of the line
Ctrl+LClear the screen
<cmd1> && <cmd2>Run the second command only if the first succeeds
<cmd1> || <cmd2>Run the second command only if the first fails
brew install <formula>Install a command-line tool
brew install --cask <app>Install a desktop app
brew upgradeUpgrade everything installed with Homebrew
brew cleanupDelete old versions and free disk space
brew services start <service>Run a service such as postgresql or redis in the background
brew doctorDiagnose Homebrew problems
xcode-select --installInstall the Command Line Tools (git, make, clang)
open .Open the current folder in Finder
awk '{print $1}' <file>Print the first column of each line
awk -F, '{sum += $3} END {print sum}' <file>.csvSum a CSV column
cut -d, -f1,3 <file>.csvPick columns 1 and 3
sed -n '10,20p' <file>Print lines 10 to 20
grep -v "<text>" <file>Lines that do not match
grep -c "<text>" <file>Count matching lines
grep -E "error|warn" <file>Lines matching any of several patterns
cat <file> | xargs -n1 <command>Run a command once per input line
sudo apt update && sudo apt upgrade -yUpdate package lists and upgrade everything
sudo apt install <pkg>Install a package
cat /etc/os-releaseDistribution and version
free -hMemory and swap usage
lsblkDisks and partitions
whoami && idCurrent user and their groups
sudo -u <user> <command>Run a command as another user
sudo adduser <user>Create a user
Get-ChildItem -Recurse -Filter *.logFind files by name (like find)
Select-String -Path *.ts -Pattern "<text>"Search inside files (like grep)
Get-Content <file> -Tail 50 -WaitFollow a log file (like tail -f)
Get-NetTCPConnection -LocalPort <port>Which process is using a port
Get-Process <name>Find running processes
Stop-Process -Name <name> -ForcedestructiveKill processes by name
Remove-Item -Recurse -Force node_modulesdestructiveDelete a folder (like rm -rf)
$env:NODE_ENV = "production"Set an environment variable for this session
code -r .Open a folder in the current VS Code window
code -g <file>:<line>Open a file at a specific line
code --diff <a> <b>Compare two files side by side
code --install-extension <publisher.extension>Install an extension
code --list-extensions > extensions.txtSave your extension list
code --disable-extensionsStart without extensions to rule them out
cursor .Open a folder in Cursor
export EDITOR="code --wait"Editor used by git, crontab and other tools
:wq :q!Vim: save and quit / quit without saving
nano <file>Simple terminal editor (Ctrl+O saves, Ctrl+X exits)
node --watch <file>.jsRestart on file changes, no nodemon needed
node --env-file=.env <file>.jsLoad a .env file without dotenv
node --run <script>Run a package.json script faster than npm run (Node 22+)
node <file>.tsRun TypeScript directly via type stripping (Node 22.18+ / 23.6+)
node --inspect <file>.jsDebug in Chrome DevTools at chrome://inspect
node --inspect-brk <file>.jsSame, but pause on the first line
node --testRun tests with the built-in test runner
node --max-old-space-size=4096 <file>.jsGive Node 4 GB of heap
npm init -yCreate a package.json with defaults
npm ciClean install exactly from the lockfile (use in CI)
npm i <pkg>Install a dependency
npm i -D <pkg>Install a dev dependency
npm i <pkg>@latestUpgrade one package to its latest version
npm uninstall <pkg>Remove a dependency
npm runList every script in package.json
npm run dev -- --port 4000Pass extra arguments through to a script
corepack enableUse the pnpm or Yarn version pinned in package.json
pnpm iInstall dependencies (fast, disk-efficient)
pnpm add <pkg>Add a dependency (-D for dev)
pnpm up -i --latestPick packages to upgrade interactively
pnpm dlx <pkg>Run a package without installing it (like npx)
pnpm -r run buildRun a script in every workspace package
pnpm --filter <pkg> devRun a script in one workspace package
pnpm why <pkg>Why a package is installed
npx tsc --noEmitType-check without writing files
npx tsc --noEmit --watchType-check on every save
npx tsc --initCreate a tsconfig.json
npx tsc --showConfigThe final tsconfig after extends are applied
npx tsx <file>.tsRun a TypeScript file directly
npx tsx watch <file>.tsRun it and restart on changes
npm init @eslint/config@latestSet up ESLint
npx eslint .Lint the project
npx vitestRun tests in watch mode
npx vitest run --coverageRun once with a coverage report
npx vitest -t "<name>"Only tests whose name matches
npx vitest related <file>Only tests that import a given file
npx vitest -uUpdate snapshots
npx jest --watchJest in watch mode
npx jest -t "<name>"Only Jest tests whose name matches
npx jest --coverageJest coverage report
npx create-next-app@latest <name>Create a new Next.js app
next devDev server; Turbopack is the default from v16
next dev -p 4000Dev server on another port
next dev -H 0.0.0.0Reachable from your phone on the same network
next dev --experimental-httpsLocal HTTPS with a self-signed certificate
next buildProduction build
next build --webpackBuild with webpack instead of Turbopack
next build --debugBuild output that also lists rewrites, redirects and headers
npm create vite@latestNew React, Vue or Svelte app on Vite
npx viteVite dev server
npx vite --hostDev server reachable on your network
npx vite buildProduction build
npx vite previewServe the production build locally
npx shadcn@latest initSet up shadcn/ui
npx shadcn@latest add <component>Add a shadcn/ui component
npx storybook@latest initSet up Storybook
npx sv create <name>New SvelteKit or Svelte project
npm run dev -- --openDev server and open the browser
npm run dev -- --hostDev server reachable on your network
npm run buildProduction build
npm run previewServe the production build locally
npx sv addPick integrations to add
npx sv add tailwindcssAdd Tailwind CSS
npx sv add eslint prettierAdd linting and formatting
python3 --versionPython version
python -m <module>Run a module with this exact interpreter (safer than a bare tool name)
python -i <file>.pyRun a script, then stay in the REPL with its variables
python -c "print(1 + 1)"Run a one-line script
python -m http.server 8000Serve the current folder over HTTP
python -m json.tool <file>.jsonPretty-print JSON
python -m pdb <file>.pyRun under the debugger
python -m cProfile -s time <file>.pyWhich functions are slow
python -m venv .venvCreate a virtual environment
source .venv/bin/activateActivate it on macOS or Linux
.venv\Scripts\activateWindowsActivate the virtual environment
deactivateLeave the virtual environment
python -m pip install <pkg>Install into the active interpreter, never the wrong one
pip install -r requirements.txtInstall from a requirements file
pip install -e .Install your own project in editable mode
pip freeze > requirements.txtPin current versions to a file
ruff check .Lint very quickly
ruff check . --fixLint and fix
ruff format .Format (Black-compatible)
black .Format with Black
mypy .Type-check your Python code
pyrightFaster type checker, the engine behind Pylance
pre-commit installRun hooks before every commit
pre-commit run --all-filesRun every hook on the whole repo
django-admin startproject <name> .New project in the current folder
python manage.py startapp <app>New app folder with models, views and admin
python manage.py runserverDev server on port 8000
python manage.py makemigrationsCreate migrations from model changes
python manage.py migrateApply migrations
python manage.py showmigrationsWhich migrations are applied
python manage.py sqlmigrate <app> <number>SQL a migration will run
python manage.py createsuperuserCreate an admin user
fastapi dev main.pyFastAPI dev server with reload; docs at /docs
fastapi run main.pyFastAPI in production mode
uvicorn main:app --reloadAny ASGI app with auto-reload
uvicorn main:app --host 0.0.0.0 --port 8000 --workers 4Production-style Uvicorn
flask --app app run --debugFlask with debugger and reload
flask --app app routesList every Flask route
gunicorn app:app -w 4 -b 0.0.0.0:8000Production server for Flask or Django (WSGI)
gunicorn main:app -k uvicorn.workers.UvicornWorker -w 4Gunicorn managing Uvicorn workers for FastAPI
go mod init <module>Start a new module
go run .Build and run the package in this folder
go build -o bin/app .Build a binary into bin/app
GOOS=linux GOARCH=amd64 go build -o bin/app .Cross-compile for Linux servers
go test ./...Run tests in every package
go test -run <TestName> -v ./...Run matching tests with output
go test -race ./...Run tests with the race detector
go test -cover ./...Test coverage per package
rustup updateUpdate the Rust toolchain
cargo new <name>New binary project with Cargo.toml and src/main.rs
cargo runBuild and run the project (debug build)
cargo checkType-check quickly without producing a binary
cargo build --releaseOptimised build in target/release
cargo testRun unit, integration and doc tests
cargo test <name> -- --nocaptureRun matching tests and show println! output
cargo add <crate>Add a dependency
java -versionInstalled Java version
jshellInteractive Java shell
sdk install javaInstall the default JDK with SDKMAN! (sdk list java shows other versions)
export JAVA_HOME=$(/usr/libexec/java_home -v 17)macOSSwitch the active JDK
mvn clean installBuild, test and install to the local repository
mvn test -Dtest=<Class>Run one test class
mvn dependency:treeMaven dependency tree; find version conflicts
./mvnw spring-boot:runRun a Spring Boot app with the Maven wrapper
dotnet new listAvailable project templates
dotnet new webapi -n <name>New Web API project
dotnet runBuild and run the project in this folder
dotnet watchRun with hot reload
dotnet buildCompile the project or solution
dotnet testRun tests in the solution
dotnet add package <package>Add a NuGet package
dotnet restoreRestore dependencies
php -S localhost:8000Built-in development server
composer installInstall from composer.lock
composer require <vendor/package>Add a dependency
composer updateUpdate dependencies
composer dump-autoloadRebuild the autoloader after adding classes
php artisan serveLaravel dev server
php artisan migrateApply migrations
php artisan migrate:fresh --seeddestructiveDrop every table, migrate and seed
npx @react-native-community/cli init <name>New bare React Native project
npx create-expo-app@latest <name>New Expo project
npx react-native start --reset-cacheMetro with a cleared cache
npx react-native run-androidBuild and launch on Android
npx react-native run-ios --simulator="iPhone 16"Build and launch on a specific simulator
npx react-native doctorCheck your environment and fix problems
npx react-native infoEnvironment details for bug reports
npx expo start -cExpo dev server with a cleared cache
adb devicesConnected devices and emulators
adb reverse tcp:8081 tcp:8081Let a USB device reach Metro on your machine
adb logcat *:EOnly error logs
adb logcat | grep ReactNativeJSOnly JavaScript logs from a React Native app
adb shell input keyevent 82Open the React Native dev menu
adb install -r <file>.apkInstall or reinstall an APK
adb uninstall <package>Uninstall an app
adb shell am start -W -a android.intent.action.VIEW -d "<url>"Test a deep link
cd ios && pod installInstall native iOS dependencies
cd ios && pod install --repo-updateSame, with fresh pod specs
cd ios && rm -rf Pods Podfile.lock && pod installReinstall pods from scratch
xcrun simctl list devicesAvailable simulators
xcrun simctl openurl booted "<url>"Test a deep link on the running simulator
xcrun simctl io booted screenshot screen.pngScreenshot the simulator
xcrun simctl erase alldestructiveReset every simulator
rm -rf ~/Library/Developer/Xcode/DerivedDataClear Xcode's build cache
docker ps -aAll containers, including stopped ones
docker imagesLocal images
docker build -t <name> .Build an image from the Dockerfile here
docker run --rm -p 3000:3000 <image>Run an image, map a port, remove it on exit
docker run --rm -it <image> shPoke around inside an image
docker exec -it <container> shShell into a running container
docker logs -f <container>Follow a container's logs
docker statsLive CPU and memory per container
kubectl config get-contextsClusters you can talk to
kubectl config use-context <context>Switch to another cluster
kubectl get pods -APods in every namespace
kubectl get all -n <namespace>Everything in a namespace
kubectl describe pod <pod>Pod details and events; start here when debugging
kubectl logs -f <pod>Follow a pod's logs
kubectl logs <pod> --previousLogs from the crashed container before the restart
kubectl exec -it <pod> -- shShell into a pod
psql -h <host> -U <user> -d <db>Connect to Postgres
\dt \d <table> \l \qpsql: list tables, describe a table, list databases, quit
pg_dump <db> > backup.sqlBack up a Postgres database
psql <db> < backup.sqlRestore a Postgres backup
createdb <db>Create a Postgres database
dropdb <db>destructiveDelete a Postgres database
mysql -u root -pConnect to MySQL
mysqldump -u <user> -p <db> > backup.sqlBack up a MySQL database
vercelDeploy a preview to Vercel
vercel --prodDeploy to production
vercel env pullDownload env variables to .env.local
vercel logs <url>Logs for a deployment
netlify deploy --prodDeploy to Netlify
npx wrangler deployDeploy to Cloudflare Workers
npx wrangler devRun a Worker locally
firebase deployDeploy to Firebase
openssl rand -hex 32Random 256-bit secret
openssl rand -base64 32Random secret in Base64
npx gitleaks detectFind secrets committed to the repo
npm audit --omit=devVulnerabilities in production dependencies only
pip-auditVulnerabilities in Python dependencies
docker scout cves <image>Vulnerabilities in a Docker image
npx lighthouse <url> --viewPerformance, accessibility and SEO audit
shasum -a 256 <file>SHA-256 checksum of a file
aws configureSet up access keys and a default region
aws sso login --profile <profile>Sign in with AWS SSO
export AWS_PROFILE=<profile>Use a profile for this shell
aws sts get-caller-identityWhich account and role you are actually using
aws s3 ls s3://<bucket>List a bucket
aws s3 cp <file> s3://<bucket>/Upload a file
aws s3 sync ./dist s3://<bucket> --deletedestructiveMirror a folder to a bucket, deleting extra files
aws logs tail <log-group> --followFollow CloudWatch logs
rm -rf node_modules package-lock.json && npm iFixes most dependency install problems: a clean reinstall
npm i --legacy-peer-depsFixes ERESOLVE unable to resolve dependency tree
sudo chown -R $(whoami) ~/.npmFixes EACCES permission errors from npm
export NODE_OPTIONS=--max-old-space-size=4096Fixes JavaScript heap out of memory during builds
ulimit -n 65536Fixes EMFILE: too many open files (Metro, Jest, watchers)
lsof -ti :<port> | xargs kill -9destructiveFixes EADDRINUSE: address already in use
git rm -r --cached . && git add .Fixes .gitignore not ignoring files that were already committed
git pull --rebaseFixes push rejected because the remote contains work you don't have