readyforhires

Advanced Shell Scripting test (Advanced)

40 questions · 40 minutes · Free

Robust scripts, process control and performance.

Take the Advanced Shell Scripting test

What it covers

Interview format

Earn a certificate

The Advanced Shell Scripting test is one of the 8 tests of the DevOps Engineer: Advanced learning path. Pass it and the other 7 tests at 70% or more and readyforhires issues you a verifiable certificate in your name, with its own code and verify link to share or add to LinkedIn.

Sample learning path certificate for DevOps Engineer: Advanced, made out to “Your name” and marked SAMPLE
Pass with 70% or more to earn a verifiable certificate. This is a sample: yours carries your name, the date you earned it and its own verify code.

Sample questions

5 sample questions from the Advanced Shell Scripting test, with the answers. Samples are taken out of the live test, so you will not meet these when you sit it.

  1. What is the correct behavior of the trap command when handling signals in a shell script?

    1. The trap command will execute the specified command when the signal is received, but only if it is explicitly defined in the trap command.
    2. The trap command is only used for terminating processes and does not interact with signals.
    3. The trap command will execute the specified command for all signals, even those not explicitly defined.
    4. The trap command will automatically handle all signals without requiring explicit definitions.

    Answer: A. The trap command will execute the specified command when the signal is received, but only if it is explicitly defined in the trap command.

    The trap command is used in shell scripting to catch signals and execute specified commands when they are received. However, it only works for signals that are explicitly defined in the trap command. The other options either misrepresent the functionality or describe unrelated concepts.

  2. Which of the following best describes the difference between using ShellCheck and using set -x for debugging shell scripts?

    1. Both ShellCheck and set -x are used for static analysis of shell scripts.
    2. set -x is a static analysis tool, while ShellCheck enables dynamic tracing of command execution.
    3. ShellCheck provides static analysis for potential bugs and style issues, while set -x enables dynamic tracing of command execution.
    4. ShellCheck is a runtime tracing tool, while set -x performs static analysis of scripts.

    Answer: C. ShellCheck provides static analysis for potential bugs and style issues, while set -x enables dynamic tracing of command execution.

    ShellCheck is a static analysis tool that checks for potential bugs and style issues in shell scripts before execution, while set -x is a runtime option that prints each command as it is executed, aiding in dynamic debugging. ShellCheck is better suited for catching errors during development, whereas set -x is useful for tracing execution flow at runtime.

  3. Which of the following statements accurately describes the behavior of the fg command in a shell environment?

    1. The fg command brings a stopped job back into the foreground and resumes its execution.
    2. The wait command brings a stopped job back into the foreground and resumes its execution.
    3. The bg command brings a stopped job back into the foreground and resumes its execution.
    4. The jobs command brings a stopped job back into the foreground and resumes its execution.

    Answer: A. The fg command brings a stopped job back into the foreground and resumes its execution.

    The fg command is used to bring a stopped job back into the foreground and resume its execution. The bg command, on the other hand, runs a stopped job in the background. The wait command is used to wait for a background job to complete, and the jobs command lists all current jobs. These commands are essential for managing process execution in shell environments.

  4. What happens when a coproc is used in a Bash script to run a command in parallel?

    1. The coproc process runs in the foreground and does not block the script.
    2. The coproc process runs in the background and can be monitored with wait, but the script continues to execute.
    3. The coproc process runs in the foreground and blocks the script until it completes.
    4. The coproc process runs in the background and cannot be monitored with wait.

    Answer: B. The coproc process runs in the background and can be monitored with wait, but the script continues to execute.

    When using coproc, the command runs in the background as a separate process. The main script continues execution, and the coproc process can be monitored using wait. This is different from foreground processes, which block the script until they complete. The coproc process is not directly tied to the script's execution flow, allowing for parallelism.

  5. Which statement is true regarding variables set inside a subshell?

    1. Variables set inside a subshell are visible to the parent shell only if explicitly exported.
    2. Variables set inside a subshell are shared with the parent shell by default.
    3. Variables set inside a subshell are not visible to the parent shell.
    4. Variables set inside a subshell are automatically exported to the parent shell.

    Answer: C. Variables set inside a subshell are not visible to the parent shell.

    A subshell runs in a separate process, so any variables set or modified inside the subshell are not visible to the parent shell. This is a fundamental aspect of subshell behavior and is important for understanding how environment changes are scoped in shell scripts.

Frequently asked questions

How many questions are in the Advanced Shell Scripting test?
40 questions (24 multiple choice, 16 multi-answer), with 40 minutes to answer them.
What does the Advanced Shell Scripting test cover?
Error handling and traps, Process substitution and subshells, Signals and job control, Portability, Debugging and ShellCheck.
Is the Advanced Shell Scripting test free?
Yes. It is free to take with a readyforhires account.
What level is the Advanced Shell Scripting test?
Advanced, in DevOps & cloud.

More DevOps & cloud tests

Roles that test these skills

Companies that test these skills

All practice tests · All DevOps & cloud tests

Last updated