Chapter 11. Using shell scripts with cloud-init


You can add list values or string values to bootcmd or runcmd in cloud-init. You can also provide a shell script within userdata to execute custom commands during VM initialization.

  • If you use a string value, the entire string runs as a shell script.
  • If you use a list value for bootcmd or runcmd, each list item runs in turn using execve.
  • If you want to use cloud-init to run a shell script, provide a shell script (complete with shebang #!) instead of providing cloud-init with a .yaml file.

Refer to Run commands on first boot for examples of how to put shell scripts in bootcmd and runcmd.

Red Hat logoGithubredditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust. Explore our recent updates.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

Theme

© 2026 Red Hat
Back to top