⚡ Dev Cheat Sheet

Git • Docker • Compose • ADB • npm/yarn • kubectl • Networking • Linux • macOS • Useful

🔌 Git

Init a repo

git init

Create a new local repository

Clone a repo

git clone https://github.com/user/repo.git

Download a remote repository

Check status

git status

Show changed/staged files

Stage files

git add .

Stage all changes for commit

Commit

git commit -m "feat: add login"

Save staged changes with a message

Push

git push origin main

Upload commits to remote

Pull

git pull origin main

Fetch + merge remote changes

Create branch

git checkout -b feature/login

Create and switch to new branch

Switch branch

git checkout main

Switch to an existing branch

Merge branch

git merge feature/login

Merge a branch into current one

View log

git log --oneline --graph

Show compact commit history

Stash changes

git stash

Temporarily save uncommitted work

Apply stash

git stash pop

Restore last stashed changes

Undo last commit (keep files)

git reset --soft HEAD~1

Undo commit but keep changes staged

Discard file changes

git checkout -- file.txt

Restore file to last commit state

Delete branch

git branch -d feature/login

Remove a local branch

Show remotes

git remote -v

List remote URLs

Diff changes

git diff

Show unstaged file differences

🐳 Docker

Build image

docker build -t myapp:latest .

Build image from Dockerfile in current dir

Run container

docker run -d -p 8080:80 --name web myapp

Run detached, map port 8080 to 80

List running containers

docker ps

Show active containers

List all containers

docker ps -a

Include stopped containers

Stop container

docker stop web

Gracefully stop a running container

Remove container

docker rm web

Delete a stopped container

List images

docker images

Show all local images

Remove image

docker rmi myapp:latest

Delete a local image

View logs

docker logs -f web

Follow container logs in real-time

Exec into container

docker exec -it web /bin/sh

Open shell inside running container

Pull image

docker pull nginx:alpine

Download image from Docker Hub

Inspect container

docker inspect web

Show detailed container info (IP, mounts…)

Prune unused data

docker system prune -a

Remove all unused images, containers, networks

Copy file to container

docker cp file.txt web:/app/

Copy local file into container

List volumes

docker volume ls

Show all Docker volumes

List networks

docker network ls

Show all Docker networks

📦 Docker Compose

Start services

docker compose up -d

Start all services in background

Stop services

docker compose down

Stop and remove containers + networks

Stop + remove volumes

docker compose down -v

Also remove named volumes

Rebuild and start

docker compose up -d --build

Force rebuild images before starting

View logs

docker compose logs -f api

Follow logs for a specific service

List services

docker compose ps

Show running compose services

Exec into service

docker compose exec api sh

Open shell in a running service

Restart a service

docker compose restart api

Restart one specific service

Scale service

docker compose up -d --scale api=3

Run 3 instances of the api service

Pull latest images

docker compose pull

Download latest images for all services

📱 ADB (Android Debug Bridge)

List connected devices

adb devices

Show all connected Android devices/emulators

Connect over Wi-Fi

adb connect 192.168.1.100:5555

Connect to device wirelessly (after enabling TCP/IP)

Enable TCP/IP mode

adb tcpip 5555

Switch device to TCP/IP mode on port 5555

Install APK

adb install app.apk

Install an APK on the connected device

Install APK (replace existing)

adb install -r app.apk

Reinstall keeping data

Uninstall app

adb uninstall com.example.app

Remove app by package name

Push file to device

adb push local.txt /sdcard/

Copy file from PC to device

Pull file from device

adb pull /sdcard/file.txt ./

Copy file from device to PC

Open shell

adb shell

Open interactive shell on the device

Run shell command

adb shell pm list packages

List all installed packages

Search installed packages

adb shell pm list packages | grep chrome

Find packages matching a keyword

View logcat

adb logcat

Stream device logs in real-time

Filter logcat by tag

adb logcat -s MyApp:D

Show only logs with tag MyApp at debug level+

Clear logcat

adb logcat -c

Clear the log buffer

Take screenshot

adb shell screencap /sdcard/screen.png

Capture screenshot and save to device

Record screen

adb shell screenrecord /sdcard/video.mp4

