Skip to main content
πŸŽ“ Claude Code Masterclass Learn AI-assisted development on Udemy β€” plus the companion book on Leanpub & Amazon. Start Learning
Install Terraform on Ubuntu 24.04 LTS
DevOps

Install Terraform on Ubuntu 24.04 LTS: Complete Guide (2026)

Step-by-step guide to install Terraform on Ubuntu 24.04 LTS. Repository setup, installation, configuration, and verification.

LB
Luca Berton
Β· 1 min read

Here is how to install Terraform on Ubuntu 24.04 LTS. Tested and verified.

Prerequisites

  • Ubuntu 24.04 LTS installed and updated
  • Root or sudo access
  • Internet connection

Step 1: Update System

sudo apt update && sudo apt upgrade -y

Step 2: Add Official Repository

Terraform is distributed through HashiCorp’s official apt repository. Import the signing key and register the repository before installing:

# Install prerequisites for adding a signed apt repository
sudo apt install -y wget gnupg

# Import the HashiCorp GPG signing key
wget -O - https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg

# Add the official HashiCorp repository (resolves to "noble" on Ubuntu 24.04)
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

sudo apt update

Step 3: Install Terraform

sudo apt install -y terraform

Step 4: Verify Installation

terraform version

Expected output should show the installed version, for example Terraform v1.x.x.

Step 5: Enable Shell Autocomplete

Terraform is a CLI binary with no background service, so there is nothing to enable or start with systemd. Instead, enable tab-completion for your shell:

terraform -install-autocomplete

This appends the completion hook to your shell profile (~/.bashrc for Bash). Restart your shell or run source ~/.bashrc for it to take effect.

Troubleshooting

GPG Key Import Failure

If apt update reports NO_PUBKEY or a signature verification error, the keyring file may be missing or empty. Re-run the key import and confirm the file exists:

ls -l /usr/share/keyrings/hashicorp-archive-keyring.gpg
wget -O - https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
sudo apt update

Package Not Found

Confirm the repository was registered and refresh the apt cache:

cat /etc/apt/sources.list.d/hashicorp.list
sudo apt update
apt-cache policy terraform

If apt-cache policy terraform shows no install candidate, double-check that the codename in hashicorp.list matches Ubuntu 24.04’s codename (noble).

Uninstall

sudo apt remove -y terraform

About the Author

I am Luca Berton, AI and Cloud Advisor. Book a consultation to get help with your infrastructure setup.

#Terraform #Ubuntu 24.04 LTS #Installation #Linux #DevOps
Share:
Ansible & Python Training

Need help with Ansible & Python Training?

Level up your automation skills with expert-led Ansible and Python training.

Learn more about Ansible & Python Training

Want to operate this yourself, in production?

Take the free AI Platform Engineer Readiness Scorecard to see which skills transfer β€” then build a production-shaped AI platform in the 4-week Bootcamp.

Take the Scorecard β†’
Luca Berton β€” AI & Cloud Advisor, Docker Captain

Luca Berton

AI & Cloud Advisor Β· Docker Captain Β· KubeCon Speaker

15+ years in enterprise infrastructure. Author of 8 technical books, creator of Ansible Pilot (1M+ YouTube views, 648K site users). Former Red Hat engineer. Speaker at KubeCon EU 2026 and Red Hat Summit 2026.

Free 30-min AI & Cloud consultation

Book Now