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–6 of 6 questions
Learn Bash Scripting →1.What does set -euo pipefail do?Beginner
-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.
2.Why should you quote variables, like "$file"?Beginner
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.
3.What is the difference between single and double quotes in Bash?Beginner
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.
4.How do you check if a command succeeded?Beginner
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.
5.How do you pass arguments to a script and use them?Beginner
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; }.
6.What is the difference between [ ] and [[ ]]?Beginner
[ 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.