NDG Linux Essentials 2.21 | Command Line Skills Module 5 | Chapter 05 Exam Answers Full 100% 2023

These are questions of Cisco NDG Linux Essentials 2.21 Command Line Skills Chapter 05 Exam Answers full 100% with the latest version and updated in 2023. All answers are verified by experts with explanations.

  1. Which environment variable contains a list of directories that is searched for commands to execute?

    • PS1
    • PS2
    • EXEC
    • PATH
    • Answers Explanation & Hint:

      The environment variable that contains a list of directories that is searched for commands to execute is PATH.

      When you enter a command in the terminal, the shell searches for that command in the directories listed in the PATH variable. If the command is found in one of the directories, it can be executed directly by typing its name in the terminal. If the command is not found in any of the directories listed in PATH, you will get a “command not found” error.

  2. Select the command that can report the location of a command:

    • what
    • which
    • where
    • Answers Explanation & Hint:

      The command that can report the location of a command in Linux is which.

      The which command is used to locate the binary executable corresponding to the given command in the directories listed in the PATH environment variable. When you run which followed by a command name, it will display the full path to the executable of that command, showing you the location of the command’s binary on the system

  3. A pair of single quotes (') will prevent the shell from interpreting any metacharacter.

    True or False?

    • True
    • False
    • Answers Explanation & Hint:

      A pair of single quotes (') will prevent the shell from interpreting most metacharacters, but it will still allow the shell to interpret single quotes (') themselves. Inside single quotes, variables and most special characters are not expanded or interpreted. This is useful when you want to ensure that a string is treated literally and doesn’t undergo any changes by the shell.

      However, if you need to use single quotes within a single-quoted string, you have to temporarily break out of the single quotes, insert the single quote using other means (e.g., \'), and then re-enter the single quotes.

  4. A pair of double quotes (") will prevent the shell from interpreting any metacharacter.

    True or False?

    • True
    • False
    • Answers Explanation & Hint:

      A pair of double quotes (") will prevent the shell from interpreting some metacharacters, but it allows the shell to interpret variables and certain other metacharacters. Inside double quotes, variables will be expanded, meaning their values will be substituted into the string. However, most other special characters (such as wildcard characters like * or commands enclosed in backticks) are treated literally within double quotes. If you want to prevent all metacharacters from being interpreted and use the string exactly as it is, you would use single quotes (') as mentioned in the previous answer.

  5. Using a pair of back quotes (`) will cause a shell to execute the back-quoted text as a command and substitute the output back into the original command.

    True or False?

    • True
    • False
    • Answers Explanation & Hint:

      Using a pair of back quotes (`) in shell scripting is known as command substitution. When you enclose a command within back quotes, the shell executes that command and substitutes the output of the command back into the original command. Note that the use of backticks for command substitution is an older method, and modern shell scripting encourages using the $() syntax for command substitution, which provides better readability and nesting capabilities.

  6. The semicolon (;) can be used to separate multiple commands to be executed in order.

    True or False?

    • True
    • False
    • Answers Explanation & Hint:

      he semicolon (;) is used in shell scripting to separate multiple commands on a single line. When you use a semicolon to separate commands, the shell will execute each command sequentially, one after the other, in the order they appear on the line.

      For example:

      echo "Hello"; date; ls -l

      In this example, three commands are separated by semicolons. The shell will execute them in the following order:

      1. echo "Hello": Prints “Hello” to the console.
      2. date: Displays the current date and time.
      3. ls -l: Lists the files and directories in the current directory with detailed information.

      The semicolon allows you to chain together multiple commands on a single line, which can be useful for scripting or performing several operations in sequence. However, be mindful of the order of execution, as the commands are run one after the other without any condition or error handling.

  7. The double ampersand characters (&& ) are used to separate commands to be executed conditionally, where if the command to the left of the ampersands fails, then the command to the right of the ampersands will be executed.

    True or False?

    • True
    • False
  8. To be able to output messages to the screen, use the _______ command:

    • type
    • display
    • echo
    • print
  9. The _______ command will print a list of the commands that you’ve previously executed.

    • list
    • eval
    • history
    • exec
  10. To execute the same command as previously executed five commands ago, you would type:

    • @-5
    • &5
    • !-5
    • !5
  11. The shell program interprets the commands you type into the terminal into instructions that the Linux operating system can execute.

    True or False?

    • True
    • False
  12. The acronym CLI stands for:

    • Computer Link Interpreter
    • Command Line Interpreter
    • Command Line Interface
    • Computer Line Interface
  13. What one character treats the character that follows it as if it was surrounded by single quotes?

    • \
    • #
    • /
    • %
  14. The echo command:

    • Tests a variable for duplication
    • Copies variables from one to another
    • Is used to output text to the console
    • Duplicates the input stream to the output stream
    • Is used for variable assignment
  15. The most common shell used for Linux distributions is the ________ shell.

    • Zsh
    • Bash
    • Tsch
    • Fish
  16. HOME is an example of _________.

    • A local variable
    • An environment variable
    • A path variable
    • An internal command
    • An alias
4.7 3 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments