Skip to content
Français
Sync not enabled: your progress stays in this browser My learning
Select theme
Français

Install Terraform on Linux and manage versions

20 min read
Improve this page

Logo Terraform

This guide installs Terraform on Linux. It presents four methods (mise, tfenv, system package, direct binary) and tells you which one to choose depending on your context. At the end, terraform version shows the installed version and you can start your first project.

The examples on this site use Terraform 1.17.2. The commands in this guide install that version, with two exceptions flagged where they occur: terraform@latest with mise, and the system package, which takes the latest version until you pin it. You need a Linux terminal and an account allowed to use sudo (the prefix that runs a command with administrator rights).

What you will learn

  • Choose the right method: mise, tfenv, system package or direct binary
  • Install with mise: the recommended method for managing several versions
  • Check the installation: terraform version and autocompletion
  • Verify the integrity of a downloaded binary: SHA256 checksum and GPG signature
  • Configure the provider cache: avoid downloading the same providers again for every project
  • Uninstall cleanly according to the method you used

Which installation method should you choose?

The table compares the four methods; the right-hand column says in which context each one fits.

MethodAdvantageUse case
miseMultiple versions, mise.toml integrationDevOps, several projects
tfenvDedicated to Terraform, lightweightTerraform only
System packageOfficial HashiCorp (apt/dnf) or distribution repositoryServer, provided you pin the version
Direct binaryNo manager to installMinimal environment

One method is enough. If you are starting out, follow method 1 (mise) and go straight to Check the installation: methods 2 to 4 are alternatives, to open only if your context requires it. In every code block, the lines are commands to type in a terminal, unless the text says that it is the content of a file.

All four methods work on Debian 13 with Terraform 1.17.2, and the dnf package works on AlmaLinux 10. The Ubuntu, Fedora and Arch tabs are not covered by these tests: if a command fails there, adapt it to your distribution. These methods decide which version is installed on your machine. The version that the code accepts is declared separately, in required_version: see the Terraform version constraints (in French).

mise is a versatile version manager that replaces nvm, rbenv, pyenv and tfenv with a single tool (its dedicated guide (in French) covers its other features).

  1. Install mise

    These commands apply to Debian-family distributions (apt); on Fedora or macOS, follow the mise installation (in French). The first two lines add the mise repository (through extrepo, the Debian tool that enables third-party repositories) and then install the tool. The third writes to ~/.bashrc, the file read each time a terminal opens, the line that activates mise; source rereads that file right away.

    Terminal window
    sudo apt install -y extrepo && sudo extrepo enable mise
    sudo apt update && sudo apt install -y mise
    echo 'eval "$(mise activate bash)"' >> ~/.bashrc
    source ~/.bashrc
  2. Install Terraform with mise

    Run only one of these two commands: the first takes the latest published version, the second a specific version (recommended). The --global option makes this version available to your user, in every directory.

    Terminal window
    # Latest stable version
    mise use --global terraform@latest
    # Specific version (recommended for reproducibility)
    mise use --global terraform@1.17.2

    For Terraform, mise relies on the aqua backend (aqua:hashicorp/terraform, visible with mise registry terraform): it checks the SHA256 checksum (the fingerprint of the file) of the downloaded archive. Its signature checks (Cosign, SLSA, GitHub Attestations) apply only when the package definition provides them, as the mise guide (in French) explains. Do not count on it to verify the GPG signature from HashiCorp: method 4 checks it by hand.

  3. Check the installation

    Terminal window
    terraform version

    The section Check the installation shows the expected output and explains the message that may appear below it.

  4. Pin the version per project

    In the directory of your Terraform project:

    Terminal window
    mise use terraform@1.17.2

    This creates or updates a mise.toml file in the current directory. Here is its content, written by mise (you have nothing to type):

    [tools]
    terraform = "1.17.2"

    A colleague who has mise installed gets the same version: in the project, they run mise install, which downloads the version written in mise.toml. With mise 2026.11, this command also approves the file along the way. Another mise command may, however, refuse a cloned mise.toml that has not been approved, for example when it contains templates: mise trust then approves it. After that, the terraform command uses 1.17.2 there.

