Skip to content

DevSecOps Cheatsheets

A quick reference for common DevOps, DevSecOps, Security, and Cloud tasks. Use these tables as a handy guide for daily operations and automation.


🛠️ DevOps & DevSecOps CLI Basics

TaskBash Command ExamplePowerShell Example
List filesls -alGet-ChildItem
Find text in filesgrep 'pattern' -r .Select-String -Path * -Pattern
Show disk usagedf -hGet-PSDrive
Show running procsps auxGet-Process
Check open portsnetstat -tulnGet-NetTCPConnection
Show env varsprintenvGet-ChildItem Env:
Edit filenano file.txtnotepad file.txt
Check networkping <host>Test-Connection <host>
Check IPcurl ifconfig.meInvoke-WebRequest ifconfig.me
Check HTTP statuscurl -I <url>Invoke-WebRequest <url> -Method Head
Check DNSdig <domain>Resolve-DnsName <domain>
Check SSL certopenssl s_client -connect <host>:443Invoke-WebRequest <url> -UseBasicParsing
Check CPU usagetopGet-Process : Sort-Object CPU -Descending
Check memory usagefree -hGet-Process : Measure-Object -Property WS -Sum
Check uptimeuptimeGet-Uptime
Remote Syncrsync -avz src/ dest/Copy-Item -Path src -Destination dest -Recurse
Remote execssh user@host 'command'Invoke-Command -ComputerName host -ScriptBlock { command }
Remote file transferscp file user@host:/pathCopy-Item -Path file -Destination \\host\path
Check logstail -f /var/log/syslogGet-Content -Path /var/log/syslog -Tail 10 -Wait
Check if command existscommand -v <cmd>Get-Command <cmd>
check for syntax errorbash -n ./deploy-kind.shtry { <cmd> } catch { Write-Host "Error" }

☁️ Cloud CLI Quick Reference

CloudLogin CommandList ResourcesDocs/Help Command
Azureaz loginaz resource listaz --help
AWSaws configureaws s3 lsaws help
GCPgcloud initgcloud compute instances listgcloud help

🔐 Security & Secrets

TaskCommand/Tool Example
Generate SSH keyssh-keygen -t ed25519 -C "email@example.com"
Check open ports (nmap)nmap -sS <host>
Hash a file (SHA256)sha256sum file.txt
Scan for secrets in codetrufflehog git / gitleaks detect
Check file permissionsls -l
Encrypt a file (openssl)openssl enc -aes-256-cbc -in file -out file.enc
Decrypt a file (openssl)openssl enc -d -aes-256-cbc -in file.enc -out file
Generate random passwordopenssl rand -base64 32
Check for weak passwordshashcat -m 0 -a 0 <hashfile> <wordlist>
Scan for vulnerabilitiestrivy image <image>
Check for CVEsaws inspector scan <resource>
Scan for malwareclamav -r <directory>
Check for misconfigurationscheckov -f <file>
Scan for open portsnmap -sS <host>

🏗️ Infrastructure as Code (IaC)

Terraform

TaskCommand Example
Init projectterraform init
Validate configterraform validate
Plan changesterraform plan
Apply changesterraform apply
Destroy resourcesterraform destroy
List resourcesterraform state list
Show resourceterraform show
Output variablesterraform output
Import resourceterraform import <resource>

Ansible

TaskCommand Example
Run playbookansible-playbook playbook.yml
List hostsansible all --list-hosts -i inventory
Ping all hostsansible all -m ping
Check factsansible all -m setup
Run ad-hoc cmdansible all -a "command"

Bicep

TaskCommand Example
Build Bicepaz bicep build --file main.bicep
Validate Bicepaz bicep validate --file main.bicep
List Bicepaz bicep list
Lint Bicepaz bicep linter --file main.bicep
Deploy Bicepaz deployment group create --resource-group <rg> --template-file main.bicep

AWS CloudFormation

TaskCommand Example
Validate templateaws cloudformation validate-template --template-body file://template.yaml
Deploy stackaws cloudformation deploy --template-file template.yaml --stack-name mystack

🧑‍💻 Git & GitHub

TaskCommand Example
Clone repogit clone <url>
Create branchgit checkout -b feature/branch
Commit changesgit commit -am "message"
Delete branchgit branch -d feature/branch
Delete remote branchgit push origin --delete feature/branch or git push origin :feature/branch
Push branchgit push origin feature/branch
Rebase maingit fetch origin && git rebase origin/main
GitHub CLI logingh auth login
Create PR (GitHub CLI)gh pr create --fill
List PRs (GitHub CLI)gh pr list
Merge PR (GitHub CLI)gh pr merge <pr-number>
Review PR (GitHub CLI)gh pr review <pr-number> --approve
List issues (GitHub CLI)gh issue list
Create issue (GitHub CLI)gh issue create --title "Issue title" --body "Issue body"
Close issue (GitHub CLI)gh issue close <issue-number>
List commits (GitHub CLI)gh repo view --commits
View commit (GitHub CLI)gh pr view <pr-number> --commits
View commit details (GitHub CLI)gh pr view <pr-number> --commits --json

🐚 Bash Scripting

TaskExample
For loopfor f in *.txt; do echo $f; done
If statementif [ -f file ]; then echo exists; fi
Functionmyfunc() { echo Hello; }
Read inputread -p "Name: " name
Export variableexport VAR=value

⚡ PowerShell Scripting

TaskExample
ForEach loopforeach ($f in Get-ChildItem *.txt) { $f }
If statementif (Test-Path file) { Write-Host exists }
Functionfunction MyFunc { Write-Host Hello }
Read input$name = Read-Host "Name"
Set variable$env:VAR = "value"

📦 Container & K8s

TaskDocker ExampleKubernetes Example
List containersdocker pskubectl get pods
Build imagedocker build -t myimg .-
Run containerdocker run -it myimg-
List imagesdocker images-
List clusters-kubectl config get-clusters
Get cluster info-kubectl cluster-info
Apply manifest-kubectl apply -f file.yaml
Port forward-kubectl port-forward svc/myapp 8080:80
Logsdocker logs <container>kubectl logs <pod>

Extra Tips

TaskCommand Example
Check disk spacedf -h
Check memory usagefree -h
Check CPU usagetop or htop
Check network connectivityping <host>
Check firewall rulesiptables -L or ufw status
Check system uptimeuptime
Check system logsjournalctl -xe or tail -f /var/log/syslog
Check system servicessystemctl list-units --type=service
Check system processesps aux or top
Check system userswho or w
Check system groupsgetent group
Check system environmentenv or printenv
Check system aliasesalias
Check system crontabcrontab -l
Check system packagesdpkg -l (Debian) or rpm -qa (Red Hat)
Check system updatesapt update && apt upgrade (Debian) or yum update (Red Hat)
Check system hardwarelshw or lscpu
Check system network configifconfig or ip addr
Check system DNS configcat /etc/resolv.conf
Check system hostnamehostname or uname -n
Check system timedate or timedatectl

📝 Notes

  • Use --help with any command to get more details.
  • Always check the documentation for the latest commands and options.
  • Customize commands with flags for specific needs (e.g., --verbose, --dry-run).

Copy SSH Key to Clipboard

Mac

sh
pbcopy < ~/.ssh/id_rsa.pub

Linux (Ubuntu)

sh
cat ~/.ssh/id_rsa.pub

Windows (Git Bash)

powershell
clip < ~/.ssh/id_rsa.pub

📚 More Resources


Keep this cheatsheet handy for fast, secure, and efficient DevSecOps workflows!