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 16–30 of 570 questions

16.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.

17.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.

18.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.

19.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 $?.

20.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.

21.What does set -euo pipefail do?BeginnerBash Scripting

-e exits on any failing command, -u fails on unset variables, and pipefail makes a pipeline fail if any stage fails, not just the last. Together they stop scripts from silently carrying on after an error.

22.Why should you quote variables, like "$file"?BeginnerBash Scripting

Unquoted variables undergo word splitting and glob expansion, so a filename with spaces or a * breaks the command or matches other files. Quoting keeps the value as one argument.

23.What is the difference between single and double quotes in Bash?BeginnerBash Scripting

Single quotes keep everything literally, so '$HOME' prints $HOME. Double quotes still expand variables and $(...) but stop word splitting and globbing, which is why you use "$var" almost everywhere.

24.How do you check if a command succeeded?BeginnerBash Scripting

Every command sets an exit code in $?: 0 means success. Usually you test it directly: if grep -q ERROR app.log; then ... or chain with cmd && next || fallback.

25.How do you pass arguments to a script and use them?BeginnerBash Scripting

Arguments arrive as $1, $2 and so on; $# is how many there are and "$@" is all of them, each kept separate. Check them early, for example [[ $# -ge 1 ]] || { echo "usage: $0 file"; exit 1; }.

26.What is the difference between [ ] and [[ ]]?BeginnerBash Scripting

[ is the old POSIX test command, so variables must be quoted and && doesn't work inside it. [[ ]] is Bash syntax: safer with empty variables, supports &&, ||, pattern matching and regex with =~. Use [[ ]] in Bash scripts.

27.How do you make sure a temporary file is always cleaned up?MidBash Scripting

Create it with mktemp and register trap 'rm -f "$tmp"' EXIT. The trap runs however the script ends, including errors under set -e.

28.What is the difference between $@ and $*?MidBash Scripting

Quoted, "$@" expands to each argument as a separate word, preserving spaces inside arguments; "$*" joins all arguments into one string. Use "$@" to pass arguments on.

29.How do you read a file line by line safely?MidBash Scripting

while IFS= read -r line; do ...; done < file. IFS= keeps leading/trailing whitespace, -r keeps backslashes, and redirecting into the loop avoids a subshell so variables set inside survive.

30.How do you write a function that returns a value?MidBash Scripting

return only sets an exit code from 0 to 255. To return data, print it and capture it: get_ip() { hostname -I | awk '{print $1}'; } then ip=$(get_ip). Use local for variables inside functions.