> ## Content Index
> Fetch the complete content index at: https://linuxhandbook.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# Chapter 2: Getting Started - Your First Steps
- URL: https://linuxhandbook.com/courses/terraform/install-terraform/
- Published: 2025-11-28T10:04:33.000Z
- Updated: 2025-11-28T10:06:28.000Z
- Description: Ready to jump in? Here’s how to get started with Terraform
- Author: Akhilesh Mishra
- Tags: Terraform, #lessons-col, #lesson-duration-20m

### Step 1: Install Terraform

**For macOS users:**

```
brew install terraform

```

For Windows users: Download from the official Terraform website and add it to your PATH.

**For Linux users:**

```
wget https://releases.hashicorp.com/terraform/1.12.0/terraform_1.12.0_linux_amd64.zip
unzip terraform_1.12.0_linux_amd64.zip
sudo mv terraform /usr/local/bin/

```

### Step 2: Verify Installation

```
terraform version

```

You should see something like:

```
Terraform v1.12.0

```

### Step 3: Create Your First Terraform File

Create a new directory for your first Terraform project:

```
mkdir my-first-terraform
cd my-first-terraform

```

Create a file called `main.tf` and add this simple configuration:

```
# This is a comment in Terraform
resource "local_file" "hello" {
content = "Hello, Terraform World!"
filename = "hello.txt"
}	

```

This simple example creates a text file on your local machine. Not very exciting, but it’s a great way to see Terraform in action without needing cloud credentials.

### Step 4: The Magic Commands

Now comes the fun part! Run these commands in order:

**Initialize Terraform:**

```
terraform init

```

![Terraform init command and its output](https://linuxhandbook.com/content/images/2025/11/terraform-init.png)

Terraform Init

This downloads the providers (plugins) needed for your configuration.

**See what Terraform plans to do:**

```
terraform plan

```

![Terraform Plan](https://linuxhandbook.com/content/images/2025/11/terraform-plan.png)

Terraform Plan

This shows you exactly what changes Terraform will make.

**Apply the changes:**

```
terraform apply

```

![Terraform Apply Command and its Output](https://linuxhandbook.com/content/images/2025/11/terraform-apply-full.png)

Terraform Apply

Type `yes` when prompted, and watch Terraform create your file!

**Clean up:**

```
terraform destroy

```

![Terraform Destroy command and its output](https://linuxhandbook.com/content/images/2025/11/terraform-destroy.png)

Terraform Destroy

This removes everything Terraform created.

### What Just Happened?

Congratulations! You just used Terraform to manage infrastructure (even if it was just a simple file). Here’s what each command did:

- **terraform init**: Set up the working directory and downloaded necessary plugins
- **terraform plan**: Showed you what changes would be made
- **terraform apply**: Actually made the changes
- **terraform destroy**: Cleaned everything up

This same pattern works whether you’re creating a simple file or managing thousands of cloud resources.

## Essential Terraform Commands

Beyond the basic workflow, here are commands you’ll use daily:

**terraform validate** \- Check if your configuration is syntactically valid:

```
terraform validate

```

![Terraform validate command with success message.](https://linuxhandbook.com/content/images/2025/11/terraform-validate.png)

Terraform Validate

Run this before plan. Catches typos and syntax errors instantly.  
**terraform fmt** \- Format your code to follow standard style:

```
terraform fmt

```

![Format the Terraform files using the terraform fmt command. Before and after formating the code.](https://linuxhandbook.com/content/images/2025/11/terraform-fmt.png)

Terraform Format

Makes your code consistent and readable. Run it before committing.  
**terraform show** \- Inspect the current state:

```
terraform show

```

![Terraform show command and its output](https://linuxhandbook.com/content/images/2025/11/terraform-show.png)

Terraform Show

Shows you what Terraform has created.  
**terraform output** \- Display output values:

```
terraform output

```

![The terraform output command and its result.](https://linuxhandbook.com/content/images/2025/11/terraform-output.png)

Terraform Output

Useful for getting information like IP addresses or resource IDs.  
**terraform console** \- Interactive console for testing expressions:

```
terraform console

```

Test functions and interpolations before using them in code. Type `exit` to quit.  
**terraform refresh** \- Update state to match real infrastructure:

```
terraform refresh

```

📋

Deprecated in favor of terraform apply -refresh-only, but worth knowing.

## Common Command Patterns

**See plan without applying:**

```
terraform plan -out=tfplan

```

![See plan without applying in Terraform](https://linuxhandbook.com/content/images/2025/11/terraform-plan-tf.png)

See Plan

**Apply saved plan:**

```
terraform apply tfplan

```

**Auto-approve (careful!):**

```
terraform apply -auto-approve

```

**Destroy specific resource:**

```
terraform destroy -target=aws_instance.example

```

**Format all files recursively:**

```
terraform fmt -recursive

```

These commands form your daily Terraform workflow. You’ll use init, validate, fmt, plan, and apply constantly.

![Terraform Daily Commands Cheat Sheet](https://linuxhandbook.com/content/images/2025/11/terraform-daily-commands.jpg)

Terraform Daily Commands

Now that you understand what Terraform is and how to use its basic commands, let’s dive deeper into the core concepts that make Terraform powerful. We’ll start with variables and locals—the building blocks that make your infrastructure code flexible and reusable.

I have also built [Living DevOps](https://livingdevops.com/?ref=linuxhandbook.com) platform as a real-world DevOps education platform.

I’ve spent years building, breaking, and fixing systems in production. Now I teach what I’ve learned in my free time.

You’ll find resources, roadmaps, blogs, and courses around real-world DevOps. No fluff. No theory-only content. Just practical stuff that actually works in production.

[Living With DevOps ](https://livingdevops.com/?ref=linuxhandbook.com)