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 224 questions
16.What is a here document, and when would you use one?MidBash Scripting
A here document feeds several lines to a command: cat <<'EOF' > config.yml ... EOF. Quoting 'EOF' stops variable expansion, which is handy for writing config files or sending a block of commands over SSH.
17.You committed a secret and pushed it. What do you do?MidGit
Rotate the secret first, because it is already compromised. Then remove it from history (git filter-repo or BFG), force-push, ask collaborators to re-clone, and add secret scanning to prevent a repeat.
18.How do you undo a commit that is already on main?MidGit
git revert <sha> creates a new commit that undoes it, which is safe on shared branches. reset --hard rewrites history and should only be used on private branches.
19.How do you find which commit introduced a bug?MidGit
git bisect start, mark a bad and a good commit, and test each midpoint Git checks out; git bisect run ./test.sh automates it. It finds the culprit in log2(n) steps.
20.How do you resolve a merge conflict?MidGit
Git marks the conflicting lines with <<<<<<<, ======= and >>>>>>>. Edit the file to the correct final version, remove the markers, git add it, then git commit (or git rebase --continue). Run the tests before pushing.
21.What does git stash do?MidGit
It saves your uncommitted changes and gives you a clean working directory, so you can switch branches. git stash pop brings them back; git stash list shows saved stashes.
22.How do you squash several commits into one?MidGit
Use an interactive rebase: git rebase -i HEAD~4 and mark commits as squash or fixup. Many teams use 'squash and merge' in the pull request instead. Only rewrite commits that aren't shared yet.
23.What is git cherry-pick and when is it useful?MidGit
It copies one commit onto your current branch, for example to bring a hotfix from main into a release branch. Use it for a few commits; for many, merge or rebase instead.
24.What are Git hooks?MidGit
Scripts Git runs at certain moments, such as pre-commit or commit-msg. Teams use them (often through the pre-commit framework) to run linters, formatters and secret scanners before code leaves a laptop. Enforce the same checks in CI too, because local hooks can be skipped.
25.Why is shell=True dangerous in subprocess?MidPython for DevOps
The text is parsed by a shell, so special characters from outside input can run extra commands. Pass the command as a list of arguments instead.
26.How do you call a REST API safely from Python?MidPython for DevOps
Use requests with a timeout, call raise_for_status(), keep tokens in environment variables, handle paging, and retry on 429 and 5xx.
27.What is yaml.safe_load and why prefer it?MidPython for DevOps
It parses YAML into plain data only. The unsafe loader can create arbitrary Python objects, so a crafted file could run code.
28.What does idempotent mean for an automation script?MidPython for DevOps
Running it again gives the same end result and causes no harm. Check what exists first, then create, update or skip.
29.Why use logging instead of print?MidPython for DevOps
Logging gives timestamps and levels, can write to files, and can be turned up or down without changing code.
30.What is exponential backoff?MidPython for DevOps
Waiting longer after each failed try, such as 1s, 2s, 4s. It gives a busy service time to recover. Always cap the number of tries.