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.


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/0.12.18/terraform_0.12.18_linux_amd64.zip
  4. Extract the downloaded file archive

    unzip terraform_0.12.18_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. – Sebastian Wagner Aug 21 '18 at 11:10
  • 17
    sudo install terraform /usr/local/bin/ is more reliable, it ensures ownership and permissions are correct. – sj26 Oct 8 '18 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 '19 at 5:19
  • Leave it , Just Move the files that all. and later check the version. – GNK Mar 13 '19 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 '20 at 15:04

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

sudo snap install terraform
  • 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 '19 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 '19 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. – David Baucum Apr 30 '20 at 19:07
  • You are right, my bad =). This addition to the approved answer. – burtsevyg Apr 30 '20 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.

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.


Not the answer you're looking for? Browse other questions tagged or ask your own question.