In a bank’s production support interview, Bash is where you prove you can triage a live incident. Expect a mix of quick-fire command questions and a scenario where a trading application has stopped and you have a terminal. Here is what to prepare.
Quick-fire questions
1. What does set -euo pipefail do?
-e exits on any failing command, -u treats unset variables as errors, and -o pipefail makes a pipeline fail if any stage fails, not just the last. It should be at the top of every production script.
2. Difference between $@ and $*?
Quoted, "$@" keeps each argument separate (safe with spaces); "$*" joins them into one string. Use "$@" almost always.
3. How do you check the exit status of the last command?
$?. Zero is success, anything else is failure. Schedulers such as Autosys and Control-M rely on this to mark jobs as failed.
4. Find the top 10 error messages in a log.
grep -i "error" app.log | cut -d']' -f2- | sort | uniq -c | sort -rn | head -10
5. Show errors between 09:00 and 09:15.
awk '$2 >= "09:00:00" && $2 <= "09:15:00" && /ERROR/' app.log
6. Disk is full, but du does not show what is using it. Why?
A process still holds a deleted file open. Find it with lsof +L1 or lsof | grep deleted, then restart the process or truncate via /proc/<pid>/fd/<n>. This is a classic.
7. Which process is listening on port 8443?
ss -ltnp | grep 8443
# or
lsof -i :8443
8. Difference between kill and kill -9?
kill sends SIGTERM, letting the process shut down cleanly (flush, close connections, release locks). kill -9 sends SIGKILL, which cannot be caught. Use it last, because it can leave stale lock files or half-written messages.
9. How do you run a command that survives logout?
nohup cmd &, screen or tmux, or properly as a systemd service. Interviewers like hearing that long-running processes belong under a supervisor, not a terminal.
10. Read a file line by line safely.
while IFS= read -r line; do
echo "Processing: $line"
done < trades.txt
11. How do you check load and memory quickly?
uptime (load average against CPU count from nproc), free -h, top or htop, vmstat 1 5 for swapping, and iostat -x 1 for disk wait.
The scenario question
“Traders say the pricing app stopped updating five minutes ago. Walk me through it.” A strong answer is structured:
- Communicate first: acknowledge, open the incident, set an update cadence.
- Is it running?
ps -ef | grep pricing,systemctl status. - What changed? Recent deployments, config changes, certificate expiry.
- Logs:
tail -fand grep around the failure time. - Resources: disk (
df -h), memory, file descriptors (ulimit -n,ls /proc/<pid>/fd | wc -l). - Dependencies: market data feed, MQ queue depth, database, network (
nc -zv host port). - Restore service, then root cause and a problem record.
Write this script in the interview
A small, safe log housekeeping script shows good habits: strict mode, variables, logging and exit codes.
#!/usr/bin/env bash
set -euo pipefail
LOG_DIR="${1:?Usage: $0 <log_dir> [days]}"
DAYS="${2:-7}"
[[ -d "$LOG_DIR" ]] || { echo "No such dir: $LOG_DIR" >&2; exit 1; }
echo "$(date '+%F %T') compressing logs older than $DAYS days in $LOG_DIR"
find "$LOG_DIR" -type f -name "*.log" -mtime +"$DAYS" -print -exec gzip {} \;
Final tips
- Know
grep,awk,sed,find,xargs,sort,uniq,cutandtailwithout looking them up. - Always say you would test in UAT first and take a backup before changing anything in production.
- Mention change control: in a bank, nothing goes to production without an approved change ticket.