โ† All RHCSA Flashcard Decks

RHCSA Shell Scripting and Automation Flashcards

6 cards from real RHCSA practice questions. Tap to flip, then mark Knew It or Still Learning โ€” missed cards come back until you master them.

Read the first 6 RHCSA Shell Scripting and Automation flashcards as text
  1. Which command redirects both stdout and stderr to a file called `output.log`?

    Answer: command > output.log 2>&1

    Redirecting stdout to a file with `>` and then redirecting stderr (`2>`) to stdout (`&1`) sends both streams to the same file.

  2. In Bash, what does the `test -f /etc/passwd` command check?

    Answer: Whether /etc/passwd exists and is a regular file

    The `-f` flag in `test` returns true if the given path exists and is a regular (non-directory) file.

  3. What does `#!/bin/bash -x` at the top of a script do?

    Answer: Enables debug mode, printing each command before execution

    The `-x` flag enables shell trace mode, printing each command and its arguments to stderr before execution.

  4. Which construct in Bash allows you to define a reusable block of commands?

    Answer: function

    Bash supports defining reusable blocks using the `function` keyword or the `name() { }` syntax.

  5. What is the purpose of `set -e` at the beginning of a Bash script?

    Answer: Exit the script immediately if any command returns a non-zero status

    `set -e` causes the script to exit immediately when any command exits with a non-zero (failure) status.

  6. Which Bash arithmetic syntax correctly computes the sum of variables A and B?

    Answer: $((A + B))

    The `$(( ))` arithmetic expansion performs integer arithmetic directly within Bash without calling external commands.