Record device screen (Ctrl+C to stop)

Reboot device

adb reboot

Restart the connected device

Reboot into bootloader

adb reboot bootloader

Reboot into fastboot/bootloader mode

Reboot into recovery

adb reboot recovery

Reboot into recovery mode

Start an activity

adb shell am start -n com.example.app/.MainActivity

Launch a specific activity

Force stop app

adb shell am force-stop com.example.app

Force kill an application

Clear app data

adb shell pm clear com.example.app

Wipe all data for an app (like fresh install)

Get device IP address

adb shell ip addr show wlan0

Show Wi-Fi IP address of the device

Get device model

adb shell getprop ro.product.model

Show the device model name

Get Android version

adb shell getprop ro.build.version.release

Show the Android OS version

Get battery info

adb shell dumpsys battery

Show battery level, status, temperature

Key event (Home)

adb shell input keyevent KEYCODE_HOME

Simulate pressing the Home button

Key event (Back)

adb shell input keyevent KEYCODE_BACK

Simulate pressing the Back button

Input text

adb shell input text "hello"

Type text on the focused input field

Tap screen coordinates

adb shell input tap 500 1200

Simulate a tap at x=500 y=1200

Swipe gesture

adb shell input swipe 500 1500 500 300 300

Swipe from (500,1500) to (500,300) in 300ms

Port forwarding

adb forward tcp:8080 tcp:8080

Forward PC port to device port

Reverse port forwarding

adb reverse tcp:3000 tcp:3000

Forward device port to PC port (e.g. for dev server)

Get APK path

adb shell pm path com.example.app

Show the on-device path of an installed APK

Dump UI hierarchy

adb shell uiautomator dump /sdcard/ui.xml

Dump current UI layout to XML for inspection

Open a URL

adb shell am start -a android.intent.action.VIEW -d "https://example.com"

Open a URL in the default browser

Enable/disable Wi-Fi

adb shell svc wifi enable

Toggle Wi-Fi (use disable to turn off)

Target specific device

adb -s SERIAL_NUMBER shell

Run command on a specific device when multiple are connected

Sideload OTA update

adb sideload update.zip

Flash an OTA update from recovery mode

Kill ADB server

adb kill-server

Stop the ADB daemon (useful for fixing connection issues)

Start ADB server

adb start-server

Start the ADB daemon

📦 npm / yarn

Init project

npm init -y

Create package.json with defaults

Install dependencies

npm install

Install all deps from package.json

Add package

npm install express

Install and save a dependency

Add dev dependency

npm install -D jest

Install as devDependency

Uninstall package

npm uninstall lodash

Remove a dependency

Run script

npm run dev

Execute a script from package.json

List outdated

npm outdated

Show packages with newer versions

Update packages

npm update

Update packages to latest allowed by semver

Global install

npm install -g nodemon

Install package globally

List global packages

npm list -g --depth=0

Show globally installed packages

Check vulnerabilities

npm audit

Scan dependencies for known vulnerabilities

Fix vulnerabilities

npm audit fix

Auto-fix vulnerable dependencies

Clear cache

npm cache clean --force

Clear the npm cache

npx run once

npx create-react-app my-app

Run a package without installing it globally

Yarn add package

yarn add axios

Install dependency with Yarn

Yarn dev dependency

yarn add -D typescript

Add devDependency with Yarn

Kubernetes (kubectl)

Get pods

kubectl get pods

List all pods in current namespace

Get all resources

kubectl get all

List pods, services, deployments, etc.

Get pods (all namespaces)

kubectl get pods -A

List pods across every namespace

Describe pod

kubectl describe pod my-pod

Show detailed info, events, status

Pod logs

kubectl logs -f my-pod

Stream logs from a pod

Exec into pod

kubectl exec -it my-pod -- /bin/sh

Open shell inside a running pod

Apply manifest

kubectl apply -f deployment.yaml

Create or update resources from YAML

Delete resource

kubectl delete -f deployment.yaml

Remove resources defined in YAML

Scale deployment

kubectl scale deployment api --replicas=3

Scale to 3 replicas

Rollout restart

kubectl rollout restart deployment api

Restart all pods in a deployment

Rollout status

kubectl rollout status deployment api

