Bash (Coding) Quiz
Bash shell scripting — the automation and glue-code language behind most Linux/Unix system administration.
This category currently has 60 questions in the SERVBG quiz bank. Below are a few sample questions — the full interactive quiz shuffles through the whole set with instant scoring.
Sample questions
What does $? expand to in Bash?
- The name of the script
- The number of arguments passed
- The exit status of the last foreground command
- The PID of the last background process
- The PID of the current shell
Which expansion gives the length of the variable var?
- $#var
- ${#var}
- ${var.length}
- ${var:#}
- $(len var)
What does ${var:-default} expand to?
- The literal "default" always
- Returns 1 as exit status
- The value of var if set and non-empty, otherwise the literal "default"
- Sets var to "default" and returns it
- Errors out if var is unset
What does ${var:=default} differ from ${var:-default} in?
- It is identical to :-
- It assigns "default" to var when var is unset/empty, then expands to it
- It exports var globally
- It deletes var if unset
- It is reserved for arrays only
What does ${var:+other} expand to?
- "other" always
- "other" when var is set and non-empty, otherwise empty
- The first word of var
- The length of var
- "other" when var is unset
Related categories
Python (Coding)
Python syntax, standard-library usage, and the language idioms that come up in day-to-day scripting and application work.
JavaScript (Coding)
Core JavaScript language behavior, async patterns, and the quirks that trip up both beginners and experienced developers.
Linux
Linux command-line usage, file permissions, process management, and the everyday admin tasks every sysadmin and developer needs.
Security
General information security concepts — threats, defenses, and the fundamentals every IT professional should know.
Hardware
Computer hardware components, how they interact, and the troubleshooting knowledge behind keeping systems running.