The cloud-init command is a utility in Linux that is used to initialize and configure cloud instances. Cloud instances are virtual machine instances that are created and run on a cloud platform, such as Amazon Web Services (AWS) or Microsoft Azure.
To display the status of cloud-init, use the status subcommand:
# cloud-init status
This will display the status of cloud-init, including the current phase of initialization and any errors or warnings that have occurred.
# cloud-init init
This will force cloud-init to re-run all initialization tasks, including configuring networking, setting the hostname, and installing packages.
If you encounter the below error while running the command cloud-init:
cloud-init: command not found
you may try installing the below package as per your choice of distribution:
Distribution | Command |
---|---|
Debian | apt-get install cloud-init |
Ubuntu | apt-get install cloud-init |
Kali Linux | apt-get install cloud-init |
CentOS | yum install cloud-init |
Fedora | dnf install cloud-init |
Raspbian | apt-get install cloud-init |
cloud-init Command Examples
1. Display the status of the most recent cloud-init run:
# cloud-init status
2. Wait for cloud-init to finish running and then report status:
# cloud-init status --wait
3. List available top-level metadata keys to query:
# cloud-init query --list-keys
4.Query cached instance metadata for data:
# cloud-init query dot_delimited_variable_path
5.Clean logs and artifacts to allow cloud-init to rerun:
# cloud-init clean