Method 2, tfenv

tfenv is a version manager dedicated to Terraform, lightweight and simple. It is installed by cloning its repository with git, and it then downloads and unpacks the Terraform archives: git and unzip must therefore be present on the machine (on Debian 13, sudo apt install -y git unzip).

  1. Install tfenv

    Terminal window
    git clone --depth=1 https://github.com/tfutils/tfenv.git ~/.tfenv
    echo 'export PATH="$HOME/.tfenv/bin:$PATH"' >> ~/.bashrc
    source ~/.bashrc
  2. List the available versions

    Terminal window
    tfenv list-remote | grep -v -E 'alpha|beta|rc' | head -20

    Without the grep, the list mixes pre-releases (1.17.0-rc2, 1.17.0-beta1) in with the stable versions, and you do not install those in production.

  3. Install and activate a version

    Terminal window
    tfenv install 1.17.2
    tfenv use 1.17.2
  4. Check

    Terminal window
    terraform version
  5. Pin per project

    In the directory of your project, this command writes the version into a .terraform-version file:

    Terminal window
    echo "1.17.2" > .terraform-version

    tfenv then uses this version automatically in that directory.

Method 3, system package

The package comes from the official HashiCorp repository on Debian, Ubuntu, RHEL and Fedora, and from the distribution repository on Arch. Choose the tab of your distribution.

A repository is a package server that apt queries: here you add the HashiCorp one, then install Terraform like any other package. On a minimal Debian 13 (container, cloud image), wget is missing and gpg may be too. Without them, the command fails and leaves an invalid repository file that then blocks every apt update: the first line of the block therefore installs them first.

The codename of the distribution is read from /etc/os-release, which is present everywhere, because lsb_release is missing on these images as well. On Ubuntu, the repository line uses UBUNTU_CODENAME instead of VERSION_CODENAME, which the block already handles. The GPG key is converted to binary format in /usr/share/keyrings/, and the signed-by option limits its trust to this one repository. Type these commands in a terminal, in order:

Terminal window
# Prerequisites
sudo apt update && sudo apt install -y wget gpg ca-certificates
# Add the official HashiCorp repository
wget -O - https://apt.releases.hashicorp.com/gpg | \
sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] \
https://apt.releases.hashicorp.com $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") main" | \
sudo tee /etc/apt/sources.list.d/hashicorp.list
sudo apt update && sudo apt install -y terraform
terraform version

This installation takes the latest published version: terraform version shows Terraform v1.17.3 as of December 4, 2026, followed by on linux_amd64. To stay on the 1.17.2 of the examples, replace terraform with terraform=1.17.2-1 in the apt install command of the block (the list of available versions is shown by apt-cache madison terraform). The package then follows the new versions of the HashiCorp repository, unless you pin it as the box below explains.

Method 4, direct binary (no dependencies)

The direct binary means downloading the official Terraform archive yourself, then copying the executable into a directory of the PATH (the list of folders where the shell looks for commands). Only curl and unzip are needed (on Debian 13, unzip is not installed: sudo apt install -y unzip), and you manage only one version at a time. Since you download an executable that you are going to copy with sudo rights, check it before installing it: the checksum and the signature are there for that.

How do you download and verify the archive?

HashiCorp publishes the SHA256 checksums and a GPG signature for each release, on releases.hashicorp.com. The checksum proves that the file is not corrupted, the signature proves that the list of checksums really comes from HashiCorp (the difference between the two is detailed in the guide on file integrity). In an empty directory, download the archive, the SHA256SUMS file and its .sig signature, then the HashiCorp public key. You need the gpg package; sha256sum ships with the system. Type these commands in a terminal:

