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 -la | List all files, including hidden ones, with details. |
| pwd | Show me "Print Working Directory" (Where am I?). |
| cd .. | Go back one folder level. |
| mkdir folder_name | Create a new folder (directory). |
| touch file.txt | Create an empty file. |
| cp file1 file2 | Copy 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.txt | Show the content of a file on the screen. |
| tail -f log.txt | Watch the end of a file in real-time (Great for logs). |
| grep "error" file.txt | Search for the word "error" inside a file. |
| chmod 777 file.sh | Give full permissions (Read, Write, Execute) to everyone. |
| chown user:group file | Change who owns the file. |
| ps aux | Show all running processes (programs). |
| top | Show CPU and Memory usage in real-time (Task Manager). |
| kill 1234 | Stop a process using its ID (PID). |
| df -h | Check disk space (Is your hard drive full?). |
| free -m | Check how much RAM memory is free. |
| tar -czvf backup.tar.gz folder/ | Compress a folder into a zip/tar file. |
| curl http://google.com | Test if a website is reachable from the terminal. |
| wget link.zip | Download a file from the internet. |
| ping 8.8.8.8 | Check if you are connected to the internet. |
| history | Show the list of commands you typed previously. |
| sudo su | Switch to the Administrator (Root) user. |
| systemctl restart nginx | Restart 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 init | Start a new Git repository in this folder. |
| git clone [url] | Download a project from GitHub to your computer. |
| git status | Check 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 main | Upload your saved changes to GitHub. |
| git pull | Download the latest changes from GitHub. |
| git branch | List all branches (versions) of your code. |
| git checkout -b new-feature | Create and switch to a new branch. |
| git checkout main | Switch back to the main branch. |
| git merge feature | Combine the 'feature' branch into the current branch. |
| git diff | Show exactly what lines of code changed. |
| git log | Show history of all commits (saves). |
| git reset --hard | Delete all unsaved changes (Dangerous!). |
| git stash | Temporarily hide changes to work on something else. |
| git stash pop | Bring back the hidden changes. |
| git remote -v | Show the URL of the GitHub repository. |
| git fetch | Check for updates without downloading them yet. |
| git revert [commit_id] | Undo a specific save without deleting history. |
| git tag v1.0 | Label a specific point in history as "v1.0". |
| git config --global user.name "Me" | Set your name for Git. |
| git branch -d feature | Delete a branch you don't need anymore. |
| git show [commit_id] | See details of a specific save. |
| git blame file.txt | See who wrote each line of code (Good for debugging). |
| git clean -fd | Remove untracked files from the folder. |
3. Docker Commands
Docker packages applications into containers so they run anywhere.
| Command | Use Case (Simple English) |
|---|---|
| docker version | Check if Docker is installed and running. |
| docker build -t app:v1 . | Build an image from a Dockerfile. |
| docker images | List all images stored on your computer. |
| docker run -d -p 80:80 nginx | Start a container (Nginx) in background on port 80. |
| docker ps | Show only running containers. |
| docker ps -a | Show 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] bash | Log inside a running container to type commands. |
| docker login | Log in to Docker Hub. |
| docker push user/app:v1 | Upload your image to Docker Hub. |
| docker pull nginx | Download an image from the internet. |
| docker network ls | List all networks. |
| docker volume ls | List all storage volumes. |
| docker system prune | Delete all unused data (Clean up junk). |
| docker inspect [id] | View detailed technical info about a container. |
| docker stats | Live view of CPU/RAM usage of containers. |
| docker-compose up -d | Start multiple containers defined in a compose file. |
| docker-compose down | Stop and delete all containers from compose. |
| docker cp file [id]:/path | Copy 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:v2 | Rename or re-tag an image. |
4. Kubernetes (kubectl)
Kubernetes manages Docker containers at a massive scale.
| Command | Use Case (Simple English) |
|---|---|
| kubectl get nodes | Check the health of the servers (cluster nodes). |
| kubectl get pods | List all running pods (containers). |
| kubectl get svc | List Services (Network endpoints). |
| kubectl get deploy | List 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.yaml | Create or update resources from a file. |
| kubectl delete -f file.yaml | Delete everything defined in that file. |
| kubectl delete pod [name] | Delete a specific pod (It usually restarts). |
| kubectl exec -it [pod] -- bash | Log inside a pod to run commands. |
| kubectl scale deploy app --replicas=5 | Increase the number of app copies to 5. |
| kubectl get all | Show pods, services, deployments all at once. |
| kubectl get pods -o wide | Show pods with extra info like IP Address. |
| kubectl get namespaces | List all virtual clusters (namespaces). |
| kubectl config current-context | Check which cluster you are connected to. |
| kubectl port-forward pod 8080:80 | Access a pod on your local computer port 8080. |
| kubectl rollout status deploy/app | Check if an update finished successfully. |
| kubectl rollout undo deploy/app | Rollback to the previous version (Emergency). |
| kubectl top nodes | Check CPU/Memory usage of servers. |
| kubectl top pods | Check 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-info | Show IP addresses of master and services. |
| kubectl events | Show recent cluster events (Warnings/Errors). |
| kubectl explain pod | Documentation about what a "Pod" is. |
5. Terraform (IaC)
Terraform allows you to build cloud infrastructure using code.
| Command | Use Case (Simple English) |
|---|---|
| terraform init | Download plugins and prepare the folder. |
| terraform plan | Show what will happen (Dry Run). |
| terraform apply | Actually create the infrastructure. |
| terraform apply --auto-approve | Create it without asking "Are you sure?". |
| terraform destroy | Delete EVERYTHING. |
| terraform validate | Check if your code has syntax errors. |
| terraform fmt | Make your code look pretty (Fix indentation). |
| terraform show | Show the current state of infrastructure. |
| terraform output | Show values like IP addresses after creation. |
| terraform state list | List all resources Terraform is managing. |
| terraform refresh | Check if the cloud changed outside of Terraform. |
| terraform graph | Generate a visual graph of your infrastructure. |
| terraform workspace list | List different environments (dev, prod). |
| terraform workspace new dev | Create a new environment named 'dev'. |
| terraform workspace select dev | Switch 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 console | Open an interactive shell to test logic. |
| terraform version | Check installed version. |
| terraform providers | List plugins (AWS, Azure) being used. |
| terraform login | Login to Terraform Cloud. |
| terraform get | Download modules. |
| terraform plan -out=tfplan | Save the plan to a file. |
| terraform force-unlock [id] | Unlock the state if it got stuck. |
