You are preparing an Ubuntu 22.04 server image that will be booted inside an on-premises KVM cluster. A NoCloud datasource will supply the following user-data to cloud-init:
The goal is to enable and start nginx only after the package has finished installing and before the first login prompt appears. Which cloud-init section name should replace <SECTION GOES HERE> so the command systemctl enable --now nginx executes at the correct point in the first-boot sequence?
The runcmd section is processed near the end of cloud-init's config stage, after all other configuration modules (including package installation) have completed. Commands listed there run once on the first boot, so the service starts after nginx is available and before the system reaches multi-user targets.
bootcmd executes much earlier (every boot, even before networking and package modules), so the service might start before nginx exists.
write_files only writes files; it does not execute commands.
cloud-init-per is a helper that can be used inside bootcmd to limit repetition, but it is not a top-level section on its own.
Therefore runcmd is the appropriate section for this requirement.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What is the purpose of the 'runcmd' section in cloud-init?
Open an interactive chat with Bash
How does the 'runcmd' section differ from 'bootcmd' in cloud-init?
Open an interactive chat with Bash
What are some alternatives to 'runcmd' in cloud-init, and when would you use them?
Open an interactive chat with Bash
CompTIA Linux+ XK0-006 (V8)
Automation, Orchestration, and Scripting
Your Score:
Report Issue
Bash, the Crucial Exams Chat Bot
AI Bot
Loading...
Loading...
Loading...
Pass with Confidence.
IT & Cybersecurity Package
You have hit the limits of our free tier, become a Premium Member today for unlimited access.
Military, Healthcare worker, Gov. employee or Teacher? See if you qualify for a Community Discount.
Monthly
$19.99
$19.99/mo
Billed monthly, Cancel any time.
3 Month Pass
$44.99
$14.99/mo
One time purchase of $44.99, Does not auto-renew.
MOST POPULAR
Annual Pass
$119.99
$9.99/mo
One time purchase of $119.99, Does not auto-renew.
BEST DEAL
Lifetime Pass
$189.99
One time purchase, Good for life.
What You Get
All IT & Cybersecurity Package plans include the following perks and exams .