Practice Exam: Shells and Shell Scripting
Simulator Summary
0 of 80 Questions completed
Questions:
Information
You have already completed the simulator before. Hence you can not start it again.
Simulator is loading…
You must sign in or sign up to start the simulator.
You must first complete the following:
Results
Results
0 of 80 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%
-
Unfortunately, your results in the simulator were not up to the desired standards. π
However, take advantage of your unlimited access and continue to practice.
Remember, persistence and dedication will lead to mastery. π -
Congratulations! π
You have successfully passed the simulator and are now one step closer to achieving your certification.
We hope you will consider joining us again in your future certification journey.Wishing you the best of luck with the upcoming exam. Keep up the great work! πͺ
- 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
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- Current
- Review
- Answered
- Correct
- Incorrect
-
Question 1 of 80
1. Question
A user wants to permanently add a custom directory /custom/bin to their PATH environment variable so that it’s available every time they spawn a new shell. Which file should the user modify in their home directory?
CorrectIncorrect -
Question 2 of 80
2. Question
A user has set an environment variable in both ~/.bashrc and ~/.bash_profile. When spawning a new interactive non-login shell, which file’s environment setting will be used?
CorrectIncorrect -
Question 3 of 80
3. Question
A system administrator wants to create a Bash function to display the total disk usage of the /home directory. Which of the following functions will accurately achieve this?
CorrectIncorrect -
Question 4 of 80
4. Question
Jane wants to create a Bash function that checks the number of files in her projects directory and then displays the count. Which of the following functions would accomplish this task?
CorrectIncorrect -
Question 5 of 80
5. Question
When creating a new user on a Linux system, the administrator wants the user to have a predefined set of files and directories in their home directory. Which directory should the administrator modify to achieve this?
CorrectIncorrect -
Question 6 of 80
6. Question
An administrator wants to ensure that every new user on the system gets a welcome message file named “welcome.txt” in their home directory upon account creation. Which of the following actions would achieve this?
CorrectIncorrect -
Question 7 of 80
7. Question
Tom has a custom script named myscript located in /home/tom/scripts/. He wants to run this script from any location without specifying the full path. Which command should Tom use to temporarily add the script’s directory to the command search path?
CorrectIncorrect -
Question 8 of 80
8. Question
Linda has downloaded a third-party tool named toolX which is located in /opt/tools/. She wishes to use this tool from any location in the terminal. To achieve this permanently for her user, where should she set the command search path?
CorrectIncorrect -
Question 9 of 80
9. Question
Alice has created a script named env_setup.sh that exports certain environment variables. She wants these variables to be available in her current shell session without starting a new one. Which command should Alice use to achieve this?
CorrectIncorrect -
Question 10 of 80
10. Question
John wants to use a function defined in a file named functions.sh within his current shell session. Which action would correctly load and make available the function from functions.sh?
CorrectIncorrect -
Question 11 of 80
11. Question
An administrator wants to set a global alias for all users when they use the Bash shell. To which file should the administrator add this alias to ensure that it’s available for all users?
CorrectIncorrect -
Question 12 of 80
12. Question
Jane has noticed that every time she opens a new terminal, a custom welcome message is displayed. The behavior is consistent across all users on the system. Which file is most likely responsible for this behavior?
CorrectIncorrect -
Question 13 of 80
13. Question
A system administrator wants to set a global PATH variable that will be applied whenever any user logs into the system. In which file should the administrator set this PATH variable to achieve the desired behavior?
CorrectIncorrect -
Question 14 of 80
14. Question
Mike noticed that every time he logs into the system via SSH, a system-wide message about maintenance is displayed. If this message is displayed due to a shell script, which file is most likely responsible for displaying this message to all users upon login?
CorrectIncorrect -
Question 15 of 80
15. Question
A system administrator wants to execute a script named myscript.sh using a specific environment variable setting without affecting the current environment. Which command would allow them to achieve this?
CorrectIncorrect -
Question 16 of 80
16. Question
A developer wants to display the value of a specific environment variable, PROJECT_PATH. Which command should the developer use to view only the value of this environment variable?
CorrectIncorrect -
Question 17 of 80
17. Question
Alice sets a shell variable named DEVELOPMENT_MODE in her current shell. She wants to make sure that any programs or scripts she runs from this shell can access this variable. Which command should she use?
CorrectIncorrect -
Question 18 of 80
18. Question
Bob is troubleshooting an issue with a script. He notices that an environment variable named CONFIG_PATH is not being recognized inside the script. Which of the following commands can Bob use in the terminal before running the script to ensure CONFIG_PATH is exported and accessible to the script?
CorrectIncorrect -
Question 19 of 80
19. Question
In a script, Jane wants to ensure that any variables she sets remain local to the function they are defined in, and she wants to display error messages when uninitialized variables are referenced. Which command should she use within the function?
CorrectIncorrect -
Question 20 of 80
20. Question
Mike is debugging a shell script. He wants to print each command and its arguments to the terminal as they are executed. Which of the following commands should he use at the beginning of his script?
CorrectIncorrect -
Question 21 of 80
21. Question
Liam has a script where he has defined an environmental variable named PROJECT_DIR. Midway through the script, he realizes he no longer requires this variable. Which command will help Liam unset or remove this environmental variable?
CorrectIncorrect -
Question 22 of 80
22. Question
Emily is writing a script and at one point she wants to ensure that the function update_project is no longer available for the rest of the script. Which command should she use?
CorrectIncorrect -
Question 23 of 80
23. Question
Maria is troubleshooting a Linux workstation for John, who is having issues with his shell environment. She suspects an issue with one of the initialization files for Bash. Which file is sourced by the Bash shell when John logs in via the graphical user interface (GUI)?
CorrectIncorrect -
Question 24 of 80
24. Question
Alex wants to add a command that should run each time he starts a new login shell session. In which file should he add this command to ensure it gets executed every time he logs in through a terminal?
CorrectIncorrect -
Question 25 of 80
25. Question
Jacob is trying to modify the behavior of his Bash shell every time he logs in via a terminal. He recalls there being a file that Bash checks when initializing a login shell. Which file will be sourced by Bash if it exists and ~/.bash_profile does not exist?
CorrectIncorrect -
Question 26 of 80
26. Question
Lisa wants to add some configurations that should only be applied when she logs into her system. She knows about ~/.bash_profile but for some reason, she doesn’t want to use it. Which of the following files can she use as an alternative to ~/.bash_profile for login shells?
CorrectIncorrect -
Question 27 of 80
27. Question
Nina is trying to ensure that certain environment settings are applied for her user every time she starts a login shell, regardless of the shell being used. Which file should she consider editing to make these settings apply even if she’s not using the Bash shell?
CorrectIncorrect -
Question 28 of 80
28. Question
Michael wants to ensure that specific environment variables are set up whenever he logs into any Unix-like system using any Bourne-compatible shell. He’s unsure about the specific file he should modify for this purpose. Which file is traditionally used to initialize settings for login sessions of Bourne-compatible shells?
CorrectIncorrect -
Question 29 of 80
29. Question
Alex is configuring his Linux environment and wants to ensure that his shell prompt (PS1) changes to display the current working directory whenever he opens a new terminal. Which file in his home directory should he edit to make this modification so it affects only non-login interactive Bash shells he starts?
CorrectIncorrect -
Question 30 of 80
30. Question
Samantha is a developer who often needs to run scripts located in the ~/projects/scripts/ directory. She wants to make sure that every time she starts a new terminal session, this directory is automatically added to the PATH. Which user-specific file should she modify to ensure this change is persistent across all her non-login interactive Bash sessions?
CorrectIncorrect -
Question 31 of 80
31. Question
Jamie has been noticing that whenever he logs out of his Bash login shell, a custom message appears thanking him for his work. He wishes to find out which file is being executed to display this message. Which user-specific configuration file should he check?
CorrectIncorrect -
Question 32 of 80
32. Question
Lea wants to ensure that every time she logs out from her Bash login shell, any temporary files in her ~/temp directory are deleted automatically. In which user-specific file should she place the commands to accomplish this?
CorrectIncorrect -
Question 33 of 80
33. Question
Samantha has a requirement where she needs to frequently check the disk usage of a specific directory and send an email to the admin if the disk usage exceeds 90%. Instead of writing the same commands over and over, she wishes to encapsulate them into a single unit for reusability. Which of the following is the best way for her to achieve this in her shell scripts?
CorrectIncorrect -
Question 34 of 80
34. Question
Gregory is writing a shell script and he wants to create a reusable component that can compute the sum of two numbers and then display the result. Which of the following constructs in Bash will allow him to do this most effectively?
CorrectIncorrect -
Question 35 of 80
35. Question
While auditing a system, Jeremy notices that every time he types the command ls, the output is colorized, showing directories in blue and executable files in green. He suspects this is not the default behavior of the ls command. What could be the most probable reason for this behavior?
CorrectIncorrect -
Question 36 of 80
36. Question
Martha frequently uses the command grep -i -r ‘pattern’ . to search for a case-insensitive pattern recursively in the current directory. To simplify this task, she wants a shortcut for this command. What should she do to achieve this?
CorrectIncorrect -
Question 37 of 80
37. Question
Lucy is writing a shell script where she wants to print numbers from 1 to 5 using a loop. Which of the following loop constructs would correctly achieve this in a standard sh shell?
CorrectIncorrect -
Question 38 of 80
38. Question
Alex needs to process a list of file names stored in a file called filelist.txt, where each file name is on a new line. He wants to use a loop to read each file name and then process it. Which of the following loop constructs in standard sh would allow Alex to achieve this?
CorrectIncorrect -
Question 39 of 80
39. Question
Jenna wants to check if a given variable x contains an integer value greater than 10 in her sh script. Which of the following tests will achieve this?
CorrectIncorrect -
Question 40 of 80
40. Question
Martin is writing a script where he needs to check if a file, represented by the variable $myfile, exists and is a regular file. Which of the following tests will provide the correct result in a standard sh script?
CorrectIncorrect -
Question 41 of 80
41. Question
Which of the following commands uses command substitution to assign the list of files in the /etc/ directory to a variable named FILES?
CorrectIncorrect -
Question 42 of 80
42. Question
Which command would you use to display the number of lines in a file named myfile.txt using command substitution?
CorrectIncorrect -
Question 43 of 80
43. Question
You’ve written a script that executes a command, and you want to check if the command was successful. Which of the following can be used immediately after the command to get its return value?
CorrectIncorrect -
Question 44 of 80
44. Question
A system administrator wants to ensure a backup script only proceeds if the previous command was successful. Which of the following lines will allow the script to continue execution only if the previous command was successful?
CorrectIncorrect -
Question 45 of 80
45. Question
A system administrator wants to execute a command that checks the disk usage of the /home directory and then, only if that command is successful, archives the directory into a tarball named home_backup.tar.gz. Which of the following commands accomplishes this?
CorrectIncorrect -
Question 46 of 80
46. Question
In a script, a developer wants to ensure that a directory named tempdata is deleted, and after that, a new directory with the same name is created. Which of the following commands accomplishes this chain of commands?
CorrectIncorrect -
Question 47 of 80
47. Question
A system administrator wants to send an email to the superuser only if a specific file, server.log, exceeds 1GB in size. Which of the following commands would achieve this by sending a message titled “File Alert”?
CorrectIncorrect -
Question 48 of 80
48. Question
A system administrator writes a script to monitor the available disk space on the root directory. If the available space drops below 5%, an email should be sent to the superuser. Which of the following lines can be added to the script for this purpose?
CorrectIncorrect -
Question 49 of 80
49. Question
A developer wants to write a shell script that should specifically be interpreted using the Bourne Again Shell (bash). Which shebang line should be placed at the beginning of the script to ensure this?
CorrectIncorrect -
Question 50 of 80
50. Question
A system administrator has a Python script that needs to be executed using Python 3. What shebang line should the admin use to make sure the script is interpreted by Python 3 even if Python 2 is also installed on the system?
CorrectIncorrect -
Question 51 of 80
51. Question
A system administrator has written a script called manage_users.sh and wants to place it in a directory where all system administrators can run it but regular users cannot. If the script is currently located in the administrator’s home directory, which of the following commands should the administrator use?
CorrectIncorrect -
Question 52 of 80
52. Question
A script named data_processor.sh processes sensitive data and creates a report. To ensure that the script has access to read the data files even if the administrator running it does not, the script needs to be executed with the file owner’s permissions. Which command should be used to achieve this?
CorrectIncorrect -
Question 53 of 80
53. Question
A system administrator wants to list all the .txt files in a directory and print their names prefixed with “FILE:”. Which of the following for loops will accomplish this?
CorrectIncorrect -
Question 54 of 80
54. Question
A developer is writing a bash script to iterate over a list of user names provided as arguments to the script and create a home directory for each of them. Which of the following for loops will correctly serve this purpose?
CorrectIncorrect -
Question 55 of 80
55. Question
A system administrator wants to monitor a directory and display a message whenever the number of .log files exceeds 10. Which of the following while loops can be used to accomplish this in a shell script?
CorrectIncorrect -
Question 56 of 80
56. Question
A developer wants to read input from a user in a script until the user enters “exit”. Which of the following while loops will serve this purpose?
CorrectIncorrect -
Question 57 of 80
57. Question
An administrator is writing a script to verify if a given file, "/etc/passwd", is readable. Which of the following commands will correctly perform this test?
CorrectIncorrect -
Question 58 of 80
58. Question
In a shell script, a developer needs to determine if a variable $count holds a value greater than 10. Which of the following expressions with the test command is suitable for this?
CorrectIncorrect -
Question 59 of 80
59. Question
A system administrator wants to write a script that checks if the /etc/passwd file exists. If the file exists, the script should echo "File exists". Which of the following scripts will achieve this?
CorrectIncorrect -
Question 60 of 80
60. Question
In a script, a developer wants to verify if a user-provided number $num is less than or equal to 100. If true, the script should print "Valid number". Which of the following script segments will achieve this?
CorrectIncorrect -
Question 61 of 80
61. Question
A system administrator is writing a script to take user input for a file name and then display the contents of the file. Which of the following script segments correctly captures user input and then displays the file content?
CorrectIncorrect -
Question 62 of 80
62. Question
In a script, a developer wants to get two inputs from the user: a username and an email. The user should be prompted for each input separately. Which of the following achieves this task?
CorrectIncorrect -
Question 63 of 80
63. Question
A system administrator wants to generate a sequence of numbers from 3 to 15 in a script. Which command will correctly generate this sequence?
CorrectIncorrect -
Question 64 of 80
64. Question
In a shell script, a developer wants to generate a sequence of even numbers from 2 to 10. Which of the following commands can achieve this?
CorrectIncorrect -
Question 65 of 80
65. Question
In a script, a system administrator wants to replace the current process with a new process, executing the top command without creating a new process ID. Which command should they use?
CorrectIncorrect -
Question 66 of 80
66. Question
A developer wants to change the current shell in a script to a Python interpreter. However, they want this change to use the current process ID rather than spawning a new one. Which command can achieve this?
CorrectIncorrect -
Question 67 of 80
67. Question
A junior system administrator is trying to display the content of a file named log.txt. If the file doesn't exist, they want to display a message saying "File not found". Which command should they use?
CorrectIncorrect -
Question 68 of 80
68. Question
An administrator wants to try downloading a file using wget. If the wget command fails, they want to use curl as a fallback. Which is the correct command to achieve this?
CorrectIncorrect -
Question 69 of 80
69. Question
In a shell script, what does the "&&" operator accomplish when used between two commands?
CorrectIncorrect -
Question 70 of 80
70. Question
Consider the following command sequence: cd /etc && ls. What will this command sequence accomplish?
CorrectIncorrect -
Question 71 of 80
71. Question
Alex is a systems administrator who wants to ensure that a script he wrote, backup.sh, can only be executed by the root user. He places the script in /usr/local/bin. Which command should Alex use to set the appropriate ownership and permissions?
CorrectIncorrect -
Question 72 of 80
72. Question
Jamie is writing a script, network_info.sh, that will fetch sensitive network configurations. She wants this script to run with the permissions of the owner, even when executed by another user. Which command should Jamie use to set the suid bit on the script?
CorrectIncorrect -
Question 73 of 80
73. Question
Rebecca is writing a shell script to print numbers 1 through 5 using a while loop. Which of the following scripts accomplishes this task correctly?
CorrectIncorrect -
Question 74 of 80
74. Question
Mike wants to read each line of a file named data.txt and print it to the console using a while loop. Which of the following scripts will correctly achieve this?
CorrectIncorrect -
Question 75 of 80
75. Question
Alice wants to first execute the mkdir newdir command and only if it succeeds, she wants to move into that directory using cd newdir. Which of the following commands would Alice need to use to achieve this?
CorrectIncorrect -
Question 76 of 80
76. Question
Ben is troubleshooting a server. He wants to attempt to restart the network service and, whether it succeeds or fails, he wants to check the status of the service immediately afterward. Which of the following command sequences accomplishes this?
CorrectIncorrect -
Question 77 of 80
77. Question
Jasmine is a system administrator and wants to receive an email every time the /var/log/syslog file grows larger than 500MB. Which of the following commands, when placed in a cron job, would achieve this?
CorrectIncorrect -
Question 78 of 80
78. Question
Roberto wants to be notified if the number of users currently logged into the system exceeds 10. How can he achieve this through a script command?
CorrectIncorrect -
Question 79 of 80
79. Question
You are reviewing a script written by a colleague that is intended to be executed using the Bash shell. However, the script is not running as expected. Which of the following shebang lines should be at the beginning of the script to ensure it is executed with Bash?
CorrectIncorrect -
Question 80 of 80
80. Question
Jane is writing a script that should be executed with the default system shell. What shebang line should she use at the start of her script?
CorrectIncorrect