Beginner Level
This section covers fundamental concepts in automation and scripting, including basic Bash commands, Python scripting, YAML syntax, and introductory Groovy concepts.
What is automation in DevOps?
Automation in DevOps means replacing manual, repetitive work — provisioning servers, applying configuration, deploying applications, running checks — with scripts or tools that execute the same steps reliably every time.
The goal is not just speed: automated steps are consistent (the same every run), repeatable (safe to run 100 times), and auditable (the script is the documentation). That is why nearly every DevOps practice, from CI/CD to infrastructure as code, is built on scripting.
What are the benefits of scripting in DevOps?
- Reduces manual effort — a task that took 30 minutes of clicking becomes a one-command run
- Consistency and repeatability — the same input always produces the same result, with no "works on my machine" drift
- Fewer human errors — typos and skipped steps are the most common cause of outages; scripts don't get tired
- Version-controllable — scripts live in Git, so every change is reviewed, tracked, and revertible
- Faster feedback — automated checks and deployments shorten the loop between making a change and verifying it
What is Bash scripting?
Bash (Bourne Again Shell) scripting is writing a series of shell commands into a file (
.sh) that the Bash interpreter executes top to bottom, so a sequence you would otherwise type manually runs as one automated unit.Scripts can use variables, conditionals, loops, and functions, which turns a list of commands into real program logic. It is the default automation tool on Linux servers, which is why it appears in almost every DevOps job description.
How do you write a basic Bash script?
bashThree steps:
- Save the file, e.g.
script.sh - Make it executable:
chmod +x script.sh - Run it:
./script.sh
The first line (
#!, the "shebang") tells the system which interpreter to use. Running./script.shonly works afterchmod +x— otherwise you would needbash script.sh, which invokes Bash explicitly and skips the execute-permission requirement.- Save the file, e.g.
What is the difference between Bash and Shell scripting?
"Shell scripting" is the general term for writing scripts for any Unix shell; Bash is one specific shell. Other shells include
sh(the original Bourne shell),zsh,ksh, anddash.Bash is a superset of POSIX
sh— it adds arrays,[[ ]]tests, string operations, and more. In interviews, mention the portability angle: a script written with only POSIX features runs everywhere, while Bash-specific features require Bash (which is why system boot scripts often stick to plainsh).What are variables in Bash?
Variables store values that scripts can read and reuse. You assign without
$and read with$:bashCommon gotchas interviewers look for:
- No spaces around
=—name = "DevOps"is an error (Bash thinks you're running a command) - Quote the value if it contains spaces:
greeting="hello world" - Use
"${var}"(quoted) when the value may contain spaces or is optional — it prevents unwanted word splitting
- No spaces around
What is Python scripting used for in DevOps?
Python is the general-purpose glue language of DevOps. Typical uses:
- Cloud automation — the AWS (boto3), Azure, and GCP SDKs are Python-first
- CI/CD tooling — release scripts, build helpers, API automation
- Log and data processing — parsing large files, generating reports
- Infrastructure tooling — Terraform is written in Go but commonly extended with Python; Ansible modules are Python under the hood
- Webhooks and bots — small Flask/FastAPI services for chat-ops and alerting
How do you define a function in Python?
pythonFunctions are defined with
def, can take parameters, and return values withreturn. Grouping logic into functions makes scripts testable and reusable — the same reason you'd use functions in Bash.What is YAML, and where is it used?
YAML ("YAML Ain't Markup Language" — a recursive acronym; it was originally "Yet Another Markup Language") is a human-readable data serialization format built on indentation rather than brackets.
It is the configuration language of the DevOps ecosystem:
- Kubernetes — every resource (Pods, Deployments, Services) is YAML
- Ansible — playbooks are YAML
- CI/CD — GitHub Actions, GitLab CI, and Docker Compose files are YAML
- Observability — Prometheus rules and alertmanager configs
Interview tip: emphasize that indentation is significant — mixing tabs and spaces is the single most common YAML error.
What is a YAML file example?
yamlThis Docker Compose file shows the core YAML building blocks:
key: valuepairs (mappings), indentation to show nesting, and a list item (- "80:80"). The same structure scales up to Kubernetes manifests and Ansible playbooks, which is why learning YAML once pays off everywhere.What is Groovy, and why does Jenkins use it?
Groovy is a dynamic language that runs on the Java Virtual Machine (JVM), known for concise syntax and smooth Java interoperability.
Jenkins uses it because Jenkins itself is Java: pipeline definitions (
Jenkinsfile) are written in Groovy, which lets pipelines mix simple DSL steps (sh,echo) with full programming logic — loops, conditionals, functions — inside the build definition.What is the shebang (
#!) in a script?The shebang is the first line of a script and specifies which interpreter should execute it:
bashWhen you execute
./script.sh, the kernel reads the shebang and invokes that interpreter. The#!/usr/bin/env bashvariant is often preferred because it finds the interpreter throughPATHinstead of hardcoding a location — more portable across Linux distributions and macOS.What are loops in Bash?
Bash supports
for,while, anduntilloops:bashA classic DevOps pattern is the
untilloop as a retry/wait mechanism — for example, waiting for a service to come up before continuing a deployment script.What are conditional statements in Bash?
if/elif/elseruns different code depending on a condition:bashKey details to mention:
- Quote variables inside tests (
"$USER") to avoid breakage on empty values [[ ]]is the Bash-preferred test (safer than the POSIX[ ]); numeric comparisons use-eq,-lt,-gt, file checks use-f(file exists),-d(directory exists),-z(empty string)
- Quote variables inside tests (
How do you read user input in Bash?
bash-pshows the prompt in one line, and-r(always use it) preventsreadfrom mangling backslashes. For scripts that must be non-interactive (CI pipelines), the samereadcan consume piped input, or you can default with${1:-"fallback"}arguments instead.How do you create a Python virtual environment?
bashA virtual environment isolates a project's dependencies from the system Python, so different projects can use different versions of the same library. In DevOps pipelines this matters constantly — CI runners create a fresh venv (or use containers) to guarantee builds use pinned, reproducible dependencies from
requirements.txt.How do you parse JSON in Python?
pythonRemember the pair:
loadsparses a JSON string into Python objects,dumpsserializes them back out. (Their file counterparts arejson.load()andjson.dump().) This is the everyday pattern for handling API responses and cloud CLI output in automation scripts.What is the
awkcommand in Bash?awkis a text-processing tool that splits each line into fields and applies pattern-action rules:bashFields are numbered
$1, $2, ...with$0being the whole line; by default fields split on whitespace, and-Fchanges the delimiter. In DevOps work it's the go-to for quick column extraction from logs,df/psoutput, and CSVs.How do you comment in YAML?
Use
#— everything after it on that line is ignored:yamlUnlike Python there is no multi-line comment syntax — each comment line needs its own
#. YAML files are usually hand-edited, so good comments explaining why a value is set are genuinely useful documentation.How do you declare variables in Groovy?
groovydefdeclares a dynamically-typed variable (the common style), while explicit types are available when you want safety. Groovy also supports single-quoted strings (no interpolation) versus double-quoted (interpolates${}) — a subtle difference that matters in Jenkinsfiles.