Shell Scripting Interview Questions and Answers

Real scenario-based questions, a free shell scripting guide, and practice exercises — free to get started.

Free scripting interview questions

A free sample — one beginner, one intermediate, one advanced — with the full answer shown below each question.

IntermediateWhat's the difference between `subprocess.run()` and using `os.system()` in Python?

`os.system()` just shells out and gives you the exit code — no easy access to stdout/stderr, and it's vulnerable to shell injection if you build the command from user input. `subprocess.run()` gives you captured output, separate stdout/stderr, timeouts, and (when you pass a list instead of a shell string) avoids shell injection entirely.

AdvancedYour Python automation script needs to call three independent APIs and is too slow doing it sequentially. How do you speed it up without over-engineering it?

Use concurrent.futures.ThreadPoolExecutor (or asyncio with an async HTTP client) to fire the independent API calls concurrently instead of one after another — since the bottleneck is I/O wait, not CPU, threads/async give a real speedup here without needing multiprocessing, which is for CPU-bound work.

BeginnerWhy bother unit testing an internal automation script, even if it's "just a script" and not a shipped product?

Automation scripts often end up running unattended in production-critical paths (deploys, backups, data migrations) despite their humble origins — a test catches a regression before it runs unsupervised against real infrastructure, which matters just as much as it would for any other piece of production code, regardless of how the script started out.

Learn shell scripting in depth, free to start

An 8-page guide from your first script through strict-mode safety, comparison operators, and real deploy skeletons. The first page is free for everyone. Writing bigger automation tools? The Python guide is the natural next step.

See the full shell scripting guide →

Practice shell scripting for real

Fix a deploy script with an unquoted rm -rf, or trace a bash -x output where a missing pipefail hid a real failure — all graded on real shell behavior.

Try the shell scripting practice exercises →

Shell scripting interview FAQ

What are the most commonly asked shell scripting interview questions?

Interviewers usually describe a script that silently did the wrong thing — an unquoted variable that turned "rm -rf $DIR/*" into something catastrophic, a pg_dump that "succeeded" with exit code 0 despite failing because of a missing pipefail — and ask you to spot the bug, rather than asking you to write syntax from memory.

Do I need to know Python too, or is Bash enough?

Bash covers most day-to-day automation — cron jobs, deploy scripts, log pipelines — but Python is commonly expected for anything more structured: API clients, config validation, multi-step automation. Most DevOps roles expect comfort with both.

What's the #1 shell scripting mistake interviewers look for?

Unquoted variables and missing strict mode (set -euo pipefail). An empty or unset variable can silently turn a safe-looking command into a disaster, and a script that keeps running after a failed step hides bugs instead of catching them.

How do I practice shell scripting safely?

Work through fix-the-script exercises and simulated-terminal incidents first — fixing an unquoted rm -rf, tracing a bash -x output where a missing pipefail hid a real failure — all graded on real shell behavior, with nothing real at risk.

Starting from zero? Read the step-by-step DevOps career roadmap →

The rest of the guide is waiting.

Create a free account to track your progress through the guide, pass the end-of-page quizzes, and take a full-length readiness check.