---
title: "Bash: Shell Scripting Fundamentals"
lang: "en"
author: "Mohammad Abu Mattar"
canonical: https://mkabumattar.com/post/bash-shell-scripting-fundamentals-quiz
---

[Home](/)›[Quizzes](/quizzes)›[All Categories](/quizzes/categories)›[Bash](/quizzes/categories/bash)

Quizzes

[Bash](/quizzes/categories/bash)[Shell Scripting](/quizzes/categories/shell-scripting)[Linux](/quizzes/categories/linux)[Automation](/quizzes/categories/automation)

# Bash: Shell Scripting Fundamentals

[Mohammad Abu Mattar](/authors/mohammad-abu-mattar)20 QuestionsBeginnerPublished: 30 Jan 2026

[Markdown for AI(opens in a new tab)](/post/bash-shell-scripting-fundamentals-quiz/index.md "Open the plain-Markdown version of this page, for pasting into an AI tool")

Series

[Linux & System Administration](/series/linux--system-administration)2/4

[PreviousLinux: System Administration Fundamentals](/quizzes/post/linux-system-administration-fundamentals-quiz)[NextPowerShell: Windows Scripting Fundamentals](/quizzes/post/powershell-scripting-fundamentals-quiz)

All posts in this series (4)

Quizzes4

1.  [Linux: System Administration Fundamentals](/quizzes/post/linux-system-administration-fundamentals-quiz)
2.  [Bash: Shell Scripting FundamentalsYou are here](/quizzes/post/bash-shell-scripting-fundamentals-quiz)
3.  [PowerShell: Windows Scripting Fundamentals](/quizzes/post/powershell-scripting-fundamentals-quiz)
4.  [Git: Version Control Fundamentals](/quizzes/post/git-version-control-fundamentals-quiz)

## Bash: Shell Scripting Fundamentals

Up to 20 questions, shuffled on every run

Quiz Configuration

Enterto start

Welcome to the Bash Basics Quiz! This quiz covers fundamental Bash scripting concepts, syntax, and best practices. Each question is multiple-choice, and you’ll find hints to help you along the way. Good luck!

Answer key and explanations20 questions

The quiz above draws 20 questions at random from these 30, so a second attempt will not be the same run. Everything in the pool is listed here.

