Setting Up Your Environment

Before you can learn Linux commands, you need a real Linux machine to work on. A web-based simulator or embedded terminal will not give you the experience you need. In this step, you will provision an Ubuntu virtual machine, configure SSH access, and connect to it from your local terminal. By the end, you will have a live server ready for the rest of this lab.

Choose Your Platform

You need a machine running Linux. There are several ways to get one. Any of the options below will work for this lab. Pick whichever you are most comfortable with or have access to.

Azure (Recommended)

Microsoft Azure is the platform this lab walks through step by step. Free trial accounts include $200 in credits, which is more than enough. If you are studying for any Microsoft certification, Azure experience is a bonus.

AWS

Amazon Web Services offers a free tier that includes a t2.micro EC2 instance. Launch an Ubuntu Server AMI and connect via SSH the same way. The VM creation flow is different, but the SSH connection process is nearly identical.

GCP

Google Cloud Platform also offers a free tier with an e2-micro instance. Create a Compute Engine VM running Ubuntu and use the gcloud CLI or standard SSH to connect. The concepts are the same.

DigitalOcean

DigitalOcean Droplets are simple and inexpensive. A basic $4-6/month droplet running Ubuntu is all you need. The interface is straightforward and beginner-friendly.

VirtualBox (Local Option)

If you prefer to work entirely offline, install VirtualBox on your computer and create a virtual machine using an Ubuntu Server ISO. This requires more setup but costs nothing and does not need an internet connection once installed.

The rest of this page uses Azure as the example. If you choose a different platform, the SSH connection steps will still apply — only the VM creation process will differ.

Creating an Ubuntu VM in Azure

Follow these steps carefully. If you have never used the Azure Portal before, take your time — every field matters.

Step 0: Sign in to the Azure Portal

  1. Open a browser and go to https://portal.azure.com
  2. Sign in with your Microsoft account
  3. If you do not have an Azure subscription, create a free account — you will get $200 in credits for 30 days
  4. Confirm you are in the correct subscription by checking the top-right corner of the portal

Step 1: Create a Virtual Machine

You do not need to create a resource group first — Azure will let you create one inline during the VM creation flow.

  1. In the search bar at the top, type Virtual machines and select it
  2. Click + Create and choose Azure virtual machine
  3. On the Basics tab, configure the following:
    • Subscription: your active subscription
    • Resource group: click Create new directly under the field and name it rg-linux-lab
    • Virtual machine name: linux-lab-vm
    • Region: pick the region closest to where you are (e.g., East US if you are on the US East Coast). Lower latency means a snappier SSH session.
    • Availability options: No infrastructure redundancy required
    • Security type: Standard (or leave the default Trusted launch)
    • Image: Ubuntu Server 22.04 LTS or 24.04 LTS (either works)
    • Size: click See all sizes and pick Standard_B2s. This is what I always use because it is noticeably faster and more responsive. If you want to save money, Standard_B1s is the smallest/cheapest option and will still work fine for this lab.
    • Authentication type: SSH public key
    • Username: azureuser (or whatever you prefer — remember this)
    • SSH public key source: Generate new key pair
    • SSH key type: RSA SSH Format (default)
    • Key pair name: linux-lab-key
    • Public inbound ports: Allow selected ports, then select SSH (22) in the dropdown
  4. Skip the Disks, Networking, Management, Monitoring, and Advanced tabs — the defaults are fine
  5. Click Review + create
  6. Wait for validation to pass, then click Create
  7. Important: A dialog titled Generate new key pair will appear. Click Download private key and create resource. Your browser will download a linux-lab-key.pem file. Save it somewhere you can find it — you will move it to the correct folder in the next section.

Deployment takes 1-3 minutes. Wait for the "Your deployment is complete" message before continuing.

Step 2: Find Your Public IP Address

  1. Once deployment is complete, click Go to resource
  2. On the VM overview page, find the Public IP address field
  3. Copy this IP address — you will use it to connect via SSH

The public IP is how your local machine reaches the VM over the internet. It will look something like 20.25.100.42.

Setting Up Your SSH Key

When Azure generated the key pair, it gave you a .pem file. This file is your private key — it proves your identity when connecting to the VM. You need to put it in the right place and set the right permissions.

Move the Key to Your SSH Directory

The standard location for SSH keys is the ~/.ssh/ directory in your home folder. Move your downloaded .pem file there:

# On macOS or Linux:
mv ~/Downloads/linux-lab-key.pem ~/.ssh/linux-lab-key.pem

# On Windows (PowerShell):
Move-Item ~\Downloads\linux-lab-key.pem ~\.ssh\linux-lab-key.pem

