Ultimate Guide

DevOps Engineer Playbook: Practical Commands for Everyday Use

Updated March 2024 | Bookmark this page

Welcome to the ultimate "Cheat Sheet" for DevOps Engineers. Whether you are a beginner just starting or a professional who needs a quick reminder, this guide covers the most essential commands for Linux, Git, Docker, Kubernetes, and Terraform.

We have selected the Top 25+ commands for each tool that you will actually use in a real job. No fluff, just practical commands.

1. Linux Essentials

Linux is the operating system of the cloud. You cannot survive in DevOps without mastering the terminal.

Command Use Case (Simple English)
ls -laList all files, including hidden ones, with details.
pwdShow me "Print Working Directory" (Where am I?).
cd ..Go back one folder level.
mkdir folder_nameCreate a new folder (directory).
touch file.txtCreate an empty file.
cp file1 file2Copy file1 to file2.
mv file1 folder/Move a file into a folder.
rm -rf folder/Force delete a folder and everything inside it (Careful!).
cat file.txtShow the content of a file on the screen.
tail -f log.txtWatch the end of a file in real-time (Great for logs).
grep "error" file.txtSearch for the word "error" inside a file.
chmod 777 file.shGive full permissions (Read, Write, Execute) to everyone.
chown user:group fileChange who owns the file.
ps auxShow all running processes (programs).
topShow CPU and Memory usage in real-time (Task Manager).
kill 1234Stop a process using its ID (PID).
df -hCheck disk space (Is your hard drive full?).
free -mCheck how much RAM memory is free.
tar -czvf backup.tar.gz folder/Compress a folder into a zip/tar file.
curl http://google.comTest if a website is reachable from the terminal.
wget link.zipDownload a file from the internet.
ping 8.8.8.8Check if you are connected to the internet.
historyShow the list of commands you typed previously.
sudo suSwitch to the Administrator (Root) user.
systemctl restart nginxRestart a service (like a web server).

2. Git Version Control

Git helps teams collaborate on code. It is the "Save Game" button for developers.

Command Use Case (Simple English)
git initStart a new Git repository in this folder.
git clone [url]Download a project from GitHub to your computer.
git statusCheck which files have been changed.
git add .Select ALL changed files to be saved.
git commit -m "msg"Save the selected files with a message.
git push origin mainUpload your saved changes to GitHub.
git pullDownload the latest changes from GitHub.
git branchList all branches (versions) of your code.
git checkout -b new-featureCreate and switch to a new branch.
git checkout mainSwitch back to the main branch.
git merge featureCombine the 'feature' branch into the current branch.
git diffShow exactly what lines of code changed.
git logShow history of all commits (saves).
git reset --hardDelete all unsaved changes (Dangerous!).
git stashTemporarily hide changes to work on something else.
git stash popBring back the hidden changes.
git remote -vShow the URL of the GitHub repository.
git fetchCheck for updates without downloading them yet.
git revert [commit_id]Undo a specific save without deleting history.
git tag v1.0Label a specific point in history as "v1.0".
git config --global user.name "Me"Set your name for Git.
git branch -d featureDelete a branch you don't need anymore.
git show [commit_id]See details of a specific save.
git blame file.txtSee who wrote each line of code (Good for debugging).
git clean -fdRemove untracked files from the folder.

3. Docker Commands

Docker packages applications into containers so they run anywhere.

Command Use Case (Simple English)
docker versionCheck if Docker is installed and running.
docker build -t app:v1 .Build an image from a Dockerfile.
docker imagesList all images stored on your computer.
docker run -d -p 80:80 nginxStart a container (Nginx) in background on port 80.
docker psShow only running containers.
docker ps -aShow ALL containers (running and stopped).
docker stop [id]Gracefully stop a running container.
docker kill [id]Forcefully stop a container instantly.
docker rm [id]Delete a stopped container.
docker rmi [image]Delete an image to save space.
docker logs [id]See what the container is printing (Debugging).
docker exec -it [id] bashLog inside a running container to type commands.
docker loginLog in to Docker Hub.
docker push user/app:v1Upload your image to Docker Hub.
docker pull nginxDownload an image from the internet.
docker network lsList all networks.
docker volume lsList all storage volumes.
docker system pruneDelete all unused data (Clean up junk).
docker inspect [id]View detailed technical info about a container.
docker statsLive view of CPU/RAM usage of containers.
docker-compose up -dStart multiple containers defined in a compose file.
docker-compose downStop and delete all containers from compose.
docker cp file [id]:/pathCopy a file from your PC into a container.
docker history [image]See how an image was built layer by layer.
docker tag old:v1 new:v2Rename or re-tag an image.

4. Kubernetes (kubectl)

Kubernetes manages Docker containers at a massive scale.

Command Use Case (Simple English)
kubectl get nodesCheck the health of the servers (cluster nodes).
kubectl get podsList all running pods (containers).
kubectl get svcList Services (Network endpoints).
kubectl get deployList Deployments (App managers).
kubectl describe pod [name]Detailed info about why a pod crashed.
kubectl logs [pod_name]Read the logs of a specific pod.
kubectl apply -f file.yamlCreate or update resources from a file.
kubectl delete -f file.yamlDelete everything defined in that file.
kubectl delete pod [name]Delete a specific pod (It usually restarts).
kubectl exec -it [pod] -- bashLog inside a pod to run commands.
kubectl scale deploy app --replicas=5Increase the number of app copies to 5.
kubectl get allShow pods, services, deployments all at once.
kubectl get pods -o wideShow pods with extra info like IP Address.
kubectl get namespacesList all virtual clusters (namespaces).
kubectl config current-contextCheck which cluster you are connected to.
kubectl port-forward pod 8080:80Access a pod on your local computer port 8080.
kubectl rollout status deploy/appCheck if an update finished successfully.
kubectl rollout undo deploy/appRollback to the previous version (Emergency).
kubectl top nodesCheck CPU/Memory usage of servers.
kubectl top podsCheck CPU/Memory usage of apps.
kubectl create ns [name]Create a new namespace.
kubectl edit svc [name]Edit the configuration live in a text editor.
kubectl cluster-infoShow IP addresses of master and services.
kubectl eventsShow recent cluster events (Warnings/Errors).
kubectl explain podDocumentation about what a "Pod" is.

5. Terraform (IaC)

Terraform allows you to build cloud infrastructure using code.

Command Use Case (Simple English)
terraform initDownload plugins and prepare the folder.
terraform planShow what will happen (Dry Run).
terraform applyActually create the infrastructure.
terraform apply --auto-approveCreate it without asking "Are you sure?".
terraform destroyDelete EVERYTHING.
terraform validateCheck if your code has syntax errors.
terraform fmtMake your code look pretty (Fix indentation).
terraform showShow the current state of infrastructure.
terraform outputShow values like IP addresses after creation.
terraform state listList all resources Terraform is managing.
terraform refreshCheck if the cloud changed outside of Terraform.
terraform graphGenerate a visual graph of your infrastructure.
terraform workspace listList different environments (dev, prod).
terraform workspace new devCreate a new environment named 'dev'.
terraform workspace select devSwitch to the 'dev' environment.
terraform taint [resource]Mark a resource as broken to force recreation.
terraform untaint [resource]Unmark the resource.
terraform import [id]Bring an existing cloud resource into Terraform.
terraform consoleOpen an interactive shell to test logic.
terraform versionCheck installed version.
terraform providersList plugins (AWS, Azure) being used.
terraform loginLogin to Terraform Cloud.
terraform getDownload modules.
terraform plan -out=tfplanSave the plan to a file.
terraform force-unlock [id]Unlock the state if it got stuck.