Terminal window
VERSION="1.17.2"
BASE="https://releases.hashicorp.com/terraform/${VERSION}"
curl -fsSLO "${BASE}/terraform_${VERSION}_linux_amd64.zip"
curl -fsSLO "${BASE}/terraform_${VERSION}_SHA256SUMS"
curl -fsSLO "${BASE}/terraform_${VERSION}_SHA256SUMS.sig"
curl -fsSL https://www.hashicorp.com/.well-known/pgp-key.txt -o hashicorp.asc
gpg --show-keys --with-fingerprint hashicorp.asc
gpg --import hashicorp.asc
gpg --verify "terraform_${VERSION}_SHA256SUMS.sig" "terraform_${VERSION}_SHA256SUMS"
sha256sum -c --ignore-missing "terraform_${VERSION}_SHA256SUMS"

The three check commands read as follows:

  • The first gpg command shows the fingerprint of the key: C874 011F 0AB4 0511 0D02 1055 3436 5D94 72D7 468F. Compare it with the one that HashiCorp publishes on its security page before trusting the key.
  • gpg --verify must show Good signature from "HashiCorp Security (hashicorp.com/security) <security@hashicorp.com>". The message WARNING: This key is not certified with a trusted signature is normal as long as you have not signed the key yourself.
  • sha256sum must answer terraform_1.17.2_linux_amd64.zip: OK.

A modified file gives FAILED and exit code 1, and a signature that no longer matches the file gives BAD signature: in both cases, do not install the binary.

How do you install the binary?

Once the archive has been checked, extract it and copy the executable into /usr/local/bin, a directory of the PATH reserved for programs added by hand (hence the sudo). Type these commands in a terminal:

Terminal window
unzip "terraform_${VERSION}_linux_amd64.zip"
sudo install -o root -g root -m 0755 terraform /usr/local/bin/terraform
terraform version
rm "terraform_${VERSION}_linux_amd64.zip" "terraform_${VERSION}_SHA256SUMS" \
"terraform_${VERSION}_SHA256SUMS.sig" hashicorp.asc LICENSE.txt terraform

This block reuses the VERSION variable defined in the previous subsection: stay in the same terminal, otherwise define it again with VERSION="1.17.2". It installs the file you have just checked, without downloading anything again. The install command copies the binary and gives it to root with mode 0755 (readable and executable by everyone, writable by root only): a mv would have left the file owned by your user, who could then rewrite it. The command terraform version must show Terraform v1.17.2, and the final rm cleans up the downloaded files (the archive also contains a LICENSE.txt, extracted next to the binary, and the executable extracted into the current directory is deleted too).

Check the installation

Whatever the method, check that Terraform is accessible:

Terminal window
terraform version

Expected result:

Terraform v1.17.2
on linux_amd64

The latest published version is 1.17.3 (December 2, 2026), with no change of behavior compared with 1.17.2. With 1.17.2, Terraform adds the message Your version of Terraform is out of date! below these two lines, followed by the number of the new version. Your installation works: the message is only informational, and you can stay on 1.17.2 to get the same outputs as this site. After an installation of the system package without pinning, you will see Terraform v1.17.3 and no message.

Then enable autocompletion: the Tab key then completes the Terraform subcommands. The first command adds a line to ~/.bashrc, the second rereads that file:

Terminal window
terraform -install-autocomplete
source ~/.bashrc

How do you configure the provider cache directory?

By default, Terraform downloads the providers into the .terraform/ directory of each project. To avoid downloading them again at each init, configure a global cache:

Terminal window
mkdir -p ~/.terraform.d/plugin-cache

Then open the ~/.terraformrc file in your text editor (it does not exist yet: the editor creates it when you save) and add this line. It is not a command to type in the terminal, it is the content of the CLI configuration file:

plugin_cache_dir = "$HOME/.terraform.d/plugin-cache"

Alternatively, you can set the environment variable TF_PLUGIN_CACHE_DIR instead of editing ~/.terraformrc. This time, it is a command to type in the terminal (it applies only to that terminal: to keep it, add the same line to ~/.bashrc):

Terminal window
export TF_PLUGIN_CACHE_DIR="$HOME/.terraform.d/plugin-cache"

This configuration avoids downloading the same providers again in every project. To check it, you need a project that declares a provider: if you do not have one yet, the check will happen at your first terraform init, the configuration being already in place. Otherwise, run terraform init in that project, then list the cache:

Terminal window
find ~/.terraform.d/plugin-cache -type f

You should see the provider binary there, for example registry.terraform.io/hashicorp/random/3.9.1/linux_amd64/terraform-provider-random_v3.9.1_x5. The cache fills at the first init and serves the following ones.

How do you uninstall Terraform?

Uninstalling depends on the method used at installation: choose the tab that matches it.

Terminal window
mise uninstall terraform@1.17.2

The version is removed from the disk, but the line terraform = "1.17.2" stays in your mise.toml: mise ls then shows it with the mention (missing). Delete that line by hand if you no longer want Terraform.

What should you do if the installation fails?

Failures almost always come from the shell not seeing the command, or from an integrity check that rejects the file. The table links each symptom to its cause and to the fix.

SymptomCauseSolution
terraform: command not found after installing with misemise is not activated in the shell: the line eval "$(mise activate bash)" is missing from ~/.bashrc, or the file has not been rereadadd the line, then source ~/.bashrc or open a new terminal
terraform: command not found after installing with tfenvthe PATH does not contain ~/.tfenv/bin: the line export PATH=... is missing from ~/.bashrc, or the file has not been rereadadd the line, then source ~/.bashrc; echo "$PATH" must mention .tfenv/bin
mise ls shows (missing) next to the versionmise.toml asks for a version that mise has not installedmise install in the project folder (and mise trust if mise asks for it)
sha256sum answers FAILEDthe archive is corrupted or modifieddo not install the binary; delete the archive and download it again
gpg --verify answers BAD signaturethe list of sums does not match its signaturedo not install the binary, and do not trust that list

Key takeaways

  • mise is the recommended method for DevOps environments: it manages several versions side by side and pins the version per project through mise.toml.
  • Pinning the version is good practice: all the members of the team then use the same version.
  • The provider cache (plugin_cache_dir or TF_PLUGIN_CACHE_DIR) speeds up the inits, but does not support concurrent runs.
  • The system package follows the new versions of its repository: in production, apt upgrade or dnf upgrade can make it change minor version (from 1.16 to 1.17, for example) without warning. Pin it (apt-mark hold, dnf versionlock) or prefer mise or tfenv.
  • tfenv checks the SHA256 of the archive but not the GPG signature, unless the OpenPGP verification is enabled.
  • For a direct binary installation, check the SHA256 checksums and the GPG signature before copying the binary.
  • terraform version confirms the installation, whatever the method.
  • The examples on this site use Terraform 1.17.2.

Put it into practice

The lab has you install Terraform in several ways in practice folders: a specific version for a single folder with mise, an archive verified by its signature and then by its SHA256 sum, a modified archive that the verification refuses (FAILED, then BAD signature), and a provider cache that you see being used. You need mise, curl, unzip and gpg. At the end, you install on your own the version that a project requires in its .terraform-version file, with the binary method and its two verifications. The validation checks the version of the installed binary, the signature of the list of sums, the conformity of the archive, and that the provider cache has served the project.

Knowledge check

Six randomly drawn questions check that you can choose an installation method, verify what you installed and configure the provider cache.

Knowledge check

Check what you have learned with this interactive quiz

6 questions
6 min
70% to pass

How it works

  • The timer starts when you click Start
  • Multiple choice, true/false and short answer questions
  • You can move between questions
  • Detailed results are shown at the end

Starts the quiz and the timer