Skip to content
$ lynuxpro

INTERVIEW PREP

Interview questions

570 questions from real DevOps, SRE, platform engineering and MLOps interviews, with the answer an interviewer wants to hear. Try answering out loud first, then open the model answer.

Showing 1–15 of 121 questions

1.Load average is 30 on an 8-core box but CPU is mostly idle. What do you check?SeniorLinux

Load counts tasks running AND in uninterruptible sleep (D state), usually waiting on disk or NFS. Check vmstat 1 (wa, b columns), iostat -x 1 for saturated devices, ps -eo state,pid,cmd | grep ^D for stuck tasks, and dmesg for storage errors.

2.How would you harden SSH on a new server?SeniorLinux

Key-only auth (PasswordAuthentication no), no root login (PermitRootLogin no), restrict users or groups (AllowGroups), keep it patched, limit exposure with a firewall or bastion/SSM, add fail2ban or rate limits, and audit logins. Change one thing at a time and keep a second session open while testing.

3.A server is slow. Walk through how you investigate.SeniorLinux

Start broad, then narrow: uptime for load, top/htop for CPU and memory, vmstat 1 for run queue, swap and I/O wait, iostat -xz 1 for disk, free -m for memory, ss -s for connections, and dmesg/journal for errors like OOM kills. Find which resource is saturated, then which process uses it.

4.What happens, step by step, when you type a command and press Enter?SeniorLinux

The shell reads the line, expands variables and globs, and looks up the command: alias, function, builtin, then each folder in PATH. For an external program it calls fork() to create a child and execve() to load the program; the parent waits and stores the exit code in $?.

5.How does the Linux OOM killer decide what to kill, and how do you protect a process?SeniorLinux

When memory runs out, the kernel picks the process with the highest oom_score, mostly based on memory use. You can lower a process's chance with oom_score_adj (systemd OOMScoreAdjust=). The real fix is right-sizing memory, limits in cgroups, and finding the leak.

6.How do you prevent two copies of a cron script running at once?SeniorBash Scripting

Use a lock: exec 9>/var/lock/job.lock; flock -n 9 || exit 0. The kernel releases the lock when the process exits, even if it crashes, unlike a hand-made PID file.

7.How do you test and lint Bash scripts in CI?SeniorBash Scripting

Run ShellCheck on every script, write tests with bats-core, run with bash -n for syntax, and test under the shell that will run it (dash for /bin/sh scripts).

8.When should you stop using Bash and switch to Python?SeniorBash Scripting

Switch when the script needs real data structures, JSON/YAML parsing, error handling with retries, unit tests, or grows past roughly 100-200 lines. Bash is great for gluing commands together; Python is easier to read, test and maintain for logic.

9.How do you run commands in parallel in Bash and wait for them?SeniorBash Scripting

Start them with & and call wait; capture each PID to check exit codes (wait $pid). For many jobs, xargs -P 8 or GNU parallel limits how many run at once.

10.How do you make a script safe to run twice (idempotent)?SeniorBash Scripting

Check state before changing it: mkdir -p, id user || useradd user, grep -q line file || echo line >> file. Use lock files (flock) to stop overlapping runs, and write to a temp file then mv it into place so a crash never leaves half a file.

11.How do you keep secrets out of shell scripts and logs?SeniorBash Scripting

Read secrets from environment variables or a secret manager at runtime, never hardcode them. Avoid set -x around secret lines, don't pass secrets as command-line arguments (they show in ps), and use read -s for prompts.

12.What is a paginator in boto3?SeniorPython for DevOps

A helper that follows the page tokens of an AWS API for you, so you get every result rather than only the first page.

13.How should a Python script get AWS credentials in production?SeniorPython for DevOps

From an IAM role attached to the compute (EC2, ECS, Lambda or an EKS service account). No long-lived keys in code or files.

14.load_kube_config or load_incluster_config?SeniorPython for DevOps

load_kube_config reads your local kubeconfig and suits laptops. load_incluster_config uses the pod's service account and suits code running in the cluster.

15.Threads, asyncio or processes?SeniorPython for DevOps

Threads for a moderate number of I/O waits, asyncio for very many connections with async libraries, processes for CPU-heavy work. Always limit concurrency.