Top 10 DevOps Cheat Sheet
Short answer: this sheet collects the commands DevOps engineers use every day across Docker, Kubernetes, Terraform, Git, Linux and CI/CD. Try them on a test environment first, and double-check anything that deletes or applies changes.
1. Docker
| Command | Purpose |
|---|---|
docker build -t app:1.0 . | Build an image from a Dockerfile |
docker run -d -p 8080:80 --name web app:1.0 | Run a container in the background, mapping a port |
docker ps / docker ps -a | List running / all containers |
docker logs -f web | Follow container logs |
docker exec -it web sh | Open a shell inside a container |
docker stop web && docker rm web | Stop and remove a container |
docker compose up -d | Start all services from a compose file |
docker system prune | Remove unused data (read the prompt before confirming) |
Background: Docker containers complete guide.
2. Kubernetes (kubectl)
| Command | Purpose |
|---|---|
kubectl get pods -A | List pods in all namespaces |
kubectl describe pod NAME | Show details and recent events |
kubectl logs -f NAME | Stream pod logs |
kubectl apply -f deploy.yaml | Create or update resources from a file |
kubectl rollout status deploy/NAME | Watch a rollout |
kubectl rollout undo deploy/NAME | Roll back to the previous version |
kubectl scale deploy/NAME --replicas=3 | Change the number of pods |
kubectl config get-contexts | See which cluster you are connected to |
Always confirm your current context before applying changes. See Kubernetes basics.
3. Terraform
terraform init # download providers
terraform fmt # format files
terraform validate # check syntax
terraform plan # preview changes
terraform apply # create or change infrastructure
terraform destroy # remove managed resources (use with great care)
Learn more in Infrastructure as Code with Terraform.
4. Git
git status
git switch -c feature/login # new branch
git add -p # stage selectively
git commit -m "Add login form"
git pull --rebase origin main
git push -u origin feature/login
git log --oneline --graph --decorate
More in the Git commands cheat sheet.
5. Linux essentials
| Command | Purpose |
|---|---|
ls -lah | List files with sizes and hidden files |
grep -rn "error" /var/log/app | Search text recursively with line numbers |
tail -f /var/log/syslog | Follow a log file |
top / htop | Watch processes and CPU/memory use |
df -h / du -sh * | Check disk space |
ss -tulpn | See listening ports |
chmod 640 file / chown user:group file | Change permissions and ownership |
systemctl status nginx | Check a service |
journalctl -u nginx -f | Follow a service's logs |
6. Networking and debugging
curl -I https://example.com # response headers
curl -v http://localhost:3000/health
ping -c 4 example.com
dig example.com +short # DNS lookup
nc -zv host 443 # test a port
7. SSH
ssh-keygen -t ed25519 -C "you@example.com"
ssh user@host
scp file.txt user@host:/tmp/
ssh -L 5432:localhost:5432 user@host # port forwarding tunnel
8. CI/CD concepts and a minimal pipeline
name: ci
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: 20 }
- run: npm ci
- run: npm test
Read CI/CD pipelines explained and GitHub Actions CI/CD.
9. Cloud CLI basics (AWS example)
aws sts get-caller-identity # who am I?
aws s3 ls
aws s3 sync ./build s3://my-bucket
aws ec2 describe-instances --query "Reservations[].Instances[].InstanceId"
10. Safety habits
- Check the active cluster, account and branch before running commands that change things.
- Use
plan,--dry-runordiffoptions before applying. - Never paste secrets into terminals or logs; use a secrets manager.
- Keep infrastructure and pipelines in version control.
Next steps
Understand the practice itself in what DevOps is.
