Quiz Summary
0 of 50 Questions completed
Questions:
Information
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 must first complete the following:
Results
Results
0 of 50 Questions answered correctly
Your time:
Time has elapsed
You have reached 0 of 0 point(s), (0)
Earned Point(s): 0 of 0, (0)
0 Essay(s) Pending (Possible Point(s): 0)
Categories
- Not categorized 0%
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- Current
- Review
- Answered
- Correct
- Incorrect
-
Question 1 of 50
1. Question
You want to create a shell script that counts the number of files in a directory and displays the total count at the end using a while loop. Which of the following code snippets accomplishes this task?
CorrectIncorrect -
Question 2 of 50
2. Question
A system administrator needs to write a shell script to iterate through a list of files in a directory and perform a certain action on each file. Which of the following loops should the administrator use?
CorrectIncorrect -
Question 3 of 50
3. Question
You need to create a shell script that will keep prompting a user for input until they enter a number between 1 and 10. Which loop would be the most appropriate to use for this task?
CorrectIncorrect -
Question 4 of 50
4. Question
You want to write a shell script to check if a file exists in the current directory. If the file exists, you want to print a message saying “File exists”, and if the file does not exist, you want to create the file and then print the message “File created”. Which of the following code snippets correctly implements this logic?
CorrectIncorrect -
Question 5 of 50
5. Question
You are creating a shell script to check the status of a service on a Linux system. If the service is running, the script should display “Service is running” on the console, and if the service is stopped, it should display “Service is stopped”. Which of the following shell script elements should you use to accomplish this task?
CorrectIncorrect -
Question 6 of 50
6. Question
You need to write a script that will delete all files in a directory with a .txt extension, except for one file named “important.txt”. Which of the following is the correct globbing pattern to use in this scenario?
CorrectIncorrect -
Question 7 of 50
7. Question
You are a Linux system administrator and you want to create a script that generates filenames with a sequence of numbers. Which brace expansion will generate filenames with numbers from 1 to 10?
CorrectIncorrect -
Question 8 of 50
8. Question
You want to write a shell script that checks if a given number is greater than 10. Which of the following is the correct arithmetic comparison using shell parameter expansion?
CorrectIncorrect -
Question 9 of 50
9. Question
You need to write a shell script that checks whether a given string is a palindrome or not. Which of the following parameter expansions can be used to check this condition?
CorrectIncorrect -
Question 10 of 50
10. Question
A script is required to check if a file exists and is readable. Which parameter expansion should be used to accomplish this?
CorrectIncorrect -
Question 11 of 50
11. Question
You want to create a script that will display the hostname and the current user’s home directory. Which shell parameter expansion should you use to accomplish this?
CorrectIncorrect -
Question 12 of 50
12. Question
You have a text file called test.txt containing the following line: “The quick brown fox jumps over the lazy dog”. You want to replace the word “lazy” with “smart” in the file using shell parameter expansion. Which of the following commands can you use?
CorrectIncorrect -
Question 13 of 50
13. Question
You have a file containing a list of email addresses, and you want to extract all the email addresses that end with “.com”. Which of the following shell parameter expansions using regular expressions can you use to accomplish this task?
CorrectIncorrect -
Question 14 of 50
14. Question
You need to run a script and redirect its standard output to a file. Which of the following commands should you use?
CorrectIncorrect -
Question 15 of 50
15. Question
In a script, you want to execute a command only if a previous command fails. Which shell operator should you use?
CorrectIncorrect -
Question 16 of 50
16. Question
You have a shell script that you want to redirect the standard output to a file called “output.txt”. Which of the following commands should you use?
CorrectIncorrect -
Question 17 of 50
17. Question
You need to append the output of a command to an existing file without overwriting its contents. Which shell parameter expansion should you use?
CorrectIncorrect -
Question 18 of 50
18. Question
A user wants to read data from a file called “data.txt” using standard input. Which shell parameter expansion would they use to achieve this?
CorrectIncorrect -
Question 19 of 50
19. Question
A Linux system administrator wants to read input from a file and pass it as input to a command. Which shell parameter expansion should they use?
CorrectIncorrect -
Question 20 of 50
20. Question
You are writing a shell script that runs multiple commands in the background. Which operator do you use to run the command in the background and still allow the script to continue running other commands?
CorrectIncorrect -
Question 21 of 50
21. Question
John wants to write a shell script that checks if a file named “data.txt” exists in the current directory. If it does, it should print “File exists” to the console. If it doesn’t, it should create the file and write “Hello, World!” to it. Which of the following shell command options should John use?
CorrectIncorrect -
Question 22 of 50
22. Question
You want to redirect the output of a command to a file named “output.txt” in the current working directory. Which of the following shell redirection operators should you use?
CorrectIncorrect -
Question 23 of 50
23. Question
You are working on a shell script that performs various operations on a file. You want to redirect any error messages that occur during the execution of the script to a separate file named “errors.log”. Which shell parameter expansion can you use to accomplish this?
CorrectIncorrect -
Question 24 of 50
24. Question
A system administrator wants to redirect the standard output of a command to a file named “output.txt” in the current directory. Which of the following commands will achieve this?
CorrectIncorrect -
Question 25 of 50
25. Question
You want to create a shell script that takes user input and writes it to a file using a Here document. Which of the following is the correct syntax for Here documents?
CorrectIncorrect -
Question 26 of 50
26. Question
You are writing a shell script that performs some operations on a file. You want to ensure that the script exits with a code of 0 if the file exists and is readable, and with a code of 1 if the file doesn’t exist or is not readable. Which of the following shell parameter expansions can be used to achieve this?
CorrectIncorrect -
Question 27 of 50
27. Question
You want to create a shell script that prompts the user to enter their name and age and stores the values in variables. Which built-in command should you use in the script to achieve this?
CorrectIncorrect -
Question 28 of 50
28. Question
You are tasked to create a script that displays the text “Hello World” in red color on the terminal. Which of the following options will achieve this using the echo command?
CorrectIncorrect -
Question 29 of 50
29. Question
Which of the following commands is used to read and execute commands from the filename passed as an argument in the current shell environment?
CorrectIncorrect -
Question 30 of 50
30. Question
Which of the following is a valid example of a for loop in shell scripting?
CorrectIncorrect -
Question 31 of 50
31. Question
What are some common tasks related to “Conditional: case” that can be automated through the creation of simple shell scripts?
A script needs to take different actions depending on the value of a variable named “fruit”. Which conditional statement is most appropriate for this task?
CorrectIncorrect -
Question 32 of 50
32. Question
You need to extract the third column from a tab-separated file and output it to a new file. Which awk command should you use?
CorrectIncorrect -
Question 33 of 50
33. Question
You have a file named “data.txt” with the following content:
John,20,5.5
Samantha,25,6.2
Michael,18,5.9You need to replace all occurrences of the string “John” with “Jonathan”. Which command can you use to accomplish this using sed?
CorrectIncorrect -
Question 34 of 50
34. Question
You need to find all files with the extension “.txt” in the “/home/user/docs” directory and its subdirectories, and then run a command on each file. Which command can you use in your shell script to achieve this?
CorrectIncorrect -
Question 35 of 50
35. Question
You need to delete all files in a directory that are older than a certain date. Which of the following commands would you use with xargs to accomplish this task?
CorrectIncorrect -
Question 36 of 50
36. Question
You need to search a log file for all occurrences of the word “ERROR” and output the results to a new file. Which command should you use?
CorrectIncorrect -
Question 37 of 50
37. Question
In a script, you need to search for all the lines that contain a word starting with “c” and ending with “t”. Which of the following options will help you achieve this?
CorrectIncorrect -
Question 38 of 50
38. Question
You are writing a shell script that needs to redirect both the stdout and stderr output to a file while still displaying it on the screen. Which common script utility can you use to accomplish this task?
CorrectIncorrect -
Question 39 of 50
39. Question
A system administrator wants to count the number of lines, words, and characters in a file named “data.txt” using the wc command. Which of the following commands should be used?
CorrectIncorrect -
Question 40 of 50
40. Question
You have a file named “grades.txt” with the following content:
John 92
Marry 88
Alex 78
Eric 81You need to extract only the names from the file and store them in a new file named “names.txt”. Which of the following commands should you use?
CorrectIncorrect -
Question 41 of 50
41. Question
A system administrator wants to extract the second field from a colon-separated file. Which utility can they use to accomplish this task?
CorrectIncorrect -
Question 42 of 50
42. Question
You need to remove all digits from a file named “data.txt” and output the result to a new file named “output.txt”. Which command should you use?
CorrectIncorrect -
Question 43 of 50
43. Question
A system administrator wants to view the first 20 lines of a log file named “access.log” on a Linux server. Which of the following commands can be used to achieve this?
CorrectIncorrect -
Question 44 of 50
44. Question
You need to create a shell script that extracts the last 10 lines of a log file and writes them to a new file. Which command or utility should you use to accomplish this task?
CorrectIncorrect -
Question 45 of 50
45. Question
A user needs to run a custom script located in the /home/user/scripts directory without specifying the full path every time they want to run it. What can they do to accomplish this?
CorrectIncorrect -
Question 46 of 50
46. Question
In a shell script, you need to execute a command with elevated privileges. Which environment variable specifies the location of the sudo utility?
CorrectIncorrect -
Question 47 of 50
47. Question
You are creating a shell script to automate a backup process that involves copying several files from one directory to another. You want to include error handling in your script to detect whether any of the copy operations fail. Which environment variable should you use to check the status of the most recently executed command?
CorrectIncorrect -
Question 48 of 50
48. Question
A user wants to navigate to a directory called “documents” located inside the home directory. Which of the following commands can be used to achieve this?
CorrectIncorrect -
Question 49 of 50
49. Question
You need to stop a running container named “webapp” on your system. Which command should you use?
CorrectIncorrect -
Question 50 of 50
50. Question
You need to inspect the network activity of a running container in Docker. Which command should you use?
CorrectIncorrect