Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Install Terraform on Ubuntu 24.04 by adding HashiCorp’s official APT repository and signing key, then installing the terraform package with APT. Terraform is a command-line tool, not a desktop app. Its release changes over time, so check HashiCorp’s install page for the current version.

Install Terraform from HashiCorp’s APT repository

The steps below follow HashiCorp’s Ubuntu/Debian package instructions. They use your system architecture and Ubuntu codename when configuring the repository, rather than hard-coding a release name.

1. Install the repository setup prerequisites

Open a terminal and run:

sudo apt-get update && sudo apt-get install -y gnupg software-properties-common

2. Add HashiCorp’s signing key

Download the key and convert it to a keyring file that APT can use:

wget -O- https://apt.releases.hashicorp.com/gpg | gpg --dearmor | sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg > /dev/null

HashiCorp’s tutorial also shows how to inspect the key fingerprint:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
gpg --no-default-keyring --keyring /usr/share/keyrings/hashicorp-archive-keyring.gpg --fingerprint

Adding the key and checking its fingerprint are separate actions. The tutorial does not give an Ubuntu 24.04-specific fingerprint value, so do not treat an unverified value as a match; consult HashiCorp’s current instructions if you need to validate it against an independently obtained fingerprint.

3. Configure the official APT repository

Run this command to write the repository entry. It detects the machine’s architecture and reads the Ubuntu codename from /etc/os-release, using lsb_release -cs as a fallback:

echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(grep -oP '(?<=UBUNTU_CODENAME=).*' /etc/os-release || lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list

4. Refresh APT and install Terraform

Update package metadata after adding the repository, then install the package:

sudo apt update
sudo apt-get install terraform

APT will install the Terraform CLI package from the configured HashiCorp repository.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Verify that Terraform is available

Open a new terminal and run the vendor-documented basic check:

terraform -help

If Terraform is available on your command path, the command displays its help output.

Optional: enable shell completion

HashiCorp documents completion setup for Bash and Zsh. It is not required to install or run Terraform. In a Bash or Zsh terminal, run:

terraform -install-autocomplete

The shell configuration file must exist, and you must restart the shell for completion to take effect. See HashiCorp’s Terraform CLI installation tutorial for the vendor’s setup details.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Which installation route should you use?

HashiCorp also offers manual executable downloads from its install page. The APT route is the natural choice for Ubuntu when you want installation through the system package manager and the vendor’s repository. A manual download is an alternative when you want to select a specific release directly; follow the verification information HashiCorp provides for that download, including its SHA-256 checksums and signed checksum file.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.