Bash Quiz
Fast practice, instant feedback. Timer auto-submits when time’s up.
Avg score: 74% Most missed: “Which variable would you check to verify that the last command executed successf…”

MCQs For LinkedIn Skill Assessments. Bash is a Unix shell and command language.

Bash Quiz
Time left 00:00
25 Questions

1. Given a directory with these seven files, what would remain after executing these commands?
'''bash
archive.tar
image1.gif
image1.jpg
image2.gif
image2.jpg
textfile1.txt
textfile2.txt
----------
'shopt -s extglob
rm !(*gif|*jpg)'
2. To run a group of commands without spawning a subshell, which syntax would you use?
3. Which one is true?
4. Using Bash extended globbing, what will be the output of this command?
'''bash
$ ls -l
apple
banana
bananapple
banapple
pineapple
strawberry
$ shopt -s extglob
$ ls -l @(ba*(na)|a+(p)le)
5. What does this script accomplish?
'''bash
#!/bin/bash
declare -A ARRAY=([user1]=bob [user2]=ted [user3]=sally)
KEYS=(${!ARRAY[@]})
for (( i=0; $i < ${#ARRAY[@]}; i+=1 ));do
echo ${KEYS[$i]} - ${ARRAY[${KEYS[$i]}]}
done
6. What is the output of this code?
'''bash
VAR='/var/www/html/website.com/html/'
echo '${VAR#*/html}'
7. Which does the below command do?
'''bash
w
8. How would you find the last copy command run in your history?
9. What is the result of this script?
'''bash
txt=Penguins
[[ $txt =~ [a-z]{8} ]]; echo $?
10. What is the result of this script?
11. How would you change your Bash shell prompt to the following?
'''bash
HAL>
12. How could you get a list of all .html files in your tree?
13. Which statement will print all of the fully qualified .cvs files in the home directory or subdirectories while not displaying any errors?
14. What statement would you use to print this in the console?
'Shall we play a game? yes\no'
15. What does the asterisk represent in this statement?
'''bash
#!/usr/bin/env bash
case $num in
1)
echo 'one'
; ;
2)
echo 'two'
; ;
*)
echo 'a mystery'
; ;
esac
16. Wich operator sends the output of ls to a file for later use?
17. How does the SUID or setuid affect executable commands?
18. The shell looks at the contents of a particular variable to identify which programs it can run. What is the name of this variable?
19. What are the results of the command with a user named jon?
'''bash
echo 'Hello, $(whoami)!'
20. Which of the three methods will copy the directory named 'photo dir' recursively from the user's home directory to /backups?
'''bash
cp -R '~/photo dir' /backups #method1
cp -R ~'/photo dir' /backups #method2
cp -R ~/'photo dir' /backups #method3
21. Which statement checks whether the variable num is greater than five?
22. In order for a Bash script to be executed like an OS command, it should start with a shebang line. What does this look like?
23. To make a Bash script named script.sh executable, what should you run?
24. What will be the output of this script?
25. For the script to print 'Is numeric' on screen, what would the user have to enter when prompted?
'''bash
#!/bin/bash
read -p 'Enter text ' var
if [[ '$var' =~ '^[0-9]+$' ]];then
echo 'Is numeric'
else
echo 'Is not numeric'
fi