Terraform, which can be easily installed on Ubuntu 24.04 Linux, is an open-source Infrastructure as Code (IaC) tool developed by HashiCorp. Developers and other system administrators use this tool to provision and manage cloud infrastructure on AWS, Google Cloud, Azure, and other platforms.
If you are not aware of the commands available to install Terraform and using Ubuntu Linux (24.04, 22.04, 20.04, etc.), then this guide can help configure Terraform using different methods; here are a few we are going to discuss in this article:
✅ Installing via APT (Recommended)
✅ Installing via Binary (Manual Method)
✅ Installing via Snap
Now, let’s go through each mentioned method one by one in detail! 🚀
Method 1: Install Terraform Using APT (Recommended)
The most and the easiest way to install any software package on Ubuntu Linux is by using its default package manager APT. It is not only a reliable way, but it also ensures that the package we have installed gets the latest updates automatically.
This is the easiest and most reliable way to install Terraform on Ubuntu because it ensures you get the latest version and automatic updates.
Step 1: Install Pre-required packages
Although the given packages should already be on your system, to confirm, execute the command that will install them if they are not already. These packages will help the system add external APT repositories.
sudo apt install -y gnupg software-properties-common wget
Step 2: Add HashiCorp Repository
The program Terraform is not available to install using the default system repository of Ubuntu 24.04, so we need to add the official APT repository of HashiCorp along with the GPG key used to sign the packages.
Add the GPG key:
wget -O - https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
Now, add the repository:
echo "deb [arch=$(dpkg --print-architecture) 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
Step 3: Update Package Index
We need to run the system update command once to let the system recognize the newly added APT repository and the packages meant to be downloaded. Here is the syntax to follow:
sudo apt update && sudo apt upgrade -y
Step 4: Install Terraform on Ubuntu 24.04 or in other versions
The command to install Terraform on Ubuntu 24.04 is not limited to this version; even Debian and other Ubuntu Linux users with different versions can download and install the Terraform packages.
sudo apt install terraform

Step 5: Verify Installation
To ensure this Harshicorp tool is on our system, we can just run the given command to check its version.
terraform -version
✅ Terraform is now installed and ready to use!
Method 2: Install Terraform Using Binary File (Manual Method)
Although the APT is a straightforward method to get Terraform, here is one more for those who don’t want to use it. In this method, users who don’t need to add any external repository or need a specific version can manually install the binary file of Terraform following these steps:
Step 1: Download Terraform Binary
Go to the official HashiCorp Terraform download page: 👉 https://www.terraform.io/downloads, or use the Wget command given below to download the binary in your Ubuntu terminal. But don’t forget to replace the version in the given command with the one you want to download. (Replace 1.10.7 with the latest version from the website.)
wget https://releases.hashicorp.com/terraform/1.10.5/terraform_1.10.5_linux_amd64.zip

Step 2: Extract the Binary
The downloaded binary will be in zip archived format; unzip it to extract the terraform standalone binary.
unzip terraform_*_linux_amd64.zip
Step 3: Move the Binary to /usr/local/bin
To make Terraform accessible system-wide, move it to /usr/local/bin/, this will allow us to run it from anywhere in the Terminal without specifying its binary path.
sudo mv terraform /usr/local/bin/
Check if Terraform is working:
terraform -version
✅ Terraform is now installed manually.
Method 3: Install Terraform Using Snap
In addition to APT, Ubuntu users have one more package manager called Snap. It is a secure way to add applications to the system in an isolated environment. It is recommended for those who don’t want to add an APT repository or manually install and configure the Terraform binary on Ubuntu.
Step 1: Install Snap (If Not Installed)
Snap will already be available on most of the modern Ubuntu systems; however, to confirm, you can execute the given syntax:
sudo apt install snapd -y
Step 2: Install Terraform Using Snap
Finally, use the Snap command to install Terraform.
sudo snap install terraform --classic
Step 3: Verify Installation
To check whether the installation is successfully done or not, use:
terraform -version
✅ Terraform is now installed via Snap.
Updating
✅ APT repository users: If you are using the APT package manager to install the Terraform, then simply running the system update and upgrade will also install if the latest version is available for it:
sudo apt update && sudo apt upgrade -y
✅ For Manual users:
Users who manually added the Terraform Standalone binary need to follow the same steps again, which means downloading the latest from its official website, unzipping it, and placing the binary in /usr/local/bin/.
✅ For Snap users: They need to execute the given command:
sudo snap refresh terraform
How to Uninstall Terraform
Those who don’t need the Terraform and are looking for a way to remove it can use the commands given here according to the methods used to install it.
Remove Terraform (APT Installation)
sudo apt remove terraform -y
To remove the HashiCorp repository:
sudo rm /etc/apt/sources.list.d/hashicorp.list
Then, clean up the package cache:
sudo apt update
Uninstallation Terraform (Manual Installation)
sudo rm /usr/local/bin/terraform
Remove Terraform (Snap Installation)
sudo snap remove terraform
How to Use Terraform (Basic Setup)
Now that Terraform is installed, let’s test it using a simple configuration.
Step 1: Create a New Directory for Terraform Project
mkdir terraform-test
cd terraform-test
Step 2: Initialize Terraform
Run the following command to initialize Terraform:
terraform init
This sets up Terraform in the current directory.
Step 3: Create a Sample Terraform Configuration
Create a file named main.tf:
nano main.tf
Add the following example code to create an AWS EC2 instance (change the region accordingly):
"aws" {
region = "us-east-1"
}
resource "aws_instance" "example" {
ami = "ami-0c55b159cbfafe1f0"
instance_type = "t2.micro"
}
Save and exit (CTRL + X, then Y and Enter).
Step 4: Apply Terraform Configuration
To create the resources defined in main.tf, run:
terraform apply
Terraform will show the execution plan. Type yes to proceed.
Conclusion
That’s it! Now you know how to install Terraform on Ubuntu Linux using different methods. 🚀
✅ APT Method (Recommended) – Best for stability and automatic updates
✅ Manual Binary Installation – Useful for custom versions
✅ Snap – Easy but not always up to date
After installation, you can start using Terraform to automate infrastructure deployment. Let me know if you have any problems in performing the installation! 😃
Worked like a charm, thank you