Skip to main content

Command Palette

Search for a command to run...

🚀 The DevOps Daily Driver: Your Essential Command Cheat Sheet

Published
7 min read
R

Cloud & DevOps Engineer with hands-on expertise in cloud architecture, containerization, and Infrastructure as Code. I design automated pipelines, optimize infrastructure, and help teams adopt cloud-native solutions with confidence.

As a professional DevOps engineer, you live at the command line. Whether you're provisioning infrastructure, managing containers, or automating pipelines, speed and precision are paramount. Forget digging through documentation—this cheat sheet compiles the most critical, daily-use commands for the tools that form the backbone of modern DevOps.

Keep this handy. Your keyboard awaits!


🐧 Linux (The Foundation)

The operating system is the bedrock of our work. These commands are essential for file manipulation, system monitoring, and troubleshooting.

CategoryCommandDescription
File/Textls -alhList files with human-readable sizes and all details.
grep "pattern" file.txtSearch for a pattern within a file.
cat file.txtDisplay the entire content of a file.
tail -f logs/app.logWatch the end of a log file in real-time.
vi/nano file.txtOpen a file for editing in the terminal.
System Infotop or htopDisplay a dynamic, real-time view of running processes and resource usage.
df -hDisplay disk space usage in human-readable format.
du -sh /path/Summarize disk usage of a specific directory.
`ps auxgrep <process_name>`
Networkingcurl -I <url>Get the HTTP headers for a URL (useful for quick checks).
ssh user@hostSecurely connect to a remote server.
netstat -tuln or ss -tulnDisplay active network connections and listening ports.

🐳 Docker (Container Management)

Docker is key to consistent environments. These commands manage images, containers, and volumes.

CategoryCommandDescription
Containersdocker run -d -p 8080:80 --name my-app my-image:latestCreate and start a container in detached mode, mapping ports.
docker psList running containers. Use docker ps -a for all (including stopped).
docker logs -f my-appFollow the logs of a container.
docker exec -it my-app /bin/bashExecute an interactive shell inside a running container.
docker stop my-appStop a running container.
docker rm my-appRemove a stopped container.
Imagesdocker build -t my-image:latest .Build an image from a Dockerfile in the current directory.
docker imagesList local images.
docker pull my-image:tagDownload an image from a registry.
docker push my-repo/my-image:tagUpload an image to a registry.
docker rmi <image_id>Remove a local image.
Cleanupdocker system pruneClean up unused images, containers, networks, and build cache.

🏗️ Terraform (Infrastructure as Code)

Provisioning infrastructure efficiently requires a deep understanding of the Terraform workflow.

CommandDescription
terraform initInitializes a Terraform working directory (downloads providers/modules).
terraform validateChecks configuration for syntax errors and consistency.
terraform planGenerates an execution plan showing what changes will be made (dry run).
terraform applyApplies the planned changes to create or update infrastructure.
terraform apply -auto-approveSkip the manual approval prompt (use cautiously in CI/CD).
terraform destroyTears down all resources managed by the current configuration.
terraform fmtRewrites configuration files to a canonical format (standard formatting).
terraform output <name>Display the value of a specific output variable.
terraform state listLists all resources tracked in the current state file.

☸️ Kubernetes (Orchestration with kubectl)

Kubernetes is the heart of many modern deployments. The kubectl command is your primary interface.

| Category | Command | Description | | :--- | :--- | | Viewing Resources | kubectl get pods | List all Pods in the current namespace (can use po). | | | kubectl get svc,deploy,rs | List services, deployments, and replica sets. | | | kubectl get all -n <namespace> | List common resources across a specific namespace. | | | kubectl describe pod <pod-name> | Show detailed status (events, container info, status). | | Logs & Access | kubectl logs -f <pod-name> | Follow the logs for a specific Pod. | | | kubectl exec -it <pod-name> -- /bin/bash | Get an interactive shell inside a running Pod. | | Management | kubectl apply -f deployment.yaml | Create/Update resources from a file (declarative). | | | kubectl delete -f deployment.yaml | Delete resources defined in a file. | | | kubectl rollout status deploy/<deployment-name> | Watch the status of a deployment rollout. | | | kubectl scale deploy <name> --replicas=3 | Scale a deployment immediately. | | Configuration | kubectl config use-context <context-name> | Switch to a different cluster context. | | | kubectl get secret <secret-name> -o jsonpath='{.data.key}' \| base64 -d | Decode and view a Secret key's value. |

⛑️ Helm (Package Manager for Kubernetes)

Helm charts simplify the deployment and management of applications on Kubernetes.

CommandDescription
helm repo add <name> <url>Add a remote chart repository.
helm repo updateFetch the latest charts from all repositories.
helm install <release-name> <chart-name>Deploy a new application instance (a "release").
helm install <release> <chart> -f values.yamlInstall, overriding default chart values with a custom file.
helm upgrade <release-name> <chart-name>Upgrade an existing release to a new chart version or updated values.
helm rollback <release-name> <revision-number>Roll back a release to a previous, stable revision.
helm list or helm lsList all releases (deployed applications) in the current namespace.
helm uninstall <release-name>Remove a release from the cluster, including all its resources.
helm template <chart-name> --debugLocally render the Kubernetes manifests (useful for debugging).

💻 Bash Scripting (Automation Glue)

Bash is the essential language for writing simple, effective automation and glue scripts for CI/CD.

Concept/CommandExample/SyntaxDescription
Shebang#!/bin/bashMust be the first line to define the interpreter.
VariableNAME="prod" echo "Deploying to $NAME"Define and use a variable.
Executionchmod +x script.sh ./script.shGrant execute permission and run the script.
Conditionif [ $? -eq 0 ]; then echo "Success"; fiIf statement to check exit code of the previous command ($?).
Loopfor i in 1 2 3; do echo $i; doneA simple for loop.
Command OutputDEPLOY_ID=$(uuidgen)Store command output in a variable using $().
Error Handlingset -eExit immediately if any command fails (non-zero exit code).
Functionsdeploy() { ... } deployDefine and call a simple function.

🐍 Python (Advanced Automation)

Python is the go-to for complex automation tasks, especially when interacting with cloud APIs and data.

Module/FunctionUse Case for DevOpsExample Command/Syntax
requestsInteract with REST APIs (e.g., Jenkins, GitHub, Cloud APIs).response = requests.get('<url>')
osInteract with the Operating System (environment variables, files).os.environ.get('ENV_VAR')
subprocessRun external shell commands from within a Python script.subprocess.run(['kubectl', 'get', 'pods'])
jsonHandle JSON data structures, common in API responses.data = json.loads(response.text)
yamlRead/write YAML configuration files (e.g., Kubernetes manifests).yaml.safe_load(file)
boto3 (AWS SDK)Automate AWS cloud resources.ec2 = boto3.client('ec2')
argparseHandle Command Line Arguments in a structured way.parser.add_argument('-i', '--image')
loggingCreate structured and categorized logs for scripts.logging.info('Deployment started')

💡 Pro Tip for Every Tool

Remember the two most important flags that work for almost every command-line tool:

  • --help: Get a quick overview of the command's usage and available flags.

    • Example: docker run --help or kubectl get --help
  • -v or --version: Quickly check the installed version (crucial for compatibility checks).

    • Example: terraform version or helm version