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
Steps to install terraform on Ubuntu / Ubuntu cloud server :
Install unzip
sudo apt-get install unzipConfirm the latest version number on the terraform website:
Download latest version of the terraform (substituting newer version number if needed)
wgetExtract the downloaded file archive
unzip terraform_1.0.7_linux_amd64.zipMove the executable into a directory searched for executables
sudo mv terraform /usr/local/bin/Run it
terraform --version
If you’re running Ubuntu plus snap installed, just call:
sudo snap install terraform 2 What about using Terraform official deb repository, you can than install and update Terraform using apt.
Like this:
curl -fsSL | sudo apt-key add -
sudo apt-add-repository "deb [arch=$(dpkg --print-architecture)] $(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 | jq -r -M '.current_version') ; curl -q "" ) | sudo tee /usr/local/bin/terraform > /dev/null ; sudo chmod +x /usr/local/bin/terraformUsing the line from
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.
2You 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):
tfswitch:cloudposse/tfenv:tfutils/tfenv:
I like the first one as it was made in golang and a snap package is available (but not currently in latest version ).
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 curlAdd the HashiCorp GPG key:
curl -fsSL | sudo apt-key add -Add the official HashiCorp Linux repository:
sudo apt-add-repository "deb [arch=amd64] $(lsb_release -cs) main"Update to add the repository, and install the Terraform CLI:
sudo apt-get update && sudo apt-get install terraformCheck if Terraform is successfully installed:
terraform -v sudo apt-get install terraformthen 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.
3