CompTIA Linux+ study materials
CompTIA Linux+ study resources

CompTIA Linux+: Automation, Orchestration, and Scripting

CompTIA Linux+ · Work through your exam, one topic at a time.

All guide sections

Automation, Orchestration, and Scripting

Shell scripting

Start with #!/bin/bash. Quote variables ("$var") to survive spaces and globbing; use $(...) for command substitution and $? for the last exit status (0 = success). Test with [ ] or the safer [[ ]]; strings compare with =, integers with -eq/-lt. Flow control: if/elif/else, for, while, case; functions with local variables. Robust scripts open with set -euo pipefail. Use trap to clean up on signals.

Scheduling

cron fields: minute hour day-of-month month day-of-week, plus a user column in /etc/crontab and /etc/cron.d. Cron runs with a minimal environment - set PATH and use absolute paths; a literal % inside a crontab command must be escaped. systemd timers are the modern alternative and log to the journal. at runs a single one-off job.

Automation and orchestration

Configuration management (Ansible, Puppet) describes desired state and must be idempotent - a second run changes nothing. Ansible: inventory, YAML playbook, tasks calling modules, handlers triggered on change, --check for a dry run. Containers package an application with its dependencies; orchestration schedules, scales, and restarts them. Version control (git clone/commit/push) underpins all of it.

Traps: unquoted variables inside [ ], using = for numeric comparison, expecting cron to inherit your login profile, and writing non-idempotent tasks (raw shell where a module exists).

Worked example: 0 2 * * * /usr/local/bin/backup.sh >> /var/log/backup.log 2>&1 runs nightly at 02:00 as the crontab owner, capturing both output streams to one log.