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 217 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 branching strategy would you choose and why?SeniorGit

Usually trunk-based development: short-lived branches merged to main several times a day, feature flags for unfinished work, and releases cut from main with tags. GitFlow suits slow, versioned releases but adds merge overhead.

13.How do you recover a branch you deleted by mistake?SeniorGit

git reflog shows where HEAD has been; find the last commit of the branch and run git branch name <sha>. Commits stay recoverable until garbage collection prunes them.

14.How do you handle a huge repository that is slow to clone?SeniorGit

Use shallow clones (--depth 1) in CI, partial clones (--filter=blob:none) and sparse checkout for monorepos. Move large binaries to Git LFS or an artifact store, and clean old large files out of history with git filter-repo if needed.

15.What is trunk-based development, and what does it need to work?SeniorGit

Everyone merges small changes into main at least daily instead of keeping long-lived branches. It needs fast CI, good automated tests, feature flags to hide unfinished work, and code review that happens quickly.