Git • Docker • Compose • ADB • npm/yarn • kubectl • Networking • Linux • macOS • Useful
git init
Create a new local repository
git clone https://github.com/user/repo.git
Download a remote repository
git status
Show changed/staged files
git add .
Stage all changes for commit
git commit -m "feat: add login"
Save staged changes with a message
git push origin main
Upload commits to remote
git pull origin main
Fetch + merge remote changes
git checkout -b feature/login
Create and switch to new branch
git checkout main
Switch to an existing branch
git merge feature/login
Merge a branch into current one
git log --oneline --graph
Show compact commit history
git stash
Temporarily save uncommitted work
git stash pop
Restore last stashed changes
git reset --soft HEAD~1
Undo commit but keep changes staged
git checkout -- file.txt
Restore file to last commit state
git branch -d feature/login
Remove a local branch
git remote -v
List remote URLs
git diff
Show unstaged file differences
docker build -t myapp:latest .
Build image from Dockerfile in current dir
docker run -d -p 8080:80 --name web myapp
Run detached, map port 8080 to 80
docker ps
Show active containers
docker ps -a
Include stopped containers
docker stop web
Gracefully stop a running container
docker rm web
Delete a stopped container
docker images
Show all local images
docker rmi myapp:latest
Delete a local image
docker logs -f web
Follow container logs in real-time
docker exec -it web /bin/sh
Open shell inside running container
docker pull nginx:alpine
Download image from Docker Hub
docker inspect web
Show detailed container info (IP, mounts…)
docker system prune -a
Remove all unused images, containers, networks
docker cp file.txt web:/app/
Copy local file into container
docker volume ls
Show all Docker volumes
docker network ls
Show all Docker networks
docker compose up -d
Start all services in background
docker compose down
Stop and remove containers + networks
docker compose down -v
Also remove named volumes
docker compose up -d --build
Force rebuild images before starting
docker compose logs -f api
Follow logs for a specific service
docker compose ps
Show running compose services
docker compose exec api sh
Open shell in a running service
docker compose restart api
Restart one specific service
docker compose up -d --scale api=3
Run 3 instances of the api service
docker compose pull
Download latest images for all services
adb devices
Show all connected Android devices/emulators
adb connect 192.168.1.100:5555
Connect to device wirelessly (after enabling TCP/IP)
adb tcpip 5555
Switch device to TCP/IP mode on port 5555
adb install app.apk
Install an APK on the connected device
adb install -r app.apk
Reinstall keeping data
adb uninstall com.example.app
Remove app by package name
adb push local.txt /sdcard/
Copy file from PC to device
adb pull /sdcard/file.txt ./
Copy file from device to PC
adb shell
Open interactive shell on the device
adb shell pm list packages
List all installed packages
adb shell pm list packages | grep chrome
Find packages matching a keyword
adb logcat
Stream device logs in real-time
adb logcat -s MyApp:D
Show only logs with tag MyApp at debug level+
adb logcat -c
Clear the log buffer
adb shell screencap /sdcard/screen.png
Capture screenshot and save to device
adb shell screenrecord /sdcard/video.mp4
Record device screen (Ctrl+C to stop)
adb reboot
Restart the connected device
adb reboot bootloader
Reboot into fastboot/bootloader mode
adb reboot recovery
Reboot into recovery mode
adb shell am start -n com.example.app/.MainActivity
Launch a specific activity
adb shell am force-stop com.example.app
Force kill an application
adb shell pm clear com.example.app
Wipe all data for an app (like fresh install)
adb shell ip addr show wlan0
Show Wi-Fi IP address of the device
adb shell getprop ro.product.model
Show the device model name
adb shell getprop ro.build.version.release
Show the Android OS version
adb shell dumpsys battery
Show battery level, status, temperature
adb shell input keyevent KEYCODE_HOME
Simulate pressing the Home button
adb shell input keyevent KEYCODE_BACK
Simulate pressing the Back button
adb shell input text "hello"
Type text on the focused input field
adb shell input tap 500 1200
Simulate a tap at x=500 y=1200
adb shell input swipe 500 1500 500 300 300
Swipe from (500,1500) to (500,300) in 300ms
adb forward tcp:8080 tcp:8080
Forward PC port to device port
adb reverse tcp:3000 tcp:3000
Forward device port to PC port (e.g. for dev server)
adb shell pm path com.example.app
Show the on-device path of an installed APK
adb shell uiautomator dump /sdcard/ui.xml
Dump current UI layout to XML for inspection
adb shell am start -a android.intent.action.VIEW -d "https://example.com"
Open a URL in the default browser
adb shell svc wifi enable
Toggle Wi-Fi (use disable to turn off)
adb -s SERIAL_NUMBER shell
Run command on a specific device when multiple are connected
adb sideload update.zip
Flash an OTA update from recovery mode
adb kill-server
Stop the ADB daemon (useful for fixing connection issues)
adb start-server
Start the ADB daemon
npm init -y
Create package.json with defaults
npm install
Install all deps from package.json
npm install express
Install and save a dependency
npm install -D jest
Install as devDependency
npm uninstall lodash
Remove a dependency
npm run dev
Execute a script from package.json
npm outdated
Show packages with newer versions
npm update
Update packages to latest allowed by semver
npm install -g nodemon
Install package globally
npm list -g --depth=0
Show globally installed packages
npm audit
Scan dependencies for known vulnerabilities
npm audit fix
Auto-fix vulnerable dependencies
npm cache clean --force
Clear the npm cache
npx create-react-app my-app
Run a package without installing it globally
yarn add axios
Install dependency with Yarn
yarn add -D typescript
Add devDependency with Yarn
kubectl get pods
List all pods in current namespace
kubectl get all
List pods, services, deployments, etc.
kubectl get pods -A
List pods across every namespace
kubectl describe pod my-pod
Show detailed info, events, status
kubectl logs -f my-pod
Stream logs from a pod
kubectl exec -it my-pod -- /bin/sh
Open shell inside a running pod
kubectl apply -f deployment.yaml
Create or update resources from YAML
kubectl delete -f deployment.yaml
Remove resources defined in YAML
kubectl scale deployment api --replicas=3
Scale to 3 replicas
kubectl rollout restart deployment api
Restart all pods in a deployment
kubectl rollout status deployment api
Watch deployment rollout progress
kubectl port-forward svc/api 8080:80
Forward local port 8080 to service port 80
kubectl get svc
List all services
kubectl get ns
List all namespaces
kubectl config set-context --current --namespace=dev
Change default namespace
kubectl config get-contexts
List available cluster contexts
kubectl config use-context prod-cluster
Switch to a different cluster
kubectl get events --sort-by=.metadata.creationTimestamp
Show cluster events sorted by time
kubectl top pods
Show CPU/memory usage per pod
kubectl cp file.txt my-pod:/tmp/
Copy local file into a pod
ping -c 4 google.com
Check if host is reachable
nslookup example.com
Resolve domain to IP address
dig example.com A +short
Query specific DNS record type
traceroute google.com
Show network path to a host
netstat -tlnp
Show all listening TCP ports
ss -tlnp
Modern alternative to netstat
nc -zv host.com 443
Test if a specific port is open
curl -I https://example.com
Show only HTTP response headers
curl -o /dev/null -s -w "Total: %{time_total}s\n" https://example.com
Measure request time
wget -O file.zip https://example.com/file.zip
Download file from URL
ip addr show
List all network interfaces and IPs
curl -s ifconfig.me
Show your public IP address
openssl s_client -connect example.com:443 -servername example.com
Inspect SSL/TLS cert details
ssh -L 8080:localhost:80 user@server
Forward local port 8080 to remote port 80
ssh-keygen -t ed25519 -C "me@email.com"
Generate a modern SSH key pair
ssh-copy-id user@server
Install public key for passwordless login
sudo apt update && sudo apt upgrade -y
Refresh repos and upgrade all packages
sudo dnf upgrade --refresh
Update all packages on dnf-based distros
sudo apt install htop
Install a package via apt
apt search nginx
Find available packages by keyword
sudo apt remove --purge nginx
Uninstall package and its config files
systemctl status nginx
Check if a service is running
sudo systemctl restart nginx
Restart a systemd service
sudo systemctl enable nginx
Auto-start service at boot
journalctl -u nginx -f
Follow logs for a specific service
df -h
Show mounted filesystems and free space
free -h
Show RAM and swap usage
htop
Interactive process viewer (install first)
w
Show logged-in users and their activity
chmod 755 script.sh
Set rwxr-xr-x permissions
sudo chown -R user:group /var/www
Recursively change file ownership
sudo useradd -m -s /bin/bash devuser
Create user with home dir and bash shell
su - devuser
Switch to another user with their environment
crontab -e
Edit your cron schedule
crontab -l
Show your scheduled cron tasks
ln -s /path/to/target /path/to/link
Create a symbolic link
sudo ufw allow 22/tcp
Open a TCP port in UFW firewall
sudo ufw status verbose
Show active firewall rules
uptime
Show how long the system has been running
uname -r
Show current Linux kernel version
cat /etc/os-release
Show Linux distribution details
sudo mount /dev/sdb1 /mnt/usb
Mount a device to a directory
sudo umount /mnt/usb
Safely unmount a device
find / -type f -size +100M 2>/dev/null
Find files larger than 100 MB
pkill -f "node server"
Kill all processes matching a pattern
nohup ./script.sh &
Run command in background surviving logout
export MY_VAR="value"
Set an environment variable for current session
alias ll="ls -la"
Create a command shortcut (add to ~/.bashrc to persist)
source ~/.bashrc
Apply changes to shell config without restarting
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Install the Homebrew package manager
brew install wget
Install a CLI tool via Homebrew
brew install --cask firefox
Install a GUI application
brew update && brew upgrade
Update Homebrew and upgrade all packages
brew cleanup --prune=all
Remove old versions and cache
brew list
Show all installed formulae and casks
brew search node
Find available packages by name
brew uninstall wget
Remove an installed package
brew services list
Show running Homebrew-managed services
brew services start postgresql
Start a service and auto-launch at login
open .
Open current directory in Finder
open image.png
Open file with its default application
open https://github.com
Open a URL in the default browser
echo "hello" | pbcopy
Copy text to macOS clipboard
pbpaste
Output clipboard contents to terminal
defaults write com.apple.finder AppleShowAllFiles -bool true && killall Finder
Toggle hidden file visibility in Finder
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
Clear the DNS resolver cache
screencapture -c
Take screenshot and copy to clipboard
screencapture ~/Desktop/screen.png
Save screenshot to a file
say "build complete"
Text-to-speech from terminal
caffeinate -t 3600
Keep Mac awake for 1 hour
system_profiler SPHardwareDataType
Show hardware overview (model, CPU, RAM)
sw_vers
Show macOS product name and version
du -sh ~/Library/Caches/*
Check cache folder sizes
sudo purge
Force macOS to free up inactive RAM
lsof -iTCP -sTCP:LISTEN -n -P
Show all TCP ports being listened on
mdfind "keyword"
Search files using Spotlight index
sudo mdutil -E /
Re-index Spotlight (useful when search is slow)
diskutil eject /dev/disk2
Safely eject an external drive
xcode-select --install
Install Xcode command line developer tools
source ~/.zshrc
Apply zsh config changes without restarting
find . -name "*.log"
Search for files matching a pattern
grep -r "TODO" ./src
Recursively search for text in folder
du -sh *
Show size of each item in current dir
df -h
Show available disk space
watch -n 2 ls -la
Re-run command every 2 seconds
lsof -i :3000
Show which process uses port 3000
kill -9 $(lsof -t -i :3000)
Force kill process using port 3000
tar -czf archive.tar.gz ./folder
Compress folder to .tar.gz
tar -xzf archive.tar.gz
Extract .tar.gz archive
ssh user@192.168.1.10
Connect to remote server via SSH
scp file.txt user@server:/path/
Copy file to remote server
curl -s https://api.example.com/data | jq
Fetch URL and pretty-print JSON
curl -X POST -H "Content-Type: application/json" -d '{"key":"val"}' https://api.example.com
Send JSON POST request
chmod +x script.sh
Add execute permission to file
echo $PATH
Print the value of a variable
wc -l file.txt
Count number of lines
tail -f /var/log/app.log
Follow new lines in a log file
ps aux | grep node
Find running processes by name