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
  • 11
    sudo install terraform /usr/local/bin/ is more reliable, it ensures ownership and permissions are correct. – sj26 Oct 8 '18 at 5:09
  • 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... – matt 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
  • @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 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
  • 6
    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

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.


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


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


Like this:

wget -q -O - https://tjend.github.io/repo_terraform/repo_terraform.key | sudo apt-key add -
sudo echo 'deb [arch=amd64] https://tjend.github.io/repo_terraform stable main' >> /etc/apt/sources.list.d/terraform.list
sudo apt-get update
sudo apt-get install terraform
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.

  • 7
    there isn't a terraform apt package.... – 3z33etm Jun 14 '18 at 22:20
  • 3
    This answer is wrong in multiple ways, it should be deleted. – Marcus Oct 11 '18 at 9:32

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