[Demo Webinar] ⛏️ How to build a user-friendly infra self-service portal with Spacelift

➡️ Register Now

Terraform

Download & Install Terraform on Windows, MacOS, Linux

How to download and install Terraform - tutorial

🚀 Level Up Your Infrastructure Skills

You focus on building. We’ll keep you updated. Get curated infrastructure insights that help you make smarter decisions.

Developed by Hashicorp, Terraform is a powerful Infrastructure as Code (IaC) tool that facilitates infrastructure management and creation on-premises and in the cloud. However, without proper guidance, beginners may find installing Terraform challenging.

In this guide, we will cover the installation steps for Terraform on three different operating systems to show you how to install Terraform on Windows, Linux, or macOS. You can follow the steps based on your system.

  • Installing Terraform on Windows
  • Installing Terraform on Windows using Chocolatey
  • Installing Terraform on Linux (Ubuntu) using package repository
  • Installing Terraform on Linux using a Zip archive file
  • Installing Terraform on macOS
  • Installing Terraform using Homebrew on macOS or Linux

Prerequisites

Before you start the installation process, there are some prerequisites that you will need to fulfill:

  • A Windows PC if you are installing on Windows
  • A Linux system (virtual or local) if you are installing on Linux (in this post, I am using Ubuntu 20.04 to demonstrate the steps)
  • Some basic CLI knowledge

How to Install Terraform on Windows

If you are installing Terraform on Windows, you need to download the appropriate Terraform package from the Terraform download page, unpack it, and execute it using the CLI. 

Follow the steps below to make sure you install it correctly:

Step 1: Download the installation file

Navigate to the Terraform download page (https://developer.hashicorp.com/terraform/install). It should list out Terraform downloads for various platforms. 

Navigate to the Windows section and download the respective version. For this example, we are downloading V1.1.0.

terraform windows download

Click on the version that matches your system architecture to download a zip file. 

Step 2. Extract the file

Create a folder on the C drive as C:/terraform. Download the zip file in this folder. Unzip the file to extract the .exe file.

C:/terraform

Step 3. Update the path environment variable

Next, open the Start menu and search for Environment variables. Open the Environment Variables settings page.

Update Path Environment Variable

On the Environment variables edit page, open the Path variable as shown below:

Edit environment variables

On the Path pop-up that opens, click New and add the Terraform download folder. This is the folder where the zip file was downloaded and unzipped (C:/terraform).

add the Terraform download folder

Click OK to save the Path variable addition. If needed, restart your system to apply the variable changes.

Step 4. Verify if the correct version of Terraform is installed

Open a command prompt and run this command to verify Terraform is installed successfully:

verify if Terraform is installed successfully

To verify the installed version, run the terraform --version command just like below:

correct version of Terraform

How to install Terraform on Windows using Chocolatey

Chocolatey is a package manager for Windows that simplifies software installation and management using command-line commands, similar to apt on Debian/Ubuntu or brew on macOS.

First, let’s install Chocolatey. Open PowerShell as Administrator:

  • Click on the Start Menu, search for PowerShell
  • Right-click on Windows PowerShell, select “Run as administrator”

Run this official one-liner from Chocolatey’s website to install Chocolatey:

Set-ExecutionPolicy Bypass -Scope Process -Force; `
[System.Net.ServicePointManager]::SecurityProtocol = `
[System.Net.ServicePointManager]::SecurityProtocol -bor 3072; `
iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))

Close and reopen PowerShell to apply the updated PATH environment variable.

Once Chocolatey is installed, run this command in PowerShell or Command Prompt:

choco install terraform

Confirm the installation by typing Y when prompted. Chocolatey will download the latest verified version of Terraform and place it in your system path.

After installation completes, open a new Command Prompt or PowerShell window (not necessarily as admin), and verify by running:

terraform -version

This should output the installed Terraform version, confirming success. You should see output similar to:

Terraform v1.8.5
on windows_amd64

If this command runs without error, Terraform is correctly installed and globally available in your system’s PATH.

How to install Terraform on Linux

If you are installing Terraform on Linux, you have two options: The most popular approach is to use the Terraform zip with the executable file, which you can uncompress in any location on your Linux system. Ensure the folder containing the executable file is in the PATH so you can access it from everywhere. Alternatively, you can use the HashiCorp repository.

Installation using package repositories on Linux (Ubuntu)

First, we will show the steps for installing Terraform using the Linux package repository. You can follow these steps for Ubuntu. For other Linux versions, the steps are similar, but will depend on the specific package repositories. 

To start, log in to the system and run the steps below as root for sudo access.

Make sure the system is up-to-date and install these packages, which are needed for further steps:

sudo apt-get update && sudo apt-get install -y gnupg software-properties-common curl

Next, add the Hashicorp GPG key needed by the repository:

curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -

Then, add the official repository for HashiCorp for Linux:

sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"

Now that we have added the repo to the list, let’s update to add the relevant repository content:

sudo apt-get update

Once updated, run this command to install Terraform:

sudo apt-get install terraform

That should complete the installation. 

To verify the installation, run this and verify the output:

verify the installation

To verify the version installed, run: terraform -version

correct version of Terraform

Install using package repositories on Linux

Now, we’ll show the method for installing Terraform using the downloaded zip file. 

First, log in to the system and run the commands below as root.  

Before starting the installation process, get the download link from the Terraform website. Then, navigate to https://developer.hashicorp.com/terraform/install and move to the specific OS version. 

Here we are looking for Linux:

download link for Linux from the Terraform site

Copy the link for the respective download:

Copy the link for the Linux download

Now, log in to the Ubuntu system. Make sure Wget and Unzip are installed. If not, install the same:

sudo apt-get install wget unzip

Download the Terraform zip file by running the following command. Put the URL copied earlier in the command for download:

wget
wget https://releases.hashicorp.com/terraform/1.1.0/terraform_1.1.0_linux_amd64.zip

The zip file should download:

The downloaded zip file

Unzip the zip file in the current folder:

unzip terraform_1.1.0_linux_amd64.zip
unzip terraform_1.1.0_linux_amd64.zip

The Terraform executable should get unzipped in the current folder:

terraform executable

Move the Terraform executable file to /usr/bin folder:

sudo mv terraform /usr/local/bin/

That should complete the Terraform installation. Verify the installation by verifying the version:

Verify the installation on Linux

How to install Terraform on macOS

To install Terraform on macOS, download the Terraform binary zip from Hashicorp, unzip it, and copy the binary to a place in the path.

Log in to the system and create a folder for the Terraform executable:

sudo mkdir -p /opt/terraform

Navigate to the new folder:

cd /opt/terraform

From the Terraform downloads website, copy the macOS Terraform zip file download link:

copy the Mac OS terraform zip file download link

Download the zip file in the previously created folder:

sudo curl -O <copied_url>

Unzip the Terraform files in the current folder:

sudo unzip <zip_file_name>

The unzipped files will be in the current folder.

Next, add Terraform to the PATH. Navigate to the home folder and execute this command to open and edit the bash profile:

sudo vi ~/.bash_profile

Add these two lines to the opened file:

PATH="/opt/terraform:${PATH}"
export PATH

Execute the file for the path changes to take effect:

source ~/.bash_profile

Now that Terraform is installed, verify the Terraform version by running:

terraform –version

This should show the Terraform version that is installed in the system.

That completes your installation of Terraform on macOS.

How to install Terraform using Homebrew on macOS or Linux

Homebrew installs the latest stable version of Terraform from the HashiCorp tap. If you don’t have the tap added, Homebrew will automatically add it during the install.

To install Terraform using Homebrew on macOS or Linux, run the following command in your terminal:

brew install terraform

After installation, confirm it worked by running:

terraform version

This should display the installed Terraform version, verifying that it’s correctly set up in your PATH.

If you need a specific version, use:

brew install terraform@1.1.0

And link it manually with:

brew link terraform@1.1.0 --force

This method is commonly used in DevOps workflows to manage infrastructure with consistent tooling.

Next step? Import existing infrastructure into Terraform. See more here: How to Import Existing Infrastructure into Terraform (Tutorial with Examples)

Common questions about Terraform installation

Below, we answered the most popular questions users may have when installing Terraform.

Do I need to install Terraform to use it?

Yes, you need to install Terraform locally or use it via a compatible platform. Terraform is a CLI tool, so installing it lets you run commands like terraform init, plan, and apply directly from your terminal.

Alternatively, managed services like Spacelift or HCP Terraform (formerly Terraform Cloud) can run Terraform remotely, abstracting away local setups. However, even then, installing it locally is useful for development and testing workflows before committing changes.

How do I check if I have Terraform installed?

To check if Terraform is installed on your system, run the terraform version command in your terminal. If Terraform is installed and in your system’s PATH, it will return the installed version, like Terraform v1.x.x

If it’s not installed, you’ll see a command-not-found error or similar message. Alternatively, try which terraform (Linux/macOS) or where terraform (Windows) to locate the binary.

How do I add Terraform to my system’s PATH after installation?

After installing Terraform, you should add it to your system’s PATH so the CLI is available globally.

On Linux/macOS

Move the binary:

sudo mv terraform /usr/local/bin/

Verify:

terraform -version

If you prefer a custom path:

  • Add to ~/.bashrc, ~/.zshrc, or ~/.profile:
    export PATH=$PATH:/path/to/terraform
  • Reload shell:
    source ~/.bashrc (or relevant file)

On Windows

  1. Copy terraform.exe to a folder (e.g., C:\Terraform)
  2. Open System Properties → Environment Variables
  3. Under “System variables”, edit Path → Add C:\Terraform
  4. Restart terminal → run terraform -version to confirm.

What directory should I choose to install Terraform?

Install Terraform in a directory included in your system’s PATH so it can be executed globally from the terminal. Common choices:

  • On Linux/macOS: /usr/local/bin/ is typical for user-installed CLI tools.
  • On Windows: Add the folder (e.g., C:\Terraform\) to the system Path environment variable.

Ensure the directory is writable and doesn’t require elevated permissions every time you update Terraform. For local-only use, a custom ~/bin folder also works if added to your PATH.

Can I install multiple versions of Terraform?

Terraform does not natively support version switching, but this can be managed using tools like tfenv or by scripting custom paths. tfenv is the most popular solution, acting similarly to nvm for Node.js. It allows you to install and switch between specific Terraform versions as needed.

To use tfenv, install it and run:

tfenv install 1.5.7
tfenv use 1.5.7

You can then switch to another version later:

tfenv install 0.14.11
tfenv use 0.14.11

Read more: How to Use tfenv to Manage Multiple Terraform Versions

For Windows users, tfswitch or choco install terraform --version=... is a popular alternative.

You can also manually download and unpack different versions of Terraform in separate directories, then add the desired version to your PATH before execution.

What are common Terraform installation errors, and how do I fix them?

Common Terraform installation errors include path misconfiguration, permission issues, and incompatible binary versions. Most can be resolved by adjusting environment variables or ensuring correct binary usage.

1. Terraform command not found

This usually means the Terraform binary is not in your system’s PATH.

Ensure the Terraform binary is in a directory listed in your PATH variable. For example:

export PATH=$PATH:/usr/local/bin

Or move the binary:

sudo mv terraform /usr/local/bin/

2. Permission denied

This occurs when trying to run Terraform without execute permissions or installing it in a restricted directory.

To grant execute permissions:

chmod +x terraform

Use sudo if installing to system-wide directories:

sudo mv terraform /usr/local/bin/

3. Incompatible version or corrupted binary

If Terraform exits immediately or returns unusual errors, the binary may be corrupted or incompatible with your OS. To fix this, redownload the correct version for your OS/architecture from the Terraform documentation.

4. Checksum verification failure (during terraform init)

Occurs if the Terraform plugin checksum doesn’t match the expected values. Delete .terraform directory and reinitialize:

rm -rf .terraform && terraform init

Make sure you’re not behind a proxy altering responses. 

If you’re using custom providers or private registries, ensure the checksum in .terraform.lock.hcl matches the new binary.

How to uninstall Terraform?

To uninstall Terraform, you need to remove its binary and optionally clean up related files such as plugins or configuration. If you’re doing a clean reset, you may also want to remove ~/.terraform.d/ and any state or configuration files. The exact steps depend on how it was installed.

Uninstallation is complete once the binary is removed and terraform no longer runs from the command line.

Why use Spacelift to manage your Terraform resources?

Terraform is really powerful, but to achieve an end-to-end secure Gitops approach, you need to use a product that can run your Terraform workflows. Spacelift takes managing Terraform to the next level by giving you access to a powerful CI/CD workflow and unlocking features such as:

  • Policies (based on Open Policy Agent) – You can control how many approvals you need for runs, what kind of resources you can create, and what kind of parameters these resources can have, and you can also control the behavior when a pull request is open or merged.
  • Multi-IaC workflows – Combine Terraform with Kubernetes, Ansible, and other infrastructure-as-code (IaC) tools such as OpenTofu, Pulumi, and CloudFormation,  create dependencies among them, and share outputs
  • Build self-service infrastructure – You can use Blueprints to build self-service infrastructure; simply complete a form to provision infrastructure based on Terraform and other supported tools.
  • Integrations with any third-party tools – You can integrate with your favorite third-party tools and even build policies for them. For example, see how to integrate security tools in your workflows using Custom Inputs.

Spacelift enables you to create private workers inside your infrastructure, which helps you execute Spacelift-related workflows on your end. Read the documentation for more information on configuring private workers.

Spacelift can also optionally manage the Terraform state for you, offering a backend synchronized with the rest of the platform to maximize convenience and security. You can also import your state during stack creation, which is very useful for engineers who are migrating their old configurations and states to Spacelift.

You can check it out for free by creating a trial account or booking a demo with one of our engineers.

Key points

Terraform allows you to convert a whole cloud infrastructure to config or code files. These files can be used to spin up the entire infrastructure quickly and easily. Anyone can use it to manage a cloud infrastructure on any of the cloud providers. 

In this post, we went through the steps to install Terraform on Windows, Linux, and macOS. I hope this helps you with your installations. If you’re interested in upgrading Terraform to the latest version, see Upgrading Terraform to the Latest Version.

Note: New versions of Terraform are placed under the BUSL license, but everything created before version 1.5.x stays open-source. OpenTofu is an open-source version of Terraform that expands on Terraform’s existing concepts and offerings. It is a viable alternative to HashiCorp’s Terraform, being forked from Terraform version 1.5.6.

Terraform management made easy

Spacelift effectively manages Terraform state, more complex workflows, supports policy as code, programmatic configuration, context sharing, drift detection, resource visualization and includes many more features.

Start free trial
Terraform CLI Commands Cheatsheet

Initialize/ plan/ apply your IaC, manage modules, state, and more.

Share your data and download the cheatsheet