Hey geeks, let’s open the second edition of Shell script quiz. This quiz combines a variety of questions starting from the basic script knowledge, covering several Unix/Linux commands and goes up to asking for the output of a real-time shell script code. With such in-depth coverage of different Linux areas, the quiz will enable the readers in learning the Shell script concept on Unix/Linux platforms. You must note that learning Shell script is not merely a means to clear a Job interview. Instead, knowing it would make you do your work more smartly and efficiently. A shell script can help you in automating your manual tasks like building a project, sharing the build artifacts, deploying builds or managing web servers. You can group all of them into a single shell script.
Hence, there are infinite no. of possibilities that you can explore if you choose to learn shell scripting. And that’s where this shell script quiz will test and report the level of understanding you’ve with this subject. Just for an example, if you compare Windows with an ocean then Linux would be the scale to test the depth of that ocean. This comparison is justified because there are no. of Unix/Linux distributions that let it dominate over Windows. In this quiz, we’ve added several interview questions that should apply to all the frequently used Linux distributions like Ubuntu, RHEL, SUSE, SLES, and CentOS. We request, if you see any anomaly, please use the comment box and do report to us.
Shell script quiz for Unix/Linux geeks.
0 of 30 questions completed
|For your information, please note that this Shell Script Quiz has both single and multiple choice questions. So, we suggest you please carefully attempt all the questions. Press the below Start quiz button to go ahead.|
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading...
You must sign in or sign up to start the quiz.
You have to finish following quiz, to start this quiz:
0 of 30 questions answered correctly
Time has elapsed
You have reached 0 of 0 points, (0)
Hopefully, you have enjoyed the Shell Script Quiz, please do share this post on facebook, twitter and other social media platforms of your choice.
1. Question10 points
What is the output of the following shell command?
echo this || echo that && echo otherCorrectIncorrect
2. Question10 points
Which of the following commands would you use to check if two strings are equal?CorrectIncorrect
Note – The correct answer is “test $a = $b” as it can do both string and integer comparision while the “test $a -eq $b” command would only help to compare the integers.
3. Question10 points
Which of the following ‘sleep’ commands would print its process ID?CorrectIncorrect
4. Question10 points
Which of the following commands would always display “Linux” as output in the shell and all of its subshells?CorrectIncorrect
5. Question10 points
Which of the following code fragments would display “Java” as output?CorrectIncorrect
6. Question10 points
Which of the following loop statements would print exactly ‘onetwothree’ as output?CorrectIncorrect
7. Question10 points
How will you get the 99th line of a file with only tail and head command?CorrectIncorrect
8. Question10 points
Which of the following commands would you use to print only the 10th line?CorrectIncorrect
Note: The right answer is “sed -n “10p” filename” because it’ll print only the 10th line whereas the option “awk ‘NR%10==0’ filename” would print every 10th line.
9. Question10 points
Which of the following commands would help you to find out how long the system has been running?CorrectIncorrect
10. Question10 points
Which of the following commands would help you to count the no. of lines containing the word “ABC” in a given file?CorrectIncorrect
11. Question10 points
Which of the following commands would set the default rwx permission to all users on every file which is created in the current shell?CorrectIncorrect
12. Question10 points
Which of the following commands would return only the process name from its process id (PID)?CorrectIncorrect
13. Question10 points
Which of the following commands would insert a line “Python” at every 10th line of a file?CorrectIncorrect
14. Question10 points
Which of the following commands would you use to open a read-only file?CorrectIncorrect
15. Question10 points
Which of the following commands would help you to stop a process?CorrectIncorrect
16. Question10 points
Which of the following correctly describes the relationship between a shell and the operating system itself?CorrectIncorrect
Note: The shell merely provides an interface to read user input from the keyboard and process commands. Other programs may do the same thing, but the shell is the standard command-line interface in UNIX.
17. Question10 points
Which of the following shell programs is least compatible with the original Bourne shell (sh)?CorrectIncorrect
Note: C shell (csh) uses a different programming syntax and different interactive features, it is least compatible with the Bourne shell. The Korn shell versions (ksh and pdksh) and the bash shell are both based on the original Bourne shell and simply add interactive features without changing the programming style.
18. Question10 points
Which of the following is a disadvantage while programming for the C shell?CorrectIncorrect
Note: C shell is based on C language syntax. It lacks some features that are essential in creating strong shell scripts like strong syntax checking to prevent ambiguous code from creating unexpected results.
19. Question10 points
Which of the following permission types would help you to allow a user entering into a directory present in the file system?CorrectIncorrect
20. Question10 points
A file has a mode of 755. If you don’t own this file and isn’t a member of the group that owns the file, what can you do with it?CorrectIncorrect
21. Question10 points
Which of the following commands would you use to count the total number of lines, words, and characters contained in a file?CorrectIncorrect
22. Question10 points
Which of the following commands would help you to delete a single character in the vi editor?CorrectIncorrect
23. Question10 points
Which of the following commands would not display the list of files chap01, chap02 and chap04?CorrectIncorrect
Note: All the commands listed under the options would display the list of file chap01, chap02, and chap04. So the correct answer is ‘None of these’.
24. Question10 points
Which of the following symbols would you use to back up over typing errors in the vi editor?CorrectIncorrect
25. Question10 points
Which of the following commands would help in sorting the lines of a text file in alphabetical order?CorrectIncorrect
26. Question10 points
Which of the following commands is used with vi editor to save file and remain in the editing mode?CorrectIncorrect
27. Question10 points
Which of the following commands would return the count of the empty lines present in a file?CorrectIncorrect
28. Question10 points
Which of the following commands would get you the content between the line no. 10-20 from a text file?CorrectIncorrect
29. Question10 points
Which of the following statements correctly describes the output of the below Shell script?
#!/bin/sh for token in `echo $*| rev` do echo $token doneCorrectIncorrect
30. Question10 points
If you have a running program called ‘Java’ which is a child of the current shell. You would like to decrease the CPU usage of this program. Which of the following commands would help you in making the ‘Java’ yield more CPU resources?CorrectIncorrect
Note: You can see all the answers at the end of this quiz. To learn more about Linux Shell script or Shell Programming, refer the on-line Shell script documentation.
The Shell script quiz is useful for all software developers and testers who works on Unix/Linux platforms. But we host many top quizzes on Java/Python/Selenium and related programming articles on our blog. Some of them are listed below which you can read and go for an interview with full preparation.
We wish that all the readers would benefit from this quiz in advancing their overall Linux Shell scripting and OS skills. If you like this amazing Shell script quiz online test, then do leave us your response in the comment space below and tell us what you think. We would like to rest you assured that we’ll keep coming up with fresh quizzes on latest topics and will enhance the older ones as well.
In the end, we leave you with an enthralling quote by Linus Torvalds, the father of Linux.
“I’ve never regretted not making Linux shareware. I really don’t like the ‘pay for use’ binary shareware programs.”
If you liked the quiz, then please care to share this post across.