1.  What is the purpose of the "shebang" line (#! /bin/bash) at the top of a script?
    
    AnswerIt specifies the interpreter used to execute the script
    
2.  How do you correctly assign the value "Alpha" to a variable named "Project"?
    
    AnswerProject="Alpha"
    
3.  What does the variable "$?" represent?
    
    AnswerThe exit status of the most recently executed command
    
4.  Which command is used to accept user input during a script?
    
    Answerread
    
5.  How do you check if a variable "VAR" is empty?
    
    Answer\[ -z "$VAR" \]
    
6.  Which brackets are preferred in modern Bash for conditional tests?
    
    Answer\`\[\[ \]\]\`
    
7.  How do you perform integer arithmetic to add 5 and 2?
    
    Answer((result = 5 + 2))
    
8.  What does the "export" command do?
    
    AnswerMakes a variable available to child processes
    
9.  Which loop syntax is correct for iterating through a list of files?
    
    Answer\`for file in \*.txt; do ... done\`
    
10.  What is the difference between single quotes (' ') and double quotes (" ")?
     
     AnswerSingle quotes are literal; double quotes allow expansion
     
11.  How do you capture the output of a command into a variable?
     
     Answer\`VAR=$(command)\`
     
12.  What does the "break" keyword do in a loop?
     
     AnswerExits the loop and continues the script
     
13.  Which special variable contains the number of arguments passed to a script?
     
     Answer\`$#\`
     
14.  How do you define a function in Bash?
     
     Answer\`my\_func() { ... }\`
     
15.  What is the "exit 1" command typically used for?
     
     AnswerTo signal that an error occurred during execution
     
16.  What does "2>&1" do in a command?
     
     AnswerIt merges the error stream into the output stream
     
17.  Which comparison operator is used for strings in \[\[ \]\], but NOT for integers?
     
     Answer\`==\`
     
18.  What is a "Here Document" (EOF)?
     
     AnswerA method for passing multi-line input to a command
     
19.  How do you run a script "backup.sh" in the background?
     
     Answer\`./backup.sh &\`
     
20.  What does "set -x" do?
     
     AnswerTraces and displays each command before execution
     
21.  Which variable represents all arguments passed to the script as individual quoted items?
     
     Answer\`$@\`
     
22.  What is the result of echo ${#VAR}?
     
     AnswerIt returns the character length of the variable
     
23.  How do you check if a file is a directory?
     
     Answer\`\[ -d "$FILE" \]\`
     
24.  What is the purpose of the "alias" command?
     
     AnswerTo create a custom shortcut for a command
     
25.  Which command is used to replace text in a stream using regex?
     
     Answersed
     
26.  How do you evaluate if $A is equal to $B for integers?
     
     Answer\`\[ $A -eq $B \]\`
     
27.  What happens if you run a command with a leading space (e.g., " command")?
     
     AnswerThe command is excluded from the shell history
     
28.  What is the result of "$(( 10 / 3 ))" in Bash?
     
     AnswerA truncated integer value of 3
     
29.  Which command is used to make a script wait for a specific number of seconds?
     
     Answersleep
     
30.  What is the purpose of "source script.sh"?
     
     AnswerTo run the script within the current shell
     

## Tags

[#Bash](/quizzes/tags/bash)[#Shell Scripting](/quizzes/tags/shell-scripting)[#Bash Variables](/quizzes/tags/bash-variables)[#Bash Functions](/quizzes/tags/bash-functions)[#Bash Loops](/quizzes/tags/bash-loops)[#Command Line](/quizzes/tags/command-line)[#Scripting](/quizzes/tags/scripting)[#Automation](/quizzes/tags/automation)[#Linux Shell](/quizzes/tags/linux-shell)

## Share

[Facebook](https://facebook.com/sharer/sharer.php?u=https%3A%2F%2Fmkabumattar.com%2Fquizzes%2Fpost%2Fbash-shell-scripting-fundamentals-quiz "Share on Facebook")[Twitter](https://twitter.com/intent/tweet/?text=Bash%3A%20Shell%20Scripting%20Fundamentals&url=https%3A%2F%2Fmkabumattar.com%2Fquizzes%2Fpost%2Fbash-shell-scripting-fundamentals-quiz "Share on Twitter")[LinkedIn](https://www.linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Fmkabumattar.com%2Fquizzes%2Fpost%2Fbash-shell-scripting-fundamentals-quiz&title=Bash%3A%20Shell%20Scripting%20Fundamentals&summary=Test%20your%20knowledge%20of%20Bash%20scripting%20fundamentals%20with%20a%20quiz%20covering%20variables%2C%20conditionals%2C%20loops%2C%20functions%2C%20I%2FO%20redirection%2C%20special%20parameters%2C%20and%20shell%20scripting%20best%20practices.&source=https://mkabumattar.com "Share on LinkedIn")[WhatsApp](https://wa.me/?text=Bash%3A%20Shell%20Scripting%20Fundamentals%20https%3A%2F%2Fmkabumattar.com%2Fquizzes%2Fpost%2Fbash-shell-scripting-fundamentals-quiz "Share on WhatsApp")[Telegram](https://t.me/share/url?url=https%3A%2F%2Fmkabumattar.com%2Fquizzes%2Fpost%2Fbash-shell-scripting-fundamentals-quiz&text=Bash%3A%20Shell%20Scripting%20Fundamentals "Share on Telegram")[Reddit](https://www.reddit.com/submit?url=https%3A%2F%2Fmkabumattar.com%2Fquizzes%2Fpost%2Fbash-shell-scripting-fundamentals-quiz&title=Bash%3A%20Shell%20Scripting%20Fundamentals "Share on Reddit")[Hacker News](http://news.ycombinator.com/submitlink?u=https%3A%2F%2Fmkabumattar.com%2Fquizzes%2Fpost%2Fbash-shell-scripting-fundamentals-quiz&t=Bash%3A%20Shell%20Scripting%20Fundamentals "Share on Hacker News")[Pinterest](https://pinterest.com/pin/create/button/?url=https%3A%2F%2Fmkabumattar.com%2Fquizzes%2Fpost%2Fbash-shell-scripting-fundamentals-quiz&media=&description=Test%20your%20knowledge%20of%20Bash%20scripting%20fundamentals%20with%20a%20quiz%20covering%20variables%2C%20conditionals%2C%20loops%2C%20functions%2C%20I%2FO%20redirection%2C%20special%20parameters%2C%20and%20shell%20scripting%20best%20practices. "Share on Pinterest")[Email](<mailto:?subject=Bash%3A%20Shell%20Scripting%20Fundamentals&body=Check out this article: https%3A%2F%2Fmkabumattar.com%2Fquizzes%2Fpost%2Fbash-shell-scripting-fundamentals-quiz>)

## Comments

Was this useful?

## You might also enjoy

More posts on similar topics

[![PowerShell: Windows Scripting Fundamentals](/_astro/hero.BunyKCei_Z1q79bl.webp)](/quizzes/post/powershell-scripting-fundamentals-quiz)

## [PowerShell: Windows Scripting Fundamentals](/quizzes/post/powershell-scripting-fundamentals-quiz)

-   [Mohammad Abu Mattar](/authors/mohammad-abu-mattar)
-   [PowerShell](/quizzes/categories/powershell)
-   [Windows](/quizzes/categories/windows)
-   [System Administration](/quizzes/categories/system-administration)
-   [Automation](/quizzes/categories/automation)

Welcome to the PowerShell Basics Quiz! This quiz covers fundamental PowerShell concepts, cmdlets, and scripting best practices. Each question is multiple-choice, and you'll find hints to help you alon

[#PowerShell](/quizzes/tags/powershell)[#PowerShell Cmdlets](/quizzes/tags/powershell-cmdlets)[#PowerShell Scripting](/quizzes/tags/powershell-scripting)+6 tags

[read more](/quizzes/post/powershell-scripting-fundamentals-quiz)

[![Linux: System Administration Fundamentals](/_astro/hero.iaBV-jGL_Z26okHM.webp)](/quizzes/post/linux-system-administration-fundamentals-quiz)

## [Linux: System Administration Fundamentals](/quizzes/post/linux-system-administration-fundamentals-quiz)

-   [Mohammad Abu Mattar](/authors/mohammad-abu-mattar)
-   [Linux](/quizzes/categories/linux)
-   [Operating Systems](/quizzes/categories/operating-systems)
-   [System Administration](/quizzes/categories/system-administration)
-   [DevOps](/quizzes/categories/devops)

Welcome to the Linux Basics Quiz! This quiz covers fundamental Linux concepts, commands, and system administration best practices. Each question is multiple-choice, and you'll find hints to help you a

[#Linux](/quizzes/tags/linux)[#Linux Commands](/quizzes/tags/linux-commands)[#File System](/quizzes/tags/file-system)+6 tags

[read more](/quizzes/post/linux-system-administration-fundamentals-quiz)

[![Git: Version Control Fundamentals](/_astro/hero.CWNfmTF7_1ulCaL.webp)](/quizzes/post/git-version-control-fundamentals-quiz)

## [Git: Version Control Fundamentals](/quizzes/post/git-version-control-fundamentals-quiz)

-   [Mohammad Abu Mattar](/authors/mohammad-abu-mattar)
-   [Git](/quizzes/categories/git)
-   [Version Control](/quizzes/categories/version-control)
-   [Software Development](/quizzes/categories/software-development)
-   [DevOps](/quizzes/categories/devops)

Welcome to the Git Basics Quiz! This quiz covers fundamental Git concepts, version control workflows, and collaborative development best practices. Each question is multiple-choice, and you'll find hi

[#Git](/quizzes/tags/git)[#Version Control](/quizzes/tags/version-control)[#Git Branches](/quizzes/tags/git-branches)+6 tags

[read more](/quizzes/post/git-version-control-fundamentals-quiz)

[![Ansible: Configuration Management & Automation](/_astro/hero.DXguI9Dv_1mD5b9.webp)](/quizzes/post/ansible-automation-fundamentals-quiz)

## [Ansible: Configuration Management & Automation](/quizzes/post/ansible-automation-fundamentals-quiz)

-   [Mohammad Abu Mattar](/authors/mohammad-abu-mattar)
-   [Ansible](/quizzes/categories/ansible)
-   [Configuration Management](/quizzes/categories/configuration-management)
-   [DevOps](/quizzes/categories/devops)
-   [Automation](/quizzes/categories/automation)

Welcome to the Ansible Basics Quiz! This quiz covers fundamental Ansible concepts, modules, and best practices. Each question is multiple-choice, and you'll find hints to help you along the way. Good

[#Ansible](/quizzes/tags/ansible)[#Ansible Playbooks](/quizzes/tags/ansible-playbooks)[#Ansible Modules](/quizzes/tags/ansible-modules)+6 tags

[read more](/quizzes/post/ansible-automation-fundamentals-quiz)

[![CI/CD: Pipeline Automation Essentials](/_astro/hero.PyhZu5TH_ZSTNHp.webp)](/quizzes/post/cicd-pipeline-essentials-quiz)

## [CI/CD: Pipeline Automation Essentials](/quizzes/post/cicd-pipeline-essentials-quiz)

-   [Mohammad Abu Mattar](/authors/mohammad-abu-mattar)
-   [CI/CD](/quizzes/categories/cicd)
-   [DevOps](/quizzes/categories/devops)
-   [Software Development](/quizzes/categories/software-development)
-   [Automation](/quizzes/categories/automation)

Welcome to the CI/CD Basics Quiz! This quiz covers fundamental continuous integration and continuous delivery concepts, pipeline automation, and modern DevOps best practices. Each question is multiple

[#CI/CD](/quizzes/tags/cicd)[#Continuous Integration](/quizzes/tags/continuous-integration)[#Continuous Deployment](/quizzes/tags/continuous-deployment)+6 tags

[read more](/quizzes/post/cicd-pipeline-essentials-quiz)

[![Terragrunt: Infrastructure as Code Management](/_astro/hero.CD16Ljz1_1Nw4rh.webp)](/quizzes/post/terragrunt-iac-management-quiz)

## [Terragrunt: Infrastructure as Code Management](/quizzes/post/terragrunt-iac-management-quiz)

-   [Mohammad Abu Mattar](/authors/mohammad-abu-mattar)
-   [Infrastructure as Code](/quizzes/categories/infrastructure-as-code)
-   [DevOps](/quizzes/categories/devops)
-   [Terraform](/quizzes/categories/terraform)
-   [Automation](/quizzes/categories/automation)

Welcome to the Terragrunt Basics Quiz! This quiz covers fundamental Terragrunt concepts, including DRY configuration management, remote state handling, module dependencies, and best practices for mana

[#Terragrunt](/quizzes/tags/terragrunt)[#Terraform](/quizzes/tags/terraform)[#IaC](/quizzes/tags/iac)+6 tags

[read more](/quizzes/post/terragrunt-iac-management-quiz)

6 related posts