Watch deployment rollout progress

Port forward

kubectl port-forward svc/api 8080:80

Forward local port 8080 to service port 80

Get services

kubectl get svc

List all services

Get namespaces

kubectl get ns

List all namespaces

Switch namespace

kubectl config set-context --current --namespace=dev

Change default namespace

Get contexts

kubectl config get-contexts

List available cluster contexts

Switch context

kubectl config use-context prod-cluster

Switch to a different cluster

Get events

kubectl get events --sort-by=.metadata.creationTimestamp

Show cluster events sorted by time

Top pods (resource usage)

kubectl top pods

Show CPU/memory usage per pod

Copy file to pod

kubectl cp file.txt my-pod:/tmp/

Copy local file into a pod

🌐 Networking & Debug

Ping host

ping -c 4 google.com

Check if host is reachable

DNS lookup

nslookup example.com

Resolve domain to IP address

Dig DNS records

dig example.com A +short

Query specific DNS record type

Traceroute

traceroute google.com

Show network path to a host

Netstat listening ports

netstat -tlnp

Show all listening TCP ports

ss listening sockets

ss -tlnp

Modern alternative to netstat

Check open port

nc -zv host.com 443

Test if a specific port is open

Curl with headers

curl -I https://example.com

Show only HTTP response headers

Curl timing info

curl -o /dev/null -s -w "Total: %{time_total}s\n" https://example.com

Measure request time

Wget download

wget -O file.zip https://example.com/file.zip

Download file from URL

Show IP address

ip addr show

List all network interfaces and IPs

Public IP

curl -s ifconfig.me

Show your public IP address

Check SSL certificate

openssl s_client -connect example.com:443 -servername example.com

Inspect SSL/TLS cert details

SSH tunnel

ssh -L 8080:localhost:80 user@server

Forward local port 8080 to remote port 80

SSH key generate

ssh-keygen -t ed25519 -C "me@email.com"

Generate a modern SSH key pair

Copy SSH key to server

ssh-copy-id user@server

Install public key for passwordless login

🐧 Linux Daily Commands

Update packages (Debian/Ubuntu)

sudo apt update && sudo apt upgrade -y

Refresh repos and upgrade all packages

Update packages (Fedora/RHEL)

sudo dnf upgrade --refresh

Update all packages on dnf-based distros

Install package (apt)

sudo apt install htop

Install a package via apt

Search package (apt)

apt search nginx

Find available packages by keyword

Remove package (apt)

sudo apt remove --purge nginx

Uninstall package and its config files

Systemd service status

systemctl status nginx

Check if a service is running

Start / stop / restart service

sudo systemctl restart nginx

Restart a systemd service

Enable service on boot

sudo systemctl enable nginx

Auto-start service at boot

View journal logs

journalctl -u nginx -f

Follow logs for a specific service

Disk space

df -h

Show mounted filesystems and free space

Memory usage

free -h

Show RAM and swap usage

CPU / process monitor

htop

Interactive process viewer (install first)

Who is logged in

w

Show logged-in users and their activity

File permissions

chmod 755 script.sh

Set rwxr-xr-x permissions

Change owner

sudo chown -R user:group /var/www

Recursively change file ownership

Add user

sudo useradd -m -s /bin/bash devuser

Create user with home dir and bash shell

Switch user

su - devuser

Switch to another user with their environment

Cron jobs

crontab -e

Edit your cron schedule

List cron jobs

crontab -l

Show your scheduled cron tasks

Symbolic link

ln -s /path/to/target /path/to/link

Create a symbolic link

Firewall allow port (ufw)

sudo ufw allow 22/tcp

Open a TCP port in UFW firewall

Firewall status

sudo ufw status verbose

Show active firewall rules

System uptime

uptime

Show how long the system has been running

Kernel version

uname -r

Show current Linux kernel version

Distro info

cat /etc/os-release

Show Linux distribution details

Mount USB drive

sudo mount /dev/sdb1 /mnt/usb

Mount a device to a directory

Unmount drive

sudo umount /mnt/usb

Safely unmount a device

Find large files

find / -type f -size +100M 2>/dev/null

Find files larger than 100 MB

Kill process by name

