Master Collection
The complete collection for Automation & Scripting: 200 questions drawn straight from the source bank. The level pages curate a learning path through it; this page holds everything, so nothing is more than one scroll away.
Why is
set -euo pipefailconsidered the gold standard in production Bash scripts?By default, Bash ignores errors, treats undefined variables as empty strings, and only evaluates the exit status of the last command in a pipeline.
-e(errexit): Exits immediately if any command returns a non-zero exit status.-u(nounset): Exits immediately if an undefined variable is referenced.-o pipefail: Prevents masked pipeline errors by ensuring a pipeline (e.g.,cmd1 | cmd2) fails if any command in the chain returns non-zero.
How do you handle cleanup and signal trapping in Bash with
trap?The
trapcommand registers cleanup functions executed when the script exits or receives interruption signals (SIGINT,SIGTERM,EXIT):[ bash ] #!/usr/bin/env bash set -euo pipefail TEMP_DIR=$(mktemp -d /tmp/deploy_XXXXXX) cleanup() { local exit_code=$? echo "[INFO] Cleaning up ${TEMP_DIR} (Exit code: ${exit_code})..." rm -rf "${TEMP_DIR}" } trap cleanup EXIT INT TERMCompare single quotes
' 'vs double quotes" "in Bash.- Single Quotes (
' '): Preserves the literal value of every character inside. Variable expansion ($VAR) and command substitution ($(cmd)) are disabled. - Double Quotes (
" "): Enables variable expansion ($VAR), command substitution ($(cmd)), and arithmetic evaluation while preserving whitespace and preventing word splitting.
- Single Quotes (
How do you parse and filter JSON in Bash using
jq?[ bash ] # 1. Extract pod names in 'Running' state from Kubernetes output kubectl get pods -n production -o json | jq -r \ '.items[] | select(.status.phase=="Running") | .metadata.name' # 2. Extract nested database host echo '{"db": {"host": "10.0.0.1"}}' | jq -r '.db.host' # 3. Construct dynamic JSON payload jq -n --arg env "prod" --arg ver "1.2.0" '{environment: $env, version: $ver}'How do you modify YAML files safely in CLI using
yq?[ bash ] # 1. Update replica count in-place yq eval '.spec.replicas = 5' -i deployment.yaml # 2. Extract container image name IMAGE=$(yq eval '.spec.template.spec.containers[0].image' deployment.yaml)Compare
[[ ... ]]vs[ ... ]in Bash.[ ... ](POSIX Test): Older standard; prone to word splitting on empty variables and requires escaping logical operators (-a,-o).[[ ... ]](Extended Test): Supports regex pattern matching (=~), logical operators (&&,||) without escaping, and does not word-split unset variables.
Explain common Linux / Bash exit codes.
0: Success.1: General error.2: Misuse of shell builtins (syntax error).126: Command invoked cannot execute (permission denied).127: Command not found.130: Script terminated byCtrl+C(SIGINT= $128 + 2$).137: Process killed forcibly (SIGKILL= $128 + 9$, typical for OOMKilled).143: Process terminated gracefully (SIGTERM= $128 + 15$).
How do you run commands in parallel in Bash using
xargs?[ bash ] cat urls.txt | xargs -n 1 -P 4 curl -O-n 1: Pass one argument per command invocation.-P 4: Run up to 4 parallel processes concurrently.
Why is Python
venvmandatory for DevOps automation scripts?Creates isolated environments with independent package dependencies, preventing version conflicts between tools and avoiding polluting system Python packages (
/usr/lib/python), which would break OS package managers (apt/dnf).What is
boto3and what is its credential resolution hierarchy?The official AWS SDK for Python. Authentication Hierarchy:
- Explicit credentials passed to
boto3.client(..., aws_access_key_id=...). - Environment variables (
AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY,AWS_SESSION_TOKEN). - Shared credentials file (
~/.aws/credentials). - AWS IAM Roles for Service Accounts (IRSA) / ECS Task Roles / EC2 Instance Metadata (
IMDSv2).
- Explicit credentials passed to
Compare
boto3.clientvsboto3.resource.boto3.client: Low-level, 1-to-1 mapping to AWS REST APIs returning raw dictionaries; faster and supports 100% of AWS services.boto3.resource: High-level object-oriented abstraction (s3.Bucket('b').objects.all()); cleaner syntax, but does not support all new services.
How do you parse CLI arguments in Python using
argparse?[ python ] import argparse parser = argparse.ArgumentParser(description="Audit AWS snapshots") parser.add_argument("--retention-days", type=int, default=30) parser.add_argument("--dry-run", action="store_true") args = parser.parse_args() print(f"Retention: {args.retention_days}, Dry run: {args.dry_run}")Compare
os.system(),subprocess.run(), andsubprocess.Popen()in Python.os.system(): Legacy; executes in subshell, vulnerable to shell injection.subprocess.run(): Synchronous execution; captures stdout/stderr and return codes.subprocess.Popen(): Asynchronous, non-blocking process execution for streaming real-time output.
How do you safely read and parse environment variables in Python?
[ python ] import os LOG_LEVEL = os.getenv("LOG_LEVEL", "INFO") # Fallback default DATABASE_URL = os.environ["DATABASE_URL"] # Mandatory (raises KeyError)How do you parse and write YAML in Python safely using
PyYAML?[ python ] import yaml with open("config.yaml", "r") as f: config = yaml.safe_load(f) # Always safe_load to prevent code execution! config["replicas"] = 5 with open("config.yaml", "w") as f: yaml.dump(config, f, default_flow_style=False)How do you implement retry logic with exponential backoff in Python?
[ python ] from tenacity import retry, stop_after_attempt, wait_exponential, retry_if_exception_type import requests @retry(stop=stop_after_attempt(5), wait=wait_exponential(multiplier=1, min=2, max=10)) def fetch_api_data(url: str): res = requests.get(url, timeout=5) res.raise_for_status() return res.json()How do you check if a port is open on a remote server using Bash without external tools?
[ bash ] if timeout 2 bash -c "</dev/tcp/10.0.0.1/5432" &>/dev/null; then echo "Port 5432 OPEN" else echo "Port 5432 CLOSED" fiHow do you find and delete files older than $N$ days in Linux?
[ bash ] find /var/log/app/ -type f -name "*.log" -mtime +14 -deleteCompare
awkvssedvsgrep.grep: Pattern matching and line filtering using regex.sed: Stream Editor for text transformation and substitution (sed -i 's/old/new/g' file).awk: Text-processing language operating on structured column data (awk '{print $1, $9}' access.log).
What is a Shebang (
#!/usr/bin/env bash)?Instructs the Linux kernel which interpreter to invoke.
#!/usr/bin/env bashis preferred because it dynamically resolvesbashfrom the user's$PATH.How do you implement robust file locking in Bash with
flock?[ bash ] #!/usr/bin/env bash set -euo pipefail LOCK_FILE="/var/lock/backup_job.lock" exec 200>"${LOCK_FILE}" if ! flock -n 200; then echo "[WARN] Another instance is running. Exiting." exit 1 fi echo "[INFO] Running backup..."How do you read a large file line-by-line in Bash without memory exhaustion?
[ bash ] while IFS= read -r line || [[ -n "$line" ]]; do echo "Processing line: ${line}" done < "large_access_log.txt"How do you pass multiline strings and heredocs safely in Bash without variable expansion?
Quoting the delimiter (
'EOF') disables variable expansion:[ bash ] cat <<'EOF' > /tmp/template.sh echo "Generated at $(date) for user $USER" EOFHow do you execute remote commands concurrently across 50 servers using Python
asyncioandasyncssh?[ python ] import asyncio import asyncssh async def run_cmd(host: str, cmd: str): async with asyncssh.connect(host, username="ubuntu", known_hosts=None) as conn: res = await conn.run(cmd) print(f"[{host}] {res.stdout.strip()}") async def main(hosts): await asyncio.gather(*(run_cmd(h, "uptime") for h in hosts)) asyncio.run(main([f"10.0.0.{i}" for i in range(1, 50)]))How do you interact with HashiCorp Vault in Python using
hvac?[ python ] import hvac, os client = hvac.Client(url="https://vault.company.com:8200", token=os.environ["VAULT_TOKEN"]) res = client.secrets.kv.v2.read_secret_version(mount_point="secret", path="prod/db") password = res["data"]["data"]["password"]What are Python Generators (
yield) and why are they crucial for gigabyte log files?Generators evaluate items on-demand (lazy evaluation) rather than allocating lists in memory:
[ python ] def stream_logs(filepath): with open(filepath, "r") as f: for line in f: if "ERROR 500" in line: yield line.strip()How do you write a Bash function that accepts named parameter flags?
[ bash ] deploy() { local env="" ver="" while [[ $# -gt 0 ]]; do case "$1" in -e|--env) env="$2"; shift 2 ;; -v|--ver) ver="$2"; shift 2 ;; *) echo "Unknown: $1"; return 1 ;; esac done echo "Deploying ${ver} to ${env}" } deploy --env production --ver v2.0.1How do you convert Bash arrays into JSON using
jq?[ bash ] REGIONS=("us-east-1" "us-west-2" "eu-west-1") printf '%s\n' "${REGIONS[@]}" | jq -R . | jq -s . # Output: ["us-east-1", "us-west-2", "eu-west-1"]How do you calculate file SHA256 checksums in Python?
[ python ] import hashlib def get_sha256(filepath): sha = hashlib.sha256() with open(filepath, "rb") as f: while chunk := f.read(8192): sha.update(chunk) return sha.hexdigest()How do you debug Bash scripts in real time?
Run
bash -x script.shor wrap specific blocks inset -x(enable trace) andset +x(disable trace).What is Python
dataclassand why is it used for infrastructure models?Automatically generates
__init__,__repr__, and__eq__methods:[ python ] from dataclasses import dataclass @dataclass(frozen=True) class Instance: instance_id: str ip: str cores: intWhat is
pydanticfor configuration validation?Enforces strict data validation and type coercion from environment variables:
[ python ] from pydantic_settings import BaseSettings class Settings(BaseSettings): db_host: str db_port: int = 5432How do you implement a Token Bucket Rate Limiter in Python?
[ python ] import time class RateLimiter: def __init__(self, rate: int): self.interval = 1.0 / rate self.last = 0.0 def wait(self): diff = time.time() - self.last if diff < self.interval: time.sleep(self.interval - diff) self.last = time.time()How do you sanitize user inputs in Bash scripts to prevent Shell Injection?
Whitelist inputs using regex and avoid
eval:[ bash ] if [[ ! "${INPUT}" =~ ^[a-zA-Z0-9_-]+$ ]]; then echo "[ERROR] Invalid input." >&2; exit 1 fiHow do you build a CLI tool in Python using
Click?[ python ] import click @click.command() @click.option("--env", required=True, type=click.Choice(["dev", "prod"])) def deploy(env): click.echo(f"Deploying to {env}...") if __name__ == "__main__": deploy()What is Python
asyncioand the Event Loop?A single-threaded concurrency framework that manages asynchronous tasks. When an I/O operation starts (
await), the coroutine yields control back to the event loop to execute other tasks.How do you profile Python memory consumption with
tracemalloc?[ python ] import tracemalloc tracemalloc.start() # workload cur, peak = tracemalloc.get_traced_memory() print(f"Peak: {peak / 10**6:.2f} MB") tracemalloc.stop()What is
shutilin Python?High-level file operations module (
shutil.copytree(),shutil.rmtree(),shutil.disk_usage()).What is
pathlibin Python?Object-oriented filesystem path manipulation library replacing legacy
os.path.What is
loggingmodule best practice in Python?Configure handlers, formatters, and log levels centrally; avoid
print()statements in production code.What is Bash Parameter Expansion Default Value (
${VAR:-default})?Uses
defaultifVARis unset or empty, without modifyingVAR.What is Bash Parameter Expansion Assign Default (
${VAR:=default})?Uses
defaultifVARis unset or empty, and assignsdefaulttoVAR.What is Bash Parameter Expansion Error Check (
${VAR:?error_msg})?Exits script with
error_msgifVARis unset or empty.What is Bash String Length (
${#VAR})?Returns the character length of the string stored in
VAR.What is Bash String Substring (
${VAR:offset:length})?Extracts a substring from
offsetof designatedlength.What is Bash String Replacement (
${VAR//pattern/replacement})?Replaces all occurrences of
patternwithreplacementwithinVAR.What is Bash Subshell (
( cd /tmp && ls ))?Commands inside parentheses execute in an isolated child subshell; working directory changes do not affect the parent shell.
What is Command Grouping (
{ cd /tmp; ls; }) in Bash?Commands inside braces execute within the current shell context without spawning a subshell.
What is Process Substitution (
diff <(cmd1) <(cmd2))?Connects the output of commands to temporary file descriptors (
/dev/fd/63), passing command outputs as files to programs that expect file arguments.What is Standard I/O Redirection (
2>&1)?Redirects Standard Error (file descriptor 2) to Standard Output (file descriptor 1).
What is
/dev/nullin Linux?A pseudo-device file that discards all data written to it (black hole) and returns EOF when read.
What is Python
requests.Session?Reuses underlying TCP connections (HTTP Keep-Alive) across multiple requests, drastically improving REST API throughput.
What is Python
concurrent.futures.ThreadPoolExecutor?High-level interface for executing I/O-bound tasks concurrently across a pool of threads.
What is Python
multiprocessingvsthreading?threadingis constrained by the Global Interpreter Lock (GIL) and is optimal for I/O tasks;multiprocessingspawns independent OS processes and is optimal for CPU-bound tasks.What is Python
functools.lru_cache?Decorator that caches the return values of expensive functions in memory based on arguments.
What is Python
contextlib.contextmanager?Decorator allowing the creation of custom
withstatement context managers using generators.What is
cronsyntax (* * * * *)?5 fields: Minute (0-59), Hour (0-23), Day of Month (1-31), Month (1-12), Day of Week (0-6, 0=Sun).
What is
systemd-runfor Ephemeral Timers?Spawns ad-hoc systemd transient timer units from CLI without creating persistent service files.
What is
logrotateConfiguration?Linux daemon that rotates, compresses, and purges system logs based on file size or time intervals.
What is
rsyncwith Archive Mode (-avz)?Synchronizes files remotely preserving permissions, timestamps, symbolic links (
-a), with verbose output (-v) and compression (-z).Part 2: Python for Cloud & Kubernetes (Questions 61–130)
Write a Python script using
boto3to audit and delete unattached EBS volumes older than 30 days.[ python ] import boto3 from datetime import datetime, timezone, timedelta def cleanup_unattached_ebs(days=30, dry_run=True): ec2 = boto3.client("ec2", region_name="us-east-1") cutoff = datetime.now(timezone.utc) - timedelta(days=days) res = ec2.describe_volumes(Filters=[{"Name": "status", "Values": ["available"]}]) for vol in res.get("Volumes", []): if vol["CreateTime"] < cutoff: print(f"[ACTION] Volume {vol['VolumeId']} ({vol['Size']}GB) eligible.") if not dry_run: ec2.delete_volume(VolumeId=vol["VolumeId"]) if __name__ == "__main__": cleanup_unattached_ebs(30, dry_run=False)Write a Python script using the official
kubernetesclient to trigger a rolling restart of a deployment.[ python ] from kubernetes import client, config from datetime import datetime, timezone def restart_deployment(ns: str, name: str): try: config.load_incluster_config() except config.ConfigException: config.load_kube_config() apps = client.AppsV1Api() now = datetime.now(timezone.utc).isoformat() body = {"spec": {"template": {"metadata": {"annotations": {"kubectl.kubernetes.io/restartedAt": now}}}}} apps.patch_namespaced_deployment(name=name, namespace=ns, body=body) if __name__ == "__main__": restart_deployment("production", "payment-service")Write a Python script using
boto3to scan all S3 buckets and enable KMS encryption.[ python ] import boto3 from botocore.exceptions import ClientError def enforce_s3_encryption(): s3 = boto3.client("s3") for bucket in s3.list_buckets().get("Buckets", []): name = bucket["Name"] try: s3.get_bucket_encryption(Bucket=name) except ClientError as e: if e.response["Error"]["Code"] == "ServerSideEncryptionConfigurationNotFoundError": print(f"Enabling AES256 on {name}") s3.put_bucket_encryption( Bucket=name, ServerSideEncryptionConfiguration={ "Rules": [{"ApplyServerSideEncryptionByDefault": {"SSEAlgorithm": "AES256"}}] } ) if __name__ == "__main__": enforce_s3_encryption()How do you scrape and parse Prometheus metrics endpoints using Python?
[ python ] import requests from prometheus_client.parser import text_string_to_metric_families def parse_metrics(url: str, metric_name: str): res = requests.get(url, timeout=5) for family in text_string_to_metric_families(res.text): if family.name == metric_name: for sample in family.samples: print(f"Name: {sample.name}, Labels: {sample.labels}, Value: {sample.value}") if __name__ == "__main__": parse_metrics("http://localhost:9090/metrics", "http_requests_total")How do you drain and replace worker nodes in an AWS ASG using Python?
[ python ] import boto3, time from kubernetes import client, config def rolling_asg_update(asg_name: str): config.load_kube_config() core = client.CoreV1Api() asg = boto3.client("autoscaling") ec2 = boto3.client("ec2") instances = asg.describe_auto_scaling_groups(AutoScalingGroupNames=[asg_name])["AutoScalingGroups"][0]["Instances"] for inst in instances: iid = inst["InstanceId"] node_name = ec2.describe_instances(InstanceIds=[iid])["Reservations"][0]["Instances"][0]["PrivateDnsName"] core.patch_node(node_name, {"spec": {"unschedulable": True}}) asg.terminate_instance_in_auto_scaling_group(InstanceId=iid, ShouldDecrementDesiredCapacity=False) time.sleep(60)Part 3: Go for DevOps, Advanced Automation & Incident Runbooks (Questions 66–200)
Why is Go (Golang) the dominant language for Cloud-Native and DevOps tooling?
Compiles to a single static binary with zero external runtime dependencies, ultra-fast boot time, low memory footprint, first-class concurrency (Goroutines and Channels), and strong type safety (Docker, Kubernetes, Terraform, Prometheus are all written in Go).
What are Goroutines vs OS Threads in Go?
Goroutines are lightweight userspace threads managed by the Go runtime scheduler (m:n scheduler). A Goroutine starts with only 2KB of stack memory (compared to 1–8MB for OS threads) and switches context in nanoseconds.
What are Go Channels and how do they coordinate concurrent tasks?
Typed conduits for sending and receiving data between Goroutines safely without explicit mutex locks ("Do not communicate by sharing memory; instead, share memory by communicating").
Write a Go program using the official
client-golibrary to list all pods in a namespace.[ go ] package main import ( "context" "fmt" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes" "k8s.io/client-go/tools/clientcmd" ) func main() { config, _ := clientcmd.BuildConfigFromFlags("", clientcmd.RecommendedHomeFile) clientset, _ := kubernetes.NewForConfig(config) pods, _ := clientset.CoreV1().Pods("production").List(context.TODO(), metav1.ListOptions{}) for _, pod := range pods.Items { fmt.Printf("Pod: %s, Status: %s\n", pod.Name, pod.Status.Phase) } }Write a Go HTTP health check probe with timeout.
[ go ] package main import ( "net/http" "time" ) func checkHealth(url string) bool { client := http.Client{Timeout: 2 * time.Second} resp, err := client.Get(url) if err != nil || resp.StatusCode != http.StatusOK { return false } return true }What is
sync.WaitGroupin Go?Coordinates waiting for a collection of concurrent Goroutines to finish execution using
Add(),Done(), andWait().What is
context.Contextin Go and why is it mandatory for cloud operations?Carries deadlines, cancellation signals, and request-scoped values across API boundaries, ensuring downstream network calls terminate when parent requests time out.
What is Go
deferstatement?Schedules a function call to execute immediately before the surrounding function returns, heavily used for resource cleanup (
defer file.Close(),defer resp.Body.Close()).What is Go
selectstatement?Allows a Goroutine to wait on multiple channel communications simultaneously, executing the first channel that is ready.
What is Go Mutex (
sync.Mutexvssync.RWMutex)?sync.Mutex: Exclusive mutual exclusion lock.sync.RWMutex: Allows multiple concurrent readers or a single exclusive writer.
What is Go Custom Kubernetes Controller architecture?
Uses
InformerFactory,Lister, andWorkqueueto process reconcile events from the Kubernetes API Server.What is Go Cobra Framework?
The standard library for building modern CLI tools with subcommands, flags, and auto-generated help docs (powers
kubectlandhugo).What is Go Viper Framework?
A complete configuration solution for Go applications supporting JSON, YAML, environment variables, and remote key-value stores.
What is Go Cross-Compilation?
Compiling binaries for different OS and architectures from a single machine using environment variables:
GOOS=linux GOARCH=arm64 go build -o app_arm64.What is Go
cgoand why isCGO_ENABLED=0mandatory for container scratch images?CGO_ENABLED=0disables linking to host C libraries (glibc), producing a 100% statically linked binary that runs inside an empty DockerFROM scratchcontainer.What is Bash Array Slicing (
${ARR[@]:1:2})?Extracts a subset of array elements from offset index for designated length.
What is Bash Associative Array (
declare -A MAP)?Key-value hash maps in Bash 4+:
[ bash ] declare -A SERVERS SERVERS["web"]="10.0.0.1" SERVERS["db"]="10.0.0.2"What is Bash Indirect Variable Reference (
${!VAR})?Evaluates the value of the variable whose name is stored in
VAR.What is Bash Read with Timeout (
read -t 5)?Waits up to 5 seconds for user input before returning non-zero.
What is Bash Math Evaluation (
$(( 5 * 2 )))?Native integer arithmetic evaluation inside double parentheses.
What is Python
boto3Paginator?Automatically iterates across multi-page API responses (
paginator.paginate()) to fetch thousands of cloud objects without manualNextTokenhandling.What is Python
boto3Waiter?Polls AWS service state until a designated condition is reached (
waiter.wait(InstanceIds=['...'])), avoiding custom while-sleep loops.What is Python
fabricfor SSH automation?High-level Python library executing shell commands remotely over SSH and uploading/downloading files.
What is Python
pexpect?Automates interactive console applications (prompting for passwords or confirmations) by spawning child processes and matching output patterns.
What is Python
paramiko?Low-level native Python implementation of the SSHv2 protocol for custom SFTP and SSH clients.
What is Bash Here-String (
<<< "$STRING")?Passes a string variable directly to a command's standard input without
echo | cmd.What is Bash Null Command (
:)?A no-op builtin that returns exit code 0, used in infinite loops (
while :; do ... done) or setting default variables.What is Bash Output to Multiple Files (
tee)?Reads standard input and writes it simultaneously to standard output and one or more files.
What is Bash Split String by Delimiter (
IFS=',' read -ra ARR <<< "$STR")?Splits a delimited string into an array using Internal Field Separator.
What is Python
uuid.uuid4()?Generates cryptographically secure random UUIDs for distributed correlation IDs and request tracking.
What is Python
tempfile.NamedTemporaryFile?Creates secure temporary files with automated deletion on context manager exit.
What is Python
secretsmodule?Generates cryptographically secure random numbers and tokens for passwords and authentication keys.
What is Python
hashlib.pbkdf2_hmac?Secure key derivation function applying HMAC with SHA256 over thousands of iterations for password hashing.
What is Python
urllib3.PoolManager?Thread-safe connection pool manager used internally by
requestsfor client connection reuse.What is Python
jinja2.Template?Renders configuration files dynamically with variable substitutions, conditionals, and loops.
What is Bash
mktemp?Creates a secure temporary file or directory with unique randomized name in
/tmp.What is Bash
basenameanddirname?basename /var/log/app.log$\rightarrow$app.logdirname /var/log/app.log$\rightarrow$/var/log
What is Bash
realpath?Resolves relative paths, symbolic links, and parent references (
..) to canonical absolute paths.What is Bash
getopts?Builtin utility for parsing single-character command-line options and arguments in scripts.
What is Bash Subshell Exit Code (
$?)?Holds the exit status of the most recently executed foreground command.
What is Python
dotenv(python-dotenv)?Reads key-value pairs from a
.envfile and adds them to environment variables (os.environ).What is Python
attrsvspydantic?attrsfocuses on class creation and boilerplate reduction;pydanticfocuses on runtime data parsing and strict schema validation.What is Python
marshmallow?Object serialization and deserialization library converting complex objects to and from native Python datatypes.
What is Python
celery?Distributed task queue managing background jobs across Redis or RabbitMQ message brokers.
What is Python
fastapiin DevOps Tooling?High-performance web framework for building microservices, webhook receivers, and internal DevOps APIs with automated OpenAPI docs.
What is Bash
shuf?Generates random permutations or picks random lines from input files (used for random canary node selection).
What is Bash
comm?Compares two sorted files line by line, outputting lines unique to file 1, unique to file 2, or common to both.
What is Bash
cut?Extracts specific sections or columns from each line of a file using field delimiters (
cut -d: -f1 /etc/passwd).What is Bash
tr?Translates, deletes, or squeezes characters from standard input (
tr '[:lower:]' '[:upper:]').What is Bash
sort -uvsuniq?uniqonly removes adjacent duplicate lines;sort -usorts the entire file and removes all duplicates globally.What is Python
typer?CLI library built on top of Click that uses Python type hints to generate command-line interfaces automatically.
What is Python
rich?Terminal formatting library rendering rich colored text, tables, progress bars, and markdown directly in CLI tools.
What is Python
watchdog?Filesystem event monitoring library that triggers callbacks when files are created, modified, or deleted on disk.
What is Python
schedule?In-process Python job scheduling library for running recurring jobs with human-readable syntax.
What is Python
pytestin DevOps Automation?Testing framework for writing unit and integration tests against infrastructure scripts, API responses, and CLI tools.
What is Bash
head -nandtail -n?Outputs the first $N$ or last $N$ lines of a file (
tail -fstreams live appended lines).What is Bash
wc -l?Counts the total number of lines in standard input or files.
What is Bash
grep -E(Extended Regex)?Enables extended regular expressions (
+,?,|,()) without backslash escaping.What is Bash
grep -v?Inverts match to select non-matching lines.
What is Bash
grep -o?Prints only the exact matched parts of a matching line.
What is Python
boto3Client Error Handling (botocore.exceptions.ClientError)?Catching AWS API exceptions and inspecting
e.response['Error']['Code']to handle specific errors (NoSuchBucket,ThrottlingException).What is Python
kubernetes.watch.Watch?Streams real-time event updates for Kubernetes resources from the API Server without polling.
What is Python
dockerSDK?Official Python library for controlling Docker daemons, building images, managing containers, and reading logs via API.
What is Python
gitpython?Python library for interacting with Git repositories programmatically (cloning, checking out branches, creating commits).
What is Python
pyOpenSSL?Python wrapper around OpenSSL for generating keys, creating CSRs, and inspecting X.509 certificate fields.
What is Bash
seq?Generates a sequence of numbers (
seq 1 10).What is Bash
column -t?Formats unaligned tabular text into clean, evenly spaced visual columns.
What is Bash
fold?Wraps input lines to fit a specified column width.
What is Bash
paste?Merges corresponding lines of multiple files side-by-side separated by tabs.
What is Bash
split?Splits a large file into smaller chunks based on line count or byte size (
split -b 100M large.tar.gz).What is Python
pytest-mock?Plugin providing fixture-based mocking of cloud SDKs and external APIs during unit test execution.
What is Python
responses?Utility library for mocking Python
requestscalls during unit testing.What is Python
moto?Comprehensive library that mocks AWS services locally, allowing
boto3scripts to be tested without AWS accounts.What is Python
freezegun?Freezes and mocks time in Python unit tests to test TTLs and expiration logic.
What is Python
hypothesis?Property-based testing framework that generates diverse test cases to discover edge-case bugs in automation logic.
What is Bash
tac?Concatenates and prints files in reverse order (last line first).
What is Bash
nl?Numbers lines of files during output.
What is Bash
fold -s?Wraps lines at space boundaries to prevent breaking words across lines.
What is Bash
rev?Reverses lines character-by-character.
What is Bash
expandandunexpand?Converts tabs to spaces and spaces to tabs in text files.
What is Python
structlog?Structured logging library binding contextual key-value pairs across application call chains to emit structured JSON logs.
What is Python
loguru?Zero-config Python logging library with automatic stack formatting, file rotation, and colorized output.
What is Python
coloredlogs?Colorizes Python standard logging output for CLI terminal tools.
What is Python
psutil?Cross-platform library for retrieving hardware utilization (CPU, memory, disks, network) and running process information.
What is Python
cryptographylibrary?Standard cryptographic primitives library providing AES-GCM encryption, RSA/ECC key generation, and X.509 parsing.
What is Bash
readlink -f?Canonicalizes paths by following every symlink recursively.
What is Bash
env -i?Executes a command in a clean, empty environment with zero inherited environment variables.
What is Bash
exec?Replaces the current shell process with the specified command without creating a new process ID.
What is Bash
timebuiltin?Measures real, user, and system CPU time consumed by command execution.
What is Bash
ulimit?Controls process resource limits (max open files, max stack size, max user processes).
What is Python
scapy?Powerful interactive packet manipulation library for generating, sniffing, and forging network packets.
What is Python
netaddr?Library for parsing, manipulating, and calculating IP addresses, subnets, CIDRs, and MAC addresses.
What is Python
socketmodule?Low-level network interface accessing BSD socket APIs directly.
What is Python
sslmodule?TLS/SSL encryption wrapper for socket objects.
What is Python
ipaddressmodule?Standard library for inspecting and calculating IPv4 and IPv6 network properties and subnet overlap.
What is Bash
aliasvs Function?Aliases are simple string replacements; Functions accept positional arguments, local variables, and logic branches.
What is Bash
historycommand?Displays the chronological list of previously executed shell commands with line numbers.
What is Bash
bind?Binds Readline keyboard shortcuts to shell editing functions.
What is Bash
typecommand?Identifies whether a command is a shell builtin, alias, function, or external binary on disk.
What is Bash
whichvscommand -v?command -vis POSIX-compliant and faster because it is a shell builtin;whichis an external binary that may behave inconsistently across OSs.What is Python
multiprocessing.Pool?Distributes CPU-intensive tasks across a fixed pool of worker processes.
What is Python
asyncio.Semaphore?Limits the maximum number of concurrent coroutines accessing a shared resource simultaneously.
What is Python
asyncio.Queue?Thread-safe FIFO queue for coordinating producer and consumer coroutines in asynchronous pipelines.
What is Python
aiohttp?Asynchronous HTTP client and server framework for high-throughput API integrations.
What is Python
httpx?Modern HTTP client supporting both synchronous and asynchronous APIs with HTTP/2 support.
What is Bash
loggercommand?Sends custom log messages directly to the Linux system logger (
/var/log/syslog/ systemd journal).What is Bash
watchcommand?Executes a command repeatedly at regular intervals (default: 2s), displaying live output in full screen.
What is Bash
timeoutcommand?Runs a command and terminates it with
SIGTERM/SIGKILLif it exceeds a specified duration.What is Bash
yescommand?Outputs an endless stream of
y(or designated string) to automate interactive CLI prompts.What is Bash
nohupcommand?Runs a command immune to hangups (
SIGHUP), allowing processes to continue running in background after terminal disconnection.What is Python
boto3Resource Cost Tracking?Tagging all dynamically created AWS resources (
Environment,CreatedBy,Owner) via Python scripts to enable FinOps attribution.What is Python AWS Lambda Handler Structure?
def lambda_handler(event, context):receives trigger payload (event) and runtime metadata (context).What is Python AWS Step Functions Local Execution?
Testing serverless state machines locally using Docker containers and Python SDKs.
What is Python
sqlalchemyin DevOps?Object Relational Mapper (ORM) and SQL toolkit for interacting with relational databases in automation pipelines.
What is Python
alembic?Lightweight database migration tool for PostgreSQL/MySQL managed in Python code.
What is Bash
chownvschmod?chownchanges user and group file ownership;chmodchanges read, write, and execute permissions.What is Bash
umask?Sets default permission masks for newly created files and directories (e.g.,
022results in755directories and644files).What is Bash Sticky Bit (
chmod +t)?Applied to directories (like
/tmp) so that only the file's owner or root can delete or rename files within the directory.What is Bash SUID Bit (
chmod u+s)?Executes binary with the permissions of the file owner rather than the running user (e.g.,
/usr/bin/passwd).What is Bash SGID Bit (
chmod g+s)?Ensures newly created files inside a directory inherit the group ownership of the directory rather than the primary group of the user.
What is Python
click.group?Creates nested multi-level command hierarchies for complex CLI utilities (
cli deploy backend).What is Python
click.prompt?Interactively prompts the user for inputs with optional masking for passwords (
hide_input=True).What is Python
click.progressbar?Renders visual progress bars for long-running iterative tasks in terminal tools.
What is Python
pyinstrument?Statistical Python code profiler that outputs hierarchical call trees to identify execution bottlenecks.
What is Python
line_profiler?Line-by-line CPU profiling tool analyzing execution time spent on each individual statement inside functions.
What is Bash
crontab -evs/etc/cron.d/?crontab -eedits user-specific cron tables;/etc/cron.d/contains system-wide modular cron job files with explicit username fields.What is Bash
atcommand?Schedules a one-time command execution at a specific future timestamp (
at 2:00 AM tomorrow).What is Bash
systemctl list-timers?Lists all active systemd timer units, their next trigger timestamp, and last execution time.
What is Bash
journalctl -u?Filters and displays systemd logs for a specific service unit (
journalctl -u nginx.service -f).What is Bash
dmesg -T?Prints human-readable timestamped Linux kernel ring buffer messages.
What is Python
pytest-cov?Pytest plugin measuring code coverage percentage across test suites.
What is Python
black?Uncompromising Python code formatter ensuring consistent codebase style across teams.
What is Python
ruff?Extremely fast Python linter and code formatter written in Rust, replacing flake8, isort, and black.
What is Python
mypy?Static type checker for Python analyzing type hints to prevent runtime
TypeErrorbugs.What is an Enterprise Automation Runbook Standard?
- Idempotency: Re-running produces identical state without errors.
- Dry-Run Mode (
--dry-run): Previews actions before executing modifications. - Structured Logging: Emits machine-readable JSON logs.
- Signal Handling: Cleans up temporary resources on
SIGINT/SIGTERM. - Auditing & Telemetry: Records who ran the script, parameters used, and execution duration.
Contribute & Stay Updated
When sharing scripts, include comments explaining the logic and add error handling examples. This helps others learn best practices.
Want to contribute?
We welcome contributions! If you have insights, new tools, or improvements, feel free to submit a pull request.
How to Contribute?
- Read the CONTRIBUTING.md guide.
- Fix errors, add missing topics, or suggest improvements.
- Submit a pull request with your updates.
Stay Updated:
Star the repository to get notified about new updates and additions.
Join discussions in GitHub Issues to suggest improvements.
Connect With Us
- GitHub: @NotHarshhaa
- Blog: ProDevOpsGuy Tech
- Telegram Community: Join Here
The level pages cover the curated path. This page holds the complete raw collection — every question from the source bank, in exam order.