Last reviewed: September 2026
Terraform is distributed as a single command-line executable. Install it from an official HashiCorp channel, confirm that your shell can find it, and then initialize a small project to verify provider downloads and local configuration.
Before you install
- Confirm whether your computer uses x86-64 or Arm64.
- Remove or rename an older Terraform executable if it could appear earlier in PATH.
- Use the official HashiCorp download and checksum pages. Do not install binaries copied from an unknown mirror.
- For team environments, agree on a supported Terraform version and enforce it in configuration or automation.
Install Terraform on Ubuntu
HashiCorp publishes a signed APT repository for supported Debian and Ubuntu systems. Follow the current official installation page to add the HashiCorp signing key and repository for your distribution, then refresh package metadata and install Terraform.
sudo apt update
sudo apt install terraformIf the package cannot be located, verify that the HashiCorp repository entry matches your Ubuntu release and that its signing key is present. Avoid disabling signature verification.
Install Terraform on Windows
- Open the official Terraform installation page and download the ZIP for Windows that matches your processor architecture.
- Compare the archive checksum with the checksum published by HashiCorp.
- Extract terraform.exe to a controlled directory such as C:\Tools\Terraform.
- Add that directory to your user or system PATH.
- Close and reopen PowerShell or Command Prompt so the updated PATH is loaded.
A package manager can automate upgrades, but first confirm who maintains the package and which version it provides. The direct HashiCorp download keeps the source and checksum explicit.
Install Terraform on macOS
HashiCorp maintains a Homebrew tap for macOS. After installing Homebrew, add the tap and install Terraform.
brew tap hashicorp/tap
brew install hashicorp/tap/terraformFor a later upgrade through the same tap, refresh Homebrew metadata and use its standard upgrade command. Review release notes before changing the version used by an existing project.
Verify the CLI
Open a new terminal and confirm that Terraform is available. The displayed version depends on the current release and your installation source.
terraform version
terraform -helpIf the command is not found, inspect PATH and check for multiple Terraform executables. On Windows, use where.exe terraform; on Ubuntu or macOS, use command -v terraform.
Initialize a first project
Create an empty directory, then add the following provider requirement and resource. The version constraint is an example policy; review current provider releases before adopting it.
terraform {
required_providers {
random = {
source = "hashicorp/random"
version = "~> 3.0"
}
}
}resource "random_pet" "name" {
length = 2
}
output "generated_name" {
value = random_pet.name.id
}Format the files, initialize the working directory, validate the configuration, and inspect the proposed changes.
terraform fmt
terraform init
terraform validate
terraform planInitialization creates a .terraform directory and a dependency lock file. Do not commit the .terraform directory. Commit .terraform.lock.hcl so other runs can select the same provider builds.
Upgrade safely
- Review Terraform and provider release notes before upgrading.
- Change one version boundary at a time and test in a branch or non-production environment.
- Run initialization with controlled upgrade behavior, then review the lock-file change.
- Run validation and inspect the full plan before applying anything.
- Keep CI, local development and automation runners on compatible Terraform versions.
Common setup problems
- Command not found: reopen the shell, correct PATH, and remove stale executable locations.
- Permission denied: check executable permissions and directory ownership; do not broadly weaken permissions.
- Provider download failure: verify DNS, proxy, firewall and registry access.
- Checksum or signature warning: stop and verify the download source; do not bypass trust checks.
- Wrong architecture: download the package that matches the operating system and CPU.
- Initialization fails in a reused folder: check configuration, the lock file and previous working-directory state before deleting anything.
Next steps
After the CLI works, learn how provider requirements, authentication and aliases fit into a real configuration.
Official references
Join the discussion
0 CommentsAsk questions, add context, or share what worked.
More from Melochip Editorial
Learn what Playwright testing is, why modern QA teams use it, how testers can get started, and the major types...
7 min read · Sep 19, 2026
Learn how Kubernetes Deployments and ReplicaSets work with practical YAML, scaling, self-healing, rolling upda...
7 min read · Sep 17, 2026
Learn Kubernetes security best practices with RBAC, Secrets, ServiceAccounts, Pod securityContext, NetworkPoli...
6 min read · Sep 17, 2026Related articles
Learn what Playwright testing is, why modern QA teams use it, how testers can get started, and the major types...
7 min read · Sep 19, 2026
Learn how Kubernetes Deployments and ReplicaSets work with practical YAML, scaling, self-healing, rolling upda...
7 min read · Sep 17, 2026
Learn Kubernetes security best practices with RBAC, Secrets, ServiceAccounts, Pod securityContext, NetworkPoli...
6 min read · Sep 17, 2026
Learn Kubernetes monitoring and logs with kubectl logs, events, metrics-server, top commands, Prometheus, Graf...
5 min read · Sep 17, 2026Stay in the loop. Get new Melochip articles
Receive Melochip article updates when new articles are available. Explicit opt-in only.
No comments yet. Start the discussion.