pkill -f "node server"

Kill all processes matching a pattern

Background job

nohup ./script.sh &

Run command in background surviving logout

Environment variables

export MY_VAR="value"

Set an environment variable for current session

Alias shortcut

alias ll="ls -la"

Create a command shortcut (add to ~/.bashrc to persist)

Reload shell config

source ~/.bashrc

Apply changes to shell config without restarting

🍎 macOS Daily Commands

Install Homebrew

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Install the Homebrew package manager

Brew install

brew install wget

Install a CLI tool via Homebrew

Brew install app (cask)

brew install --cask firefox

Install a GUI application

Brew update & upgrade

brew update && brew upgrade

Update Homebrew and upgrade all packages

Brew cleanup

brew cleanup --prune=all

Remove old versions and cache

Brew list installed

brew list

Show all installed formulae and casks

Brew search

brew search node

Find available packages by name

Brew uninstall

brew uninstall wget

Remove an installed package

Brew services

brew services list

Show running Homebrew-managed services

Start brew service

brew services start postgresql

Start a service and auto-launch at login

Open Finder from terminal

open .

Open current directory in Finder

Open file with default app

open image.png

Open file with its default application

Open URL in browser

open https://github.com

Open a URL in the default browser

Copy to clipboard

echo "hello" | pbcopy

Copy text to macOS clipboard

Paste from clipboard

pbpaste

Output clipboard contents to terminal

Show/hide hidden files (Finder)

defaults write com.apple.finder AppleShowAllFiles -bool true && killall Finder

Toggle hidden file visibility in Finder

Flush DNS cache

sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder

Clear the DNS resolver cache

Screenshot (clipboard)

screencapture -c

Take screenshot and copy to clipboard

Screenshot to file

screencapture ~/Desktop/screen.png

Save screenshot to a file

Say text aloud

say "build complete"

Text-to-speech from terminal

Prevent sleep

caffeinate -t 3600

Keep Mac awake for 1 hour

System info

system_profiler SPHardwareDataType

Show hardware overview (model, CPU, RAM)

macOS version

sw_vers

Show macOS product name and version

Disk usage (GUI-friendly)

du -sh ~/Library/Caches/*

Check cache folder sizes

Purge memory

sudo purge

Force macOS to free up inactive RAM

List listening ports

lsof -iTCP -sTCP:LISTEN -n -P

Show all TCP ports being listened on

Spotlight search

mdfind "keyword"

Search files using Spotlight index

Rebuild Spotlight index

sudo mdutil -E /

Re-index Spotlight (useful when search is slow)

Eject disk

diskutil eject /dev/disk2

Safely eject an external drive

Xcode CLI tools

xcode-select --install

Install Xcode command line developer tools

Reload shell config

source ~/.zshrc

Apply zsh config changes without restarting

🛠 Useful Commands

Find files by name

find . -name "*.log"

Search for files matching a pattern

Search text in files

grep -r "TODO" ./src

Recursively search for text in folder

Disk usage

du -sh *

Show size of each item in current dir

Free disk space

df -h

Show available disk space

Watch file changes

watch -n 2 ls -la

Re-run command every 2 seconds

Check port in use

lsof -i :3000

Show which process uses port 3000

Kill process on port

kill -9 $(lsof -t -i :3000)

Force kill process using port 3000

Tar compress

tar -czf archive.tar.gz ./folder

Compress folder to .tar.gz

Tar extract

tar -xzf archive.tar.gz

Extract .tar.gz archive

SSH into server

ssh user@192.168.1.10

Connect to remote server via SSH

SCP file to server

scp file.txt user@server:/path/

Copy file to remote server

Curl GET request

curl -s https://api.example.com/data | jq

Fetch URL and pretty-print JSON

Curl POST request

curl -X POST -H "Content-Type: application/json" -d '{"key":"val"}' https://api.example.com

Send JSON POST request

Make file executable

chmod +x script.sh

Add execute permission to file

Show environment variable

echo $PATH

Print the value of a variable

Count lines in file

wc -l file.txt

Count number of lines

Tail log file

tail -f /var/log/app.log

Follow new lines in a log file

Process list

ps aux | grep node

Find running processes by name