If the ~/.ssh/ directory does not exist, create it first: mkdir ~/.ssh

Set Permissions on the Key

SSH requires that your private key file is only readable by you. If the permissions are too open, SSH will refuse to use the key. Run:

chmod 600 ~/.ssh/linux-lab-key.pem

The 600 permission means: the owner can read and write the file, and nobody else can do anything with it. This is a security requirement — SSH will not accept a key file that other users on your system could read.

i

Why do permissions matter for SSH keys?

Your private key is like a password. If anyone else on your computer could read it, the security of the connection would be compromised. SSH enforces strict permissions to protect you. If you ever see an error about "unprotected private key file," this is why — fix it with chmod 600.

Connecting to Your VM

Now that your key is in place and permissions are set, you can connect to your Linux VM using SSH.

The SSH Command

Open a terminal on your local machine (Terminal on macOS/Linux, PowerShell or Windows Terminal on Windows) and run:

ssh -i ~/.ssh/linux-lab-key.pem azureuser@YOUR_PUBLIC_IP

Replace YOUR_PUBLIC_IP with the public IP address you copied from the Azure Portal. Replace azureuser with whatever username you chose during VM creation.

What You Should See

The first time you connect, SSH will ask you to verify the server's fingerprint. Type yes and press Enter. After that, you should see something like this:

The authenticity of host '20.25.100.42 (20.25.100.42)' can't be established.
ED25519 key fingerprint is SHA256:aBcDeFgHiJkLmNoPqRsTuVwXyZ...
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes

Welcome to Ubuntu 22.04.4 LTS (GNU/Linux 6.5.0-1025-azure x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/pro

azureuser@linux-lab-vm:~$

When you see the azureuser@linux-lab-vm:~$ prompt, you are connected. You are now on a real Linux server. Everything you type from here runs on the remote machine, not your local computer.

Common Errors and Fixes

  • Permission denied (publickey): Your key file permissions are wrong, the key path is wrong, or the username is wrong. Double-check all three. Run chmod 600 on the key file and verify the username matches what you set during VM creation.
  • Connection timed out: The VM is not running, the public IP is wrong, or port 22 is not open. Go back to the Azure Portal and confirm the VM is in the Running state. Check that your Network Security Group allows inbound SSH on port 22.
  • Connection refused: The SSH service is not running on the VM, or port 22 is blocked. This is rare with a fresh Azure Ubuntu VM since SSH is enabled by default. Verify the Network Security Group rules.
  • WARNING: UNPROTECTED PRIVATE KEY FILE: Run chmod 600 ~/.ssh/linux-lab-key.pem to fix the permissions. SSH will not use a key that other users can read.

The Scenario

Your Assignment

You just got access to a server at work. Something might be broken. You do not know where anything is. Your job is to figure it out.

This is the scenario for the rest of this lab. Every command you learn from here on is a tool for investigating and understanding a Linux system you have never seen before. That is exactly what happens in real IT work — you SSH into a server, and you need to orient yourself quickly.

IMPORTANT: Delete the Entire Resource Group When You Are Done

When you are finished with this lab, delete the entire resource group (rg-linux-lab). Go to the Azure Portal, search for Resource groups, open rg-linux-lab, and click Delete resource group. Azure will prompt you to type the resource group name (rg-linux-lab) to confirm — type it exactly and then click Delete. This removes the VM, disk, public IP, network interface, and everything else in one shot.

If you do not delete the resource group, Azure will keep charging you — even if the VM is stopped, the disk and public IP continue to accrue charges. This is your responsibility, not mine. I take no responsibility for charges you incur by leaving resources running.

Tips for Windows Users

  • Use Windows Terminal or PowerShell for SSH. Both support the ssh command natively on Windows 10 and later.
  • If ssh is not recognized, install the OpenSSH Client feature: go to Settings > Apps > Optional Features and add OpenSSH Client.
  • On Windows, the chmod command does not exist. Instead, right-click the .pem file, go to Properties > Security > Advanced, disable inheritance, remove all users except your own account, and set your account to Read only.
  • Alternatively, use WSL (Windows Subsystem for Linux) and run the lab from there — the experience will be identical to macOS or Linux.

Checkpoint

Before moving on, confirm the following:

  • You have a running Ubuntu VM (Azure, AWS, GCP, DigitalOcean, or VirtualBox)
  • Your SSH private key (.pem file) is in ~/.ssh/
  • Key permissions are set to 600
  • You can SSH into the VM and see the Ubuntu welcome message
  • You see a command prompt like azureuser@linux-lab-vm:~$

If all of the above are true, your environment is ready. Move on to the next page to start exploring the Linux file system.