$ run as a normal user# run as root (or with sudo)
Skills in this chapter
- The 10 everyday command-line tools — full pages
Know the 10 tools and how they connect
Code goes into git, is packed by docker, is created in the cloud by terraform (with aws or az), is configured by ansible, runs on Kubernetes through kubectl and helm, and is checked with ssh and curl.
| # | Tool | Job | Full page |
|---|---|---|---|
| 1 | git | Version control: every change, branch and release | git |
| 2 | docker | Build and run container images | docker |
| 3 | kubectl | Control a Kubernetes cluster | kubectl |
| 4 | helm | Install and upgrade apps on Kubernetes | helm |
| 5 | terraform | Build cloud infrastructure from code | terraform |
| 6 | ansible | Configure servers over SSH | ansible |
| 7 | aws | Control Amazon Web Services | aws |
| 8 | az | Control Microsoft Azure | az |
| 9 | ssh | Secure login, tunnels and file copy | ssh |
| 10 | curl | Test web servers and APIs | curl |
Remember
You do not learn every option by heart. Learn the first sub-commands of each card, and know where the full page is.
git — every change in one history
Git saves snapshots of your project. Branches keep work apart; pull requests and pipelines start from Git.
| Sub-command | Use it to |
|---|---|
clone, init | Get or start a repository |
status, diff, add, commit | See and save changes |
switch -c, merge, rebase | Work with branches |
fetch, pull, push | Sync with GitHub, GitLab, Azure Repos |
log --oneline --graph, blame, reflog | Read and rescue the history |
tag, revert | Release and undo safely |
git switch -c feature/health-check
git add app.py && git commit -m "Add /health endpoint"
git push -u origin feature/health-checkAll sub-commands and options: the git page.
docker — build and run containers
Docker packs an app into an image and runs it as a container — the same on a laptop, a build server and in production.
| Sub-command | Use it to |
|---|---|
build -t, push, pull, images | Make and move images |
run -d -p, ps, stop, rm | Run and manage containers |
logs -f, exec -it, inspect, stats | Look inside and debug |
volume, network | Keep data, connect containers |
compose up -d, compose down | Run a stack from one YAML file |
buildx build --platform, system prune | Multi-CPU builds, clean up |
docker build -t ghcr.io/s0sta/shop:1.4.0 .
docker run -d --name shop -p 127.0.0.1:8080:8080 ghcr.io/s0sta/shop:1.4.0
docker logs -f shopAll sub-commands and options: the docker page.
kubectl — talk to Kubernetes
kubectl reads and changes every object in a cluster. Apply YAML from Git; use describe and logs when something fails.
| Sub-command | Use it to |
|---|---|
get, describe, explain | See objects and their events, learn fields |
apply -f, diff -f, delete | Deploy the wanted state |
rollout status / undo, scale, set image | Update and roll back |
logs, exec -it, port-forward, debug | Debug Pods |
config use-context, auth can-i | Choose the cluster, check RBAC |
cordon, drain, top | Node maintenance and load |
kubectl apply -f k8s/
kubectl rollout status deploy/shop
kubectl describe pod -l app=shop | tail -20All sub-commands and options: the kubectl page.
helm — packages for Kubernetes
Helm installs a chart (templates + values) as a release, and every upgrade can be rolled back.
| Sub-command | Use it to |
|---|---|
repo add, repo update, search repo | Find charts |
show values, template, lint | Check a chart before installing |
upgrade --install --atomic | Install or upgrade the same way every time |
list, status, history, get values | See releases |
rollback, uninstall | Go back or remove |
package, push oci:// | Ship your own charts |
helm upgrade --install shop ./charts/shop -n shop -f values/prod.yaml --atomic --wait
helm history shop -n shopAll sub-commands and options: the helm page.
terraform — infrastructure as code
Terraform compares your .tf files with the real cloud and the state, shows a plan, and applies only the difference.
| Sub-command | Use it to |
|---|---|
init, fmt, validate | Prepare and check the folder |
plan -out, apply PLAN | Review and make the change |
state list / show / mv, import | Work with the state |
output, show, console | Read values and test expressions |
workspace, destroy | Several states, remove a stack |
All sub-commands and options: the terraform page.
ansible — configure many servers
Ansible runs idempotent modules over SSH from playbooks, so a second run changes nothing when the servers are already right.
| Command | Use it to |
|---|---|
ansible all -m ping | Test access to every host |
ansible-playbook site.yml --check --diff | Preview, then run playbooks |
ansible-inventory --graph | See hosts and groups |
ansible-galaxy collection install | Get modules and roles |
ansible-vault create / edit | Keep secrets encrypted |
ansible-doc MODULE | Read a module's options |
ansible-playbook -i inventory.ini site.yml -l web --check --diff
ansible-playbook -i inventory.ini site.yml -l webAll commands, modules and options: the ansible page.
aws — Amazon Web Services from the terminal
aws SERVICE OPERATION reaches every AWS service; --query and --output make the answers easy for people and scripts.
| Command | Use it to |
|---|---|
configure sso, sts get-caller-identity | Log in and check who you are |
ec2 describe-instances --filters --query | Find servers |
s3 cp, s3 sync | Move files and backups |
ecr get-login-password, eks update-kubeconfig | Containers and Kubernetes |
ssm start-session, logs tail --follow | Reach servers and read logs |
aws sso login --profile prod && aws sts get-caller-identity --profile prod
aws s3 sync ./public s3://s0sta-site --delete --dryrunAll services and options: the aws page.
az — Microsoft Azure from the terminal
az GROUP COMMAND manages Azure: resource groups, VMs, networks, storage, AKS, Key Vault and RBAC.
| Command | Use it to |
|---|---|
login, account set, account show | Log in and pick the subscription |
group create, deployment group create | Resource groups and Bicep/ARM |
vm create, network vnet / nsg | Servers and networks |
storage blob upload, keyvault secret set | Files and secrets |
acr build, aks get-credentials | Containers and Kubernetes |
role assignment create | Give exactly the access needed |
All command groups and options: the az page.
ssh — secure access to servers
SSH gives an encrypted shell, file copy and tunnels. Keys instead of passwords, and a jump host for private networks.
| Command | Use it to |
|---|---|
ssh user@host | Log in |
ssh-keygen -t ed25519, ssh-copy-id | Make and install a key |
ssh -J bastion web1 | Go through a jump host |
ssh -L 5432:db:5432 bastion | Reach a private service locally |
scp, rsync -e ssh | Copy files |
~/.ssh/config | Save hosts, users, keys and jump hosts |
ssh-keygen -t ed25519 -C "hosam@laptop"
ssh -J deploy@bastion deploy@10.10.1.5All options: the ssh page, plus ssh-keygen and scp.
curl — test websites and APIs
curl sends HTTP requests from the terminal: check status codes, headers, TLS, redirects and API answers.
| Option | Use it to |
|---|---|
-I, -sS -o /dev/null -w '%{http_code}' | Check a site and its status code |
-L, -v | Follow redirects, see the full exchange |
-X POST -H -d / --json | Call an API |
--resolve, -k | Test a new server before DNS / ignore TLS (tests only) |
--retry, --max-time | Health checks in scripts |
curl -sS -o /dev/null -w '%{http_code} %{time_total}s\n' https://s0sta.com/
curl -fsS http://localhost:8080/health || echo "app is down"All options: the curl page.
Follow one change through all 10 tools
A normal day: one small change goes from your laptop to production and is checked — and every tool has its place.
- Make the change on a branch and push it.
- The pipeline builds and pushes the image.
- The infrastructure is already there (built once with Terraform); check it has no drift.
terraform plan -detailed-exitcode - Deploy with Helm and watch the rollout with kubectl.
- Check the result from outside, and on the old VM that still runs a cron job.
At work
Put these steps in a pipeline (GitHub Actions or GitLab CI). The commands are the same; only the trigger changes.
Check yourself
Short questions about the 10 tools.
1Which command shows the Events of a Pod that does not start?
kubectl describe pod NAME (the Events are at the end).
2Which Terraform pair makes sure only the reviewed change is applied?
3How do you install or upgrade a Helm release with one command, and roll back on failure?
4Which Docker publish option keeps a port reachable only from the same machine?
-p 127.0.0.1:8080:80.