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. Standard commands like sudo apt install terraform fail on Ubuntu because the tool is missing from the default software list.
You need to 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
You can install Terraform on Ubuntu using Snap (a software package manager that handles updates automatically) by running a single command in your terminal. This method automatically keeps your Terraform installation up to date without requiring manual downloads from the official website.
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
You can install Terraform on Ubuntu through HashiCorp's official repository by adding their GPG key (a security code that verifies software authenticity) and setting up the software source list. This approach ensures you receive stable, direct updates using your standard system package manager.
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.
Was this guide helpful?
About the Author
Richard
Tech Writer, IT Professional
Richard is a writer at Geek Rewind who turns complex IT tasks into clear, step-by-step guides. He draws on years of hands-on experience in system administration and enterprise IT operations, focusing on Windows, Linux and WordPress: the problems people actually run into, and the fixes that work. His server and WordPress guides come from systems he runs himself. Richard builds and maintains the platform behind Geek Rewind, from its Ubuntu servers and Nginx configuration to its custom WordPress plugins. Many new tutorials start with readers' questions, and he's always glad to answer them in the comments.
No comments yet — be the first to share your thoughts!