โ† All LCA Flashcard Decks

Shell Scripting & Automation Flashcards

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

Read the first 7 Shell Scripting & Automation flashcards as text
  1. Which bash option enables strict mode by catching unset variable references?

    Answer: set -u

    `set -u` (or `set -o nounset`) causes the shell to treat unset variables as an error and exit.

  2. What does `set -o pipefail` change about pipeline exit status?

    Answer: The pipeline returns the exit status of the last failed command, not just the last command

    Without `pipefail`, a pipeline's exit status is the last command's status; with it, any failure in the pipeline propagates.

  3. In bash, what is a here-document used for?

    Answer: Providing multi-line input to a command inline in the script

    A here-document (`<< DELIMITER ... DELIMITER`) feeds multiple lines of text directly as stdin to a command without needing a separate file.

  4. Which command schedules a one-time job to run at 3:00 AM tonight on a Linux system?

    Answer: echo 'command' | at 03:00

    The `at` command schedules one-time tasks; you pipe the command to `at` with a time argument.

  5. What is the correct way to source a file named `config.sh` in the current shell?

    Answer: . config.sh

    The dot (`.`) command or `source` built-in reads and executes commands from the file in the current shell environment.

  6. Which tool is best suited for parsing and transforming structured text using field separators in a shell pipeline?

    Answer: awk

    awk is designed for field-based text processing and supports custom field separators with the -F option.

  7. What does `nohup script.sh &` accomplish?

    Answer: Runs the script in the background, immune to hangup signals when the terminal closes

    `nohup` ignores the SIGHUP signal, and `&` backgrounds the process so it continues after logout.