💻 Scripting and Automation - LINUXPLUS Practice Questions

Write Bash scripts, use regular expressions, automate tasks with cron, and manage system automation.

5Questions Available
1Exam Domains

Practice Scripting Questions Now

Start a timed practice session focusing on Scripting and Automation topics from the LINUXPLUS question bank.

Start LINUXPLUS Practice Quiz →

LINUXPLUS Scripting Question Bank (5 Questions)

Browse all 5 practice questions covering Scripting and Automation for the LINUXPLUS certification exam. Each question includes the full answer and a detailed explanation to help you understand the concepts.

  1. Question 1Automation & Scripting

    In a bash script, which construct correctly tests if a file exists and is a regular file?

    Aif [ -f /path/to/file ]; then
    Bif [ -e /path/to/file ]; then
    Cif [ -d /path/to/file ]; then
    Dif [ -r /path/to/file ]; then
    Show Answer & Explanation
    Correct Answer: A
    Explanation:

    The -f test operator checks if the path exists and is a regular file. -e checks for existence (any type), -d checks for a directory, and -r checks for read permission. For scripts that specifically need regular files, -f is the correct choice.

  2. Question 2Select All That ApplyAutomation & Scripting

    Which 'set' options improve error handling in a bash script? (Choose two.)

    Aset -e exits on any command failure
    Bset -u treats unset variables as errors
    Cset -x exports all variables to child processes
    Dset -a enables extended globbing
    Show Answer & Explanation
    Correct Answers: A, B
    Explanation:

    set -e exits the script on non-zero return codes, and set -u raises an error when an unset variable is referenced. Together they catch common scripting bugs. set -x enables command tracing (debug output), and set -a marks variables for export.

  3. Question 3Automation & Scripting

    Which variable contains the exit status of the last executed command in bash?

    A$?
    B$!
    C$#
    D$$
    Show Answer & Explanation
    Correct Answer: A
    Explanation:

    $? holds the exit status of the most recently executed foreground command. $! holds the PID of the last background process, $# contains the number of positional parameters, and $$ contains the current shell's PID.

  4. Question 4Automation & Scripting

    Which command edits the current user's crontab file?

    Acrontab -e
    Bvi /etc/crontab
    Ccron --edit
    Dsystemctl edit crond
    Show Answer & Explanation
    Correct Answer: A
    Explanation:

    crontab -e opens the current user's crontab for editing in the default editor. User crontabs are stored in /var/spool/cron/ and have a slightly different format than /etc/crontab (no username field).

  5. Question 5Automation & Scripting

    In a bash script, what does the construct '${VAR:-default}' do?

    AReturns 'default' if VAR is unset or empty, otherwise returns VAR's value
    BAssigns 'default' to VAR permanently
    CRemoves 'default' from VAR's value
    DAppends 'default' to VAR's value
    Show Answer & Explanation
    Correct Answer: A
    Explanation:

    ${VAR:-default} is a parameter expansion that provides a fallback value. If VAR is unset or null, it expands to 'default' without modifying VAR. Use ${VAR:=default} to also assign the default value to VAR.

Key Scripting Concepts for LINUXPLUS

bashscriptingcronregexautomationvariablesloopssedawk

LINUXPLUS Scripting Exam Tips

Scripting and Automation questions in LINUXPLUS are typically scenario-based. Focus on service-level decision making aligned to official exam objectives. Priority concepts: bash, scripting, cron, regex, automation, variables.

What LINUXPLUS Expects

  • Anchor your answer in select the most practical, secure, and scalable answer for the stated scenario.
  • Scripting scenarios for LINUXPLUS are frequently mapped to Domain 3 (19%), so read the objective carefully before picking controls or architecture.
  • Expect multi-service scenarios where Scripting interacts with IAM, networking, storage, or observability patterns rather than appearing as an isolated service question.
  • When two options are both technically valid, prefer the choice that best aligns with the exam's operational scope (Associate) and managed-service best practices.

High-Value Scripting Concepts

  • Know the core Scripting building blocks cold: bash, scripting, cron, regex.
  • Review the edge-case features and limits for automation, variables; these details are commonly used to differentiate answer choices.
  • Practice service-integration reasoning: how Scripting pairs with System Management, Troubleshooting in real deployment patterns.
  • For LINUXPLUS, explain why the chosen Scripting design meets reliability, security, and cost expectations better than the alternatives.

Common LINUXPLUS Traps

  • Watch for answers that partially solve the requirement but miss operational constraints.
  • Questions in Scripting and Automation often include distractors that look correct for Scripting but violate least-privilege, durability, or availability requirements.
  • Avoid picking options purely by feature name; validate data path, failure handling, and governance impact before answering.
  • If the prompt hints at automation or repeatability, eliminate manual-only operational answers first.

Fast Review Checklist

  • Can you compare at least two Scripting implementation paths and justify which one best fits the scenario?
  • Can you map the chosen answer back to Scripting and Automation (19%) outcomes for LINUXPLUS?
  • Can you explain security and access boundaries for Scripting without relying on default-open assumptions?
  • Can you describe how Scripting integrates with System Management and Troubleshooting during failure, scaling, and monitoring events?

Exam Domains Covering Scripting

Related Resources

More LINUXPLUS Study Resources