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 versionand 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.
| Method | Advantage | Use case |
|---|---|---|
| mise | Multiple versions, mise.toml integration | DevOps, several projects |
| tfenv | Dedicated to Terraform, lightweight | Terraform only |
| System package | Official HashiCorp (apt/dnf) or distribution repository | Server, provided you pin the version |
| Direct binary | No manager to install | Minimal 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).
Method 1, mise (recommended)
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).
-
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;sourcerereads that file right away.Terminal window sudo apt install -y extrepo && sudo extrepo enable misesudo apt update && sudo apt install -y miseecho 'eval "$(mise activate bash)"' >> ~/.bashrcsource ~/.bashrc -
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
--globaloption makes this version available to your user, in every directory.Terminal window # Latest stable versionmise use --global terraform@latest# Specific version (recommended for reproducibility)mise use --global terraform@1.17.2For Terraform, mise relies on the aqua backend (
aqua:hashicorp/terraform, visible withmise 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. -
Check the installation
Terminal window terraform versionThe section Check the installation shows the expected output and explains the message that may appear below it.
-
Pin the version per project
In the directory of your Terraform project:
Terminal window mise use terraform@1.17.2This creates or updates a
mise.tomlfile 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 inmise.toml. With mise 2026.11, this command also approves the file along the way. Another mise command may, however, refuse a clonedmise.tomlthat has not been approved, for example when it contains templates:mise trustthen approves it. After that, theterraformcommand 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).
-
Install tfenv
Terminal window git clone --depth=1 https://github.com/tfutils/tfenv.git ~/.tfenvecho 'export PATH="$HOME/.tfenv/bin:$PATH"' >> ~/.bashrcsource ~/.bashrc -
List the available versions
Terminal window tfenv list-remote | grep -v -E 'alpha|beta|rc' | head -20Without 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. -
Install and activate a version
Terminal window tfenv install 1.17.2tfenv use 1.17.2 -
Check
Terminal window terraform version -
Pin per project
In the directory of your project, this command writes the version into a
.terraform-versionfile:Terminal window echo "1.17.2" > .terraform-versiontfenv 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:
# Prerequisitessudo apt update && sudo apt install -y wget gpg ca-certificates
# Add the official HashiCorp repositorywget -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 terraformterraform versionThis 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.
On this family, the package manager is dnf (yum is now only an alias). Type
these commands in a terminal: they install the latest published version. The
command dnf list --showduplicates terraform lists the available versions, for
example terraform-1.17.2-1.
sudo dnf install -y dnf-plugins-coresudo dnf config-manager --add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.reposudo dnf install -y terraformTo stay on the 1.17.2 of the examples, name the version in the last command:
sudo dnf install -y terraform-1.17.2-1On Fedora, the HashiCorp repository is added with the addrepo --from-repofile
form of dnf config-manager.
sudo dnf install -y dnf-plugins-coresudo dnf config-manager addrepo \ --from-repofile=https://rpm.releases.hashicorp.com/fedora/hashicorp.reposudo dnf install terraformsudo pacman -S terraformMethod 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:
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.ascgpg --import hashicorp.ascgpg --verify "terraform_${VERSION}_SHA256SUMS.sig" "terraform_${VERSION}_SHA256SUMS"sha256sum -c --ignore-missing "terraform_${VERSION}_SHA256SUMS"The three check commands read as follows:
- The first
gpgcommand 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 --verifymust showGood signature from "HashiCorp Security (hashicorp.com/security) <security@hashicorp.com>". The messageWARNING: This key is not certified with a trusted signatureis normal as long as you have not signed the key yourself.sha256summust answerterraform_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:
unzip "terraform_${VERSION}_linux_amd64.zip"sudo install -o root -g root -m 0755 terraform /usr/local/bin/terraformterraform versionrm "terraform_${VERSION}_linux_amd64.zip" "terraform_${VERSION}_SHA256SUMS" \ "terraform_${VERSION}_SHA256SUMS.sig" hashicorp.asc LICENSE.txt terraformThis 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:
terraform versionExpected result:
Terraform v1.17.2on linux_amd64The 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:
terraform -install-autocompletesource ~/.bashrcHow 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:
mkdir -p ~/.terraform.d/plugin-cacheThen 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):
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:
find ~/.terraform.d/plugin-cache -type fYou 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.
mise uninstall terraform@1.17.2The 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.
tfenv uninstall 1.17.2Depending on your distribution, type one of these two commands:
sudo apt remove terraform# orsudo dnf remove terraformThese commands remove the binary (/usr/bin/terraform). The HashiCorp
repository, the ~/.terraformrc file and the line
complete -C /usr/bin/terraform terraform added to ~/.bashrc by autocompletion
stay in place.
The binary is only a file, copied into /usr/local/bin at installation: delete
it.
sudo rm /usr/local/bin/terraformWhat 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.
| Symptom | Cause | Solution |
|---|---|---|
terraform: command not found after installing with mise | mise is not activated in the shell: the line eval "$(mise activate bash)" is missing from ~/.bashrc, or the file has not been reread | add the line, then source ~/.bashrc or open a new terminal |
terraform: command not found after installing with tfenv | the PATH does not contain ~/.tfenv/bin: the line export PATH=... is missing from ~/.bashrc, or the file has not been reread | add the line, then source ~/.bashrc; echo "$PATH" must mention .tfenv/bin |
mise ls shows (missing) next to the version | mise.toml asks for a version that mise has not installed | mise install in the project folder (and mise trust if mise asks for it) |
sha256sum answers FAILED | the archive is corrupted or modified | do not install the binary; delete the archive and download it again |
gpg --verify answers BAD signature | the list of sums does not match its signature | do 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_dirorTF_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 upgradeordnf upgradecan 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 versionconfirms 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
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
Review
(0/0)Result saved on this device. It will be sent to your account at the next sync. Sync now
Score by domain
A domain groups several guides and gets several questions, so its score is more reliable than a per-topic score, which often rests on a single question.
Summary
Strengths
No topic passed at 80% on at least two questions yet.
Weak areas
No topic below the pass mark.
Recommended next
Hints before you try again?
A new full quiz with random questions
Work again only on the questions you missed