Today, we’ve come up with an interesting Unix Shell scripting quiz featuring 25 best questions to help you learn Unix programming. Both software developers and automation engineers should attempt this quiz and assess their shell scripting knowledge.
We’ve some more interesting Linux quizzes and online tests available here. You may want to check that out as well.
The primary reason to roll out this quiz was to meet the promise that we’ve made to our readers who were asking for a quiz on shell scripting for quite a time. And we’ve tried to add all the relevant Unix shell scripting questions in this quiz to make it as useful as it could be.
Attempt The Quiz And Learn Unix Shell Scripting.
Note: You can view all the answers at the end of this quiz.
Answer Key with Reasoning
Here is a concise reasoning table explaining the correct answers for all 25 Linux-related questions.
Q# | Correct Answer | Reasoning |
---|---|---|
1 | Bash, C shell, Korn shell, Z shell, tcsh, B shell | These are commonly used shells in Linux, providing various scripting capabilities. |
2 | Soft links reference filenames, Hard links reference inodes | Soft links (symbolic) point to file names, while hard links reference inodes (actual data blocks). |
3 | Number of passed arguments | $# in a shell script returns the count of arguments passed to the script. |
4 | 2>&1, &> | Both redirect standard error (stderr ) and standard output (stdout ) together. |
5 | Last command exit status | $? holds the exit status (success or failure) of the last executed command. |
6 | if [ $x -gt $y ] | The correct syntax for numeric comparisons in shell scripting. |
7 | Defines script interpreter, Known as a shebang, Executes script with bash | #!/bin/bash specifies that the script should be executed using the Bash shell. |
8 | sh -x script.sh, sh -nv script.sh | -x enables debugging, -nv checks syntax without executing the script. |
9 | 'read' command | The read command in shell scripts allows user input. |
10 | expr 7 + 3, test=$[12 + 3] | expr and $[] are used for arithmetic operations in shell scripts. |
11 | function test() {}, test() { return 1; } | Both syntaxes correctly define functions in shell scripts. |
12 | $$ = Current process ID, $! = Last background process | $$ gives the current shell’s process ID, while $! stores the PID of the last background process. |
13 | ftp, scp, rsync | ftp , scp , and rsync are used to transfer files between machines. |
14 | telnet, ssh | telnet and ssh allow executing commands on remote machines. |
15 | Replaces current shell process | exec replaces the current shell process with the specified command instead of starting a new one. |
16 | Disk block | Linux filesystems do not use a block specifically named “Disk block”; they use data, inode, and superblocks. |
17 | Super block | The superblock contains metadata about the filesystem, such as size and state. |
18 | Boot block | The boot block contains the Master Boot Record (MBR), which is essential for system startup. |
19 | array=("Hello" "World") | This is the correct syntax to define an array in Bash. |
20 | echo ${array[0]} | In Bash, ${array[0]} accesses the first element of an array. |
21 | echo ${array[@]} | ${array[@]} prints all elements of an array. |
22 | echo ${!array[@]} | ${!array[@]} returns all indexes of the array. |
23 | unset array[3] | The unset command removes an element from an array in Bash. |
24 | array[99]="New_element" | This syntax correctly assigns a new value at index 99 in a Bash array. |
25 | uptime | The uptime command shows how long the system has been running. |
This table provides quick and precise reasoning for each correct answer while ensuring technical accuracy.
Key Takeaways from Unix Shell Scripting Quiz
Interested software developers and test automation engineers are welcome to refer to our lately published posts on Python.
We wish that this quiz would help both software developers and testers in sharpening their overall Unix operating systems skills.
Next, we expect that all software developers and automation test engineers would have fun trying the quiz and appreciate us for coming out with such a post. Rest assured that we’ll keep coming up with new quizzes on new subjects and will update the earlier ones as well.
You can also support our knowledge campaign by sharing this post with your friends and on social media platforms.
All the Best,
TechBeamers