QuizzesShell Scripting — Bash Fundamentals — Concept Check
intermediate
linux

Shell Scripting — Bash Fundamentals — Concept Check

Questions on Shell Scripting — Bash Fundamentals. Bash scripts automate repetitive tasks, deploy software, and glue tools together. Master variables, conditionals, loops, functions, and error handling to write production-grade scripts.

7 minutes 7 questions Pass at 70%
Time Limit
7 minutes - timer starts when you begin
Change Answers Freely
Revisit and change any answer before submitting
Full Review After Submit
Correct answers and explanations shown for every question
Auto-submit on timeout
Quiz submits automatically when time runs out

Questions in this quiz

7 questions on Shell Scripting — Bash Fundamentals — Concept Check. Work through them here, then start the quiz to answer them and see your score.

  1. 1.You have a bash script with the line `set -euo pipefail`. What is the purpose of this line?

    • ATo disable command tracing
    • BTo set environment variables for the script
    • CTo execute the script in the background
    • DTo enable strict error handling and exit on any error
  2. 2.A script uses `trap cleanup EXIT`. What happens when the script exits?

    • AThe `cleanup` function is executed
    • BThe script restarts automatically
    • CThe script continues running
    • DThe script logs a message and exits
  3. 3.In a bash script, you see `if [[ -f "/etc/nginx/nginx.conf" ]]; then`. What does this check do?

    • AChecks if the file exists
    • BChecks if the file is empty
    • CChecks if the file is writable
    • DChecks if the file is a directory
  4. 4.A script contains `for i in $(seq 1 10); do echo "$i"; done`. What will this loop do?

    • APrint the same number 10 times
    • BPrint numbers 0 to 9
    • CPrint numbers 1 to 9
    • DPrint numbers 1 to 10
  5. 5.Why might you choose bash over Python for a script?

    • ABash is better for orchestrating CLI tools
    • BBash has better error handling
    • CBash is easier to read
    • DBash is faster than Python
  6. 6.In a script, `set -x` is used before a block of code. What is the effect?

    • AEnables debug tracing, printing each command before execution
    • BDisables error handling temporarily
    • CRuns the commands in a subshell
    • DSilently ignores errors
  7. 7.A script has `if [[ "$NAME" == "Akshay" ]]; then echo "Hello, Akshay"; fi`. What is the purpose of this conditional?

    • ATo check if the variable `NAME` is equal to "Akshay"
    • BTo print "Hello, Akshay" unconditionally
    • CTo assign "Akshay" to `NAME`
    • DTo compare two numbers