How to Install Terraform on Any OS (2026 Guide)
Install Terraform on Linux, macOS, Windows, or BSD. Quick apt, dnf, and brew commands plus step-by-step guides for Ubuntu, Debian, RHEL, Fedora, Arch, and 50+ platforms.
Technology
Install Terraform on Ubuntu 22.04 and 24.04 LTS using the official HashiCorp apt repository. Covers GPG key setup, version pinning, upgrades, and verification.

wget -O- https://apt.releases.hashicorp.com/gpg | gpg --dearmor | sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
sudo apt update && sudo apt install terraform
terraform --versionFour commands and you're running the latest Terraform (1.12+) on Ubuntu 22.04 or 24.04 LTS. Read on for the GPG fingerprint check, version pinning, and upgrades.
Terraform is a powerful open-source tool created by HashiCorp that allows you to define, provision, and manage infrastructure as code. This article provides a detailed guide on installing Terraform on Ubuntu Linux, ensuring you can manage your infrastructure effectively.
Ubuntu, known for its ease of use and robustness, is a popular choice for many developers and sysadmins. Pairing it with Terraform enhances your ability to manage infrastructure seamlessly. This guide installs the latest Terraform (1.12+) on Ubuntu 22.04 and 24.04 LTS using the official HashiCorp apt repository.
Before proceeding, update your package lists to ensure you have the latest versions available:
sudo apt-get update && sudo apt-get install -y gnupg software-properties-commonHashiCorp signs their packages with a GPG key. Add it to your system:
wget -O- https://apt.releases.hashicorp.com/gpg | gpg --dearmor | sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpgVerify the fingerprint for added security:
gpg --no-default-keyring --keyring /usr/share/keyrings/hashicorp-archive-keyring.gpg --fingerprintNext, add the HashiCorp repository to your system:
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.listAfter adding the new repository, update your package lists again:
sudo apt updateOutput:
Hit:1 http://ports.ubuntu.com/ubuntu-ports mantic InRelease
Hit:2 http://ports.ubuntu.com/ubuntu-ports mantic-updates InRelease
Hit:3 http://ports.ubuntu.com/ubuntu-ports mantic-backports InRelease
Hit:4 http://ports.ubuntu.com/ubuntu-ports mantic-security InRelease
Get:5 https://apt.releases.hashicorp.com mantic InRelease [9,523 B]
Get:6 https://apt.releases.hashicorp.com mantic/main arm64 Packages [4,413 B]
Fetched 13.9 kB in 1s (18.7 kB/s)
Reading package lists... Done
Building dependency tree... Done
Reading state information... DoneNow, you can install Terraform:
sudo apt install terraformOutput:
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following NEW packages will be installed:
terraform
0 upgraded, 1 newly installed, 0 to remove and 45 not upgraded.
Need to get 24.4 MB of archives.
After this operation, 80.5 MB of additional disk space will be used.
Get:1 https://apt.releases.hashicorp.com mantic/main arm64 terraform arm64 1.7.2-1 [24.4 MB]
Fetched 24.4 MB in 13s (1,943 kB/s)
Selecting previously unselected package terraform.
(Reading database ... 101523 files and directories currently installed.)
Preparing to unpack .../terraform_1.7.2-1_arm64.deb ...
Unpacking terraform (1.7.2-1) ...
Setting up terraform (1.7.2-1) ...
Scanning processes...
Scanning linux images...
Running kernel seems to be up-to-date.
No services need to be restarted.
No containers need to be restarted.
No user sessions are running outdated binaries.
No VM guests are running outdated hypervisor (qemu) binaries on this host.To ensure Terraform is installed correctly:
terraform --versionThis command should show the installed version of Terraform.
Terraform v1.7.2
on linux_arm64For an enhanced command-line experience, enable the autocomplete feature:
terraform -install-autocompleteRestart your shell to activate the autocomplete functionality.
Add the HashiCorp apt repository and GPG key, then run sudo apt update && sudo apt install terraform. Verify with terraform --version. The full commands are in the Quick Install section above.
Terraform is distributed through HashiCorp's official apt repository. After adding the repo and its signing key, sudo apt install terraform installs the latest release and keeps it updated through apt upgrade.
Yes. The same apt repository and commands work on Ubuntu 22.04 LTS, 24.04 LTS, and other Debian-based distributions like Debian, Linux Mint, and Pop!_OS.
Reopen your shell so the updated PATH takes effect, or run hash -r. If it persists, confirm the install succeeded with apt list --installed | grep terraform and that /usr/bin is on your PATH.
Learn by doing with interactive courses on CopyPasteLearn:
You have now successfully installed Terraform on Ubuntu Linux. This setup will allow you to efficiently manage and automate your infrastructure. Regularly check for Terraform updates and explore its vast documentation to fully leverage its capabilities in your DevOps workflow.
Install Terraform on Linux, macOS, Windows, or BSD. Quick apt, dnf, and brew commands plus step-by-step guides for Ubuntu, Debian, RHEL, Fedora, Arch, and 50+ platforms.
TechnologyStep-by-step guide to install Terraform on macOS with Homebrew. Covers brew tap hashicorp/tap, version pinning, upgrading, multiple versions with tfenv, and troubleshooting common install errors.
Compare Terraform with OpenTofu, Pulumi, Ansible, AWS CDK and CloudFormation, plus core concept guides like for_each vs count and plan vs apply.
Complete guide to Terraform providers — what they are, how to configure them, version constraints, multiple provider instances, and the official registry. With real examples for AWS, Azure, and GCP.