I tried to install terraform in Ubuntu desktop but I am getting error:

bash: /usr/local/bin/terraform: cannot execute binary file: Exec format error"

The same steps working for cloud servers.

8 Answers 8


Steps to install terraform on Ubuntu / Ubuntu cloud server :

  1. Install unzip

    sudo apt-get install unzip
  2. Confirm the latest version number on the terraform website:

  3. Download latest version of the terraform (substituting newer version number if needed)

    wget https://releases.hashicorp.com/terraform/1.0.7/terraform_1.0.7_linux_amd64.zip
  4. Extract the downloaded file archive

    unzip terraform_1.0.7_linux_amd64.zip
  5. Move the executable into a directory searched for executables

    sudo mv terraform /usr/local/bin/
  6. Run it

    terraform --version 
  • 4
    The version number is outdated. Aug 21, 2018 at 11:10
  • 19
    sudo install terraform /usr/local/bin/ is more reliable, it ensures ownership and permissions are correct.
    – sj26
    Oct 8, 2018 at 5:09
  • 1
    What does the sudo install actually add here? I'm asking this because I am getting "install: cannot stat 'terraform': No such file or directory" when trying to run it, and can't get it to work as intended. Feeling awkward about not using this command ever before...
    – matanster
    Mar 13, 2019 at 5:19
  • Leave it , Just Move the files that all. and later check the version.
    – GNK
    Mar 13, 2019 at 6:46
  • 1
    @matt you need to use install instead of` mv, otherwise if you call it after mv there will no terraform file in your current directory, and you will get an error.
    – jcubic
    Jan 22, 2020 at 15:04

If you’re running Ubuntu plus snap installed, just call:

sudo snap install terraform --classic
  • Something about the way snap installs the binary breaks integration with ssh-agent. terraform works fine if I install it with snap and then call the binary via its full path /snap/terraform/216/bin/terraform apply. But I just use terraform apply and let PATH find /snap/bin/terraform, the binary cannot use my ssh-agent.
    – drhagen
    Feb 20, 2019 at 19:18
  • 8
    note that snap is not always install the last version (currently it can install v0.11.11 while the last major version is v0.12.5
    – RELW
    Jul 31, 2019 at 12:15

What about using Terraform official deb repository, you can than install and update Terraform using apt.


Like this:

curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -
sudo apt-add-repository "deb [arch=$(dpkg --print-architecture)] https://apt.releases.hashicorp.com $(lsb_release -cs) main"
sudo apt update
sudo apt install terraform

My one-liner to install the latest version:

sudo echo ; zcat <( CURRR_VER=$(curl -s https://checkpoint-api.hashicorp.com/v1/check/terraform | jq -r -M '.current_version') ; curl -q "https://releases.hashicorp.com/terraform/${CURRR_VER#?}/terraform_${CURRR_VER#?}_linux_amd64.zip" ) | sudo tee /usr/local/bin/terraform > /dev/null ; sudo chmod +x /usr/local/bin/terraform

Using the line from https://github.com/hashicorp/terraform/issues/9803#issuecomment-257903082


This error occured when you try run 64 bit exec file on 32 bit system. Check your system:

uname -a

x86_64 or i686 mean 64 or 32 bit accordinary.

  • This answer is just generally true of software and not directly relevant to the question asked. Apr 30, 2020 at 19:07
  • You are right, my bad =). This addition to the approved answer.
    – burtsevyg
    Apr 30, 2020 at 20:46

You can also use 3 different tools that can help you to install and use specific versions of Terraform (similar to nvm, pyenv, rbenv, rustup tools):

I like the first one as it was made in golang and a snap package is available (but not currently in latest version https://github.com/warrensbox/terraform-switcher/issues/126).

The most popular is tfutils/tfenv/ and that's the one that I'm using right now.


I referred to The Official Terraform Website to install Terraform for Ubuntu and Debian.

Ensure that your system is up to date, and you have the gnupg, software-properties-common, and curl packages installed. You will use these packages to verify HashiCorp's GPG signature, and install HashiCorp's Debian package repository:

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

Add the HashiCorp GPG key:

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

Add the official HashiCorp Linux repository:

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

Update to add the repository, and install the Terraform CLI:

sudo apt-get update && sudo apt-get install terraform

Check if Terraform is successfully installed:

terraform -v
  • I used this in a CI/CD pipeline to update Terraform. For some reason terraform version gives me the old version, not sure what I'm doing wrong?
    – Oskar
    Jun 27 at 11:13
sudo apt-get install terraform

then run the command sudo apt-get update then sudo apt-get upgrade

will help you to get the suitable version of the teraform into the simulated hardware that was fetched from the Ubuntu install or any of the Linux version installed into your system.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .