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
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.
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.
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.
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.
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.
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.
Written and edited by Nathan Beja, founder of Practice Test Geeks, with AI assistance. Exam facts are checked against the official sources linked below. Editorial policy
Sources & references
Exam facts on this page (fees, format, dates, passing scores) are checked against these official sources; the date is our last check. Editorial policy
- redhat.com — Test delivery, retake policy, score release, renewal, score validity, exam information · verified Dec 2026