How to Install Terraform on Ubuntu Linux
Terraform on Ubuntu Linux is a free tool that lets you build, change, and keep track of your computer resources using simple text files. Instead of clicking through screens, you write code to set up servers and networks.
Running standard commands like sudo apt install terraform fails on Ubuntu because the tool is not in the default software list. You must add the official software source or install it as a Snap package to get the latest release, such as Terraform 1.7.0.
Install Terraform on Ubuntu using Snap with `sudo snap install terraform –classic`, or by adding HashiCorp’s official repository and then running `sudo apt update && sudo apt install terraform`. Verify the installation with `terraform -version`.
Install Terraform on Ubuntu Linux via Snap
Installing Terraform on Ubuntu Linux using Snap is a fast and simple way to get the latest version.
Snap is a package management system developed by Canonical for Linux operating systems. It allows developers to easily distribute and update their software on different Linux distributions without worrying about compatibility issues.
To install Tarraform using Snap, run the command below.
sudo snap install terraform --classic
When you want to remove Terraform, run the command below.
sudo snap remove terraform
Install Terraform via its official repository
Installing Terraform on Ubuntu Linux from HashiCorp's official repository ensures you get reliable updates straight from the source.
sudo apt install gnupg software-properties-common
wget -O- https://apt.releases.hashicorp.com/gpg | gpg --dearmor | sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg
Once the GPG key is installed, verify it using the command below.
gpg --no-default-keyring --keyring /usr/share/keyrings/hashicorp-archive-keyring.gpg --fingerprint
The command above will display the key details similar to the lines below:
#Output:
pub rsa4096 2023-01-10 [SC] [expires: 2028-01-09]
798A EC65 4E5C 1542 8C8E 42EE AA16 FCBC A621 E701
uid [ unknown] HashiCorp Security (HashiCorp Package Signing) <security+packaging@hashicorp.com>
sub rsa4096 2023-01-10 [S] [expires: 2028-01-09]
After that, run the command below to install the repository file on 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.list
Finally, update the install Terraform.
sudo apt update sudo apt install terraform
You can verify that Terraform is installed by running the command below.
terraform -version
#Output: Terraform v1.6.0 on linux_amd64
Remove it using the command below.
sudo apt remove terraform
That should do it!
Conclusion:
- Terraform is a powerful open-source infrastructure as code (IAC) tool for managing infrastructure resources.
- Ubuntu users can install Terraform using the Snap package manager or HashiCorp's official repository.
- Installing Terraform on Ubuntu enables easy management and creation of various infrastructure resources such as VMs, network switches, and containers.
- Users can verify the successful installation of Terraform by running the command "terraform -version" in the terminal.
How to check if Terraform is installed in Ubuntu?
How do I check if Terraform is installed on my system? You can run terraform --version in your terminal or command prompt to see if Terraform is installed and view the installed version.
Do you have to install Terraform?
To use Terraform, you first need to install it. HashiCorp distributes Terraform as a binary package. You can also install Terraform using popular package managers.
Is Terraform GUI or CLI?
Terraform is CLI-driven by default, which can be challenging for teams managing large-scale infrastructure or enforcing organizational policies.
Was this guide helpful?
About the Author
Richard
Tech Writer, IT Professional
Richard, a writer for Geek Rewind, is a tech enthusiast who loves breaking down complex IT topics into simple, easy-to-understand ideas. With years of hands-on experience in system administration and enterprise IT operations, he’s developed a knack for offering practical tips and solutions. Richard aims to make technology more accessible and actionable. He's deeply committed to the Geek Rewind community, always ready to answer questions and engage in discussions.
No comments yet — be the first to share your thoughts!