Set Up a Linux VM for Practice
Set up a Linux VM for practice — Linux · networking · telemetry.
Focus: set up a linux vm for practice
You’ve mastered the basics of Linux commands, but you keep worrying: what happens if I break something? On your daily driver machine, a botched rm or a bad systemd unit can cost hours. That friction is exactly why learning Linux by trial and error on your own OS feels so slow. The fix is simple: set up a Linux VM for practice and give yourself a sandbox that’s isolated, disposable, and realistic. With a virtual machine, you can destroy a system fully and rebuild it in minutes — no fear, no collateral damage, just pure learning speed.
The problem this lesson solves
Learning Linux requires you to run commands, edit configs, install services, and sometimes crash a system. If you do that on your workstation, you risk:
- Losing personal files or settings after a typo.
- Breaking a corporate or shared environment.
- Slowing down your main system with heavy daemons or telemetry agents.
Even if you’re disciplined, your local setup is not representative of a real server. You need an environment where you can:
- Experiment freely with file systems, services, and networking.
- Snapshot and roll back when something goes sideways.
- Install and remove packages without polluting your host OS.
Without a VM, most developers end up learning Linux passively — reading tutorials instead of typing. That’s why this lesson exists: to give you a safe, disposable Linux playground that mimics production, so you can break things on purpose and learn from the fix.
By the end, you’ll have a working Linux VM, know how to reach it from your terminal, and be ready for the network and telemetry lessons that follow.
Core concept / mental model
Think of a virtual machine as a computer inside your computer. A hypervisor (like VirtualBox, VMware, or QEMU/KVM) carves out part of your real hardware’s CPU, memory, disk, and network, and presents them as a separate machine. That machine boots its own kernel and runs a full Linux distribution — completely isolated from your host.
Replace virtualization with a simpler analogy: a soundproof practice room. Your physical computer is the stage; the VM is a soundproofed booth inside it. You can play as loud and as messy as you want, and nobody outside hears a thing. If you smash your instrument, you can build a new booth in minutes. The stage (your host machine) stays pristine.
Key terms to internalize:
- Host — the physical machine you’re sitting at.
- Guest — the Linux OS inside the VM.
- Hypervisor — the software that creates and runs VMs.
- Snapshot — a saved state of the VM at a moment in time; you can revert to it later.
- NAT / bridged networking — two ways a VM talks to the outside world: NAT hides it behind your host; bridged gives it its own IP on your LAN.
This mental model is crucial because everything you do in this track — pinging, tracing HTTP, pushing metrics — happens from inside that guest. Your VM is your laboratory, and the host is just the wall socket.
How it works step by step
The process of setting up a Linux VM for practice breaks into five phases. Each phase has a clear goal; follow them in order to avoid confusion.
- Choose your hypervisor — the software that manages VMs. The most common free options are VirtualBox (cross-platform), VMware Workstation Player (free for personal use), and KVM/QEMU (built into Linux hosts).
- Download a Linux distribution image — an ISO file is the raw install media for your guest. Choose something stable and common, like Ubuntu Server LTS or Debian.
- Create a VM configuration — allocate CPU, memory, disk, and networking. Start small; you can scale later.
- Install the OS — boot from the ISO, follow the installer, and create a user account with sudo access.
- Access and secure it — once installed, you’ll mostly use SSH to get into the VM. Set up port forwarding or a bridged network, install OpenSSH, and you have a headless server to practice on.
Each step matters. For example, skipping a proper network configuration means you can’t reach your VM, and without snapshots you lose your ability to roll back. Let’s build a real VM now.
Hands-on walkthrough
We’ll use VirtualBox and Ubuntu Server 22.04 LTS because they’re free, cross-platform, and the most common in tutorials. If you’re already on Linux, you can swap in KVM with the same concepts. Here are the exact steps.
1. Install VirtualBox and download an ISO
On your host (Windows, macOS, or Linux), go to virtualbox.org and download VirtualBox for your OS. Then grab the Ubuntu Server ISO from ubuntu.com/download/server. You’ll get a .iso file (about 2 GB).
2. Create the VM in VirtualBox
Open VirtualBox, click New, and set the machine name to linux-lab. Choose Linux as type and Ubuntu (64-bit) as version. For memory, pick 2048 MB (2 GB) — plenty for a minimal server. For disk, choose Create a virtual hard disk now and select VDI with Dynamically allocated; set the size to 20 GB. That’s enough for a few telemetry stacks later.
Pro tip: Dynamically allocated disks grow only as you use them, so a 20 GB VM won’t consume 20 GB on your host until it actually needs it.
Now, before booting, open Settings → Storage and attach the Ubuntu ISO to the optical drive slot. Then set Settings → Network to NAT (the default) — we’ll forward ports later for SSH.
3. Install Ubuntu Server
Start the VM; it will boot from the ISO. The install prompts are self-explanatory, but a few choices matter:
- Install Ubuntu Server (not the “Live Server” option unless you want a different flow).
- Choose Done for the default network config (DHCP).
- When asked, Set up this disk as an LVM group — LVM makes resizing easier later.
- Create a username and password. Use something memorable like
labuserand a strong password. - Leave Install OpenSSH server checked when prompted — it saves you from installing it manually.
Wait for the install to finish, then reboot. The VM will eject the ISO automatically; if it boots into the installer again, detach the ISO from the VM settings.
4. Log in and test the basics
You are now inside your Linux VM. Log in with the user and password you created. Run a few sanity checks to confirm this is a real Linux system:
# Who am I?
whoami
# What kernel is running?
uname -a
# What OS?
cat /etc/os-release
# How much memory do we have?
free -h
Sample output (yours will vary slightly):
labuser
Linux linux-lab 5.15.0-91-generic #101-Ubuntu SMP ... x86_64 ...
PRETTY_NAME="Ubuntu 22.04.3 LTS"
...
total used free shared buff/cache available
Mem: 1.9Gi 256Mi 1.2Gi 8.0Mi 458Mi 1.5Gi
You now have a Linux VM for practice. But you’ll quickly get tired of typing into a small VM window. That’s why the next step is to access it via SSH from your host terminal.
5. Enable SSH and connect from your host
First, inside the VM, confirm SSH is running:
sudo systemctl status ssh
# If it’s not active, install and start it:
sudo apt update
sudo apt install -y openssh-server
sudo systemctl enable --now ssh
While the VM uses NAT networking, your host can’t reach it directly. You’ll forward a host port to the VM’s port 22. In VirtualBox, go to Settings → Network → Advanced → Port Forwarding and add:
- Name:
ssh - Protocol:
TCP - Host Port:
2222 - Guest Port:
22
Now from your host terminal, connect with:
ssh -p 2222 labuser@localhost
You should land at a shell prompt inside the VM. You’re now ready to practice Linux without worrying about your host.
Pro tip: Install the VirtualBox Guest Additions for a smoother console experience and shared folders. Run
sudo apt install -y virtualbox-guest-utilsinside the VM, then reboot. This is optional but very convenient for copying files in and out.
6. Take a snapshot
Before you start exploring, take a snapshot so you can always revert to this clean state. In VirtualBox, click the Snapshot button (or use ⌘+T on macOS, Ctrl+T on Windows) and name it fresh-install. Now go crazy — install services, edit system files, break things. If you mess up, you can revert in seconds.
Compare options / when to choose what
Not all virtualization tools are equal. Here’s a quick comparison to help you pick what fits your host and workflow.
| Tool | Platform | Best for | Snapshot & rollback | Nested virtualization | Learning curve |
|---|---|---|---|---|---|
| VirtualBox | Windows, macOS, Linux | General learning, cross-platform | ✅ Yes | ⚠️ Limited | Easy |
| VMware Workstation Player | Windows, Linux | Lightweight, simpler UI | ✅ Yes | ⚠️ Limited | Easy |
| KVM/QEMU | Linux only | Performance, production-like | ✅ Yes (via snapshots or lvcreate) |
✅ Excellent | Medium |
| Multipass | macOS, Windows, Linux | Quick disposable Ubuntu VMs from the CLI | ✅ Yes | N/A | Very easy |
- Choose VirtualBox if you’re on Windows or macOS and want a standard, well-documented experience.
- Choose KVM/QEMU if your host is Linux and you want near-native speed for memory-hungry telemetry stacks.
- Choose Multipass if you want a one-line VM:
multipass launch --name lab— but it’s Ubuntu-only and less flexible.
All options give you the core superpower: a machine you can break and rebuild at will. Focus on one first; you can change later without losing your Linux skills.
Troubleshooting & edge cases
Even with a guide, things don’t always go perfectly. Here are the most common issues when you set up a Linux VM for practice, and how to fix them quickly.
“Failed to open a session for the virtual machine”
This is usually a hardware acceleration or virtualization issue. On Windows, enable Intel VT-x/AMD-V in your BIOS/UEFI settings. Also check that VirtualBox’s vboxdrv kernel module is loaded on Linux: sudo modprobe vboxdrv (or reinstall the VirtualBox package).
The VM boots into the installer every time
That means the ISO is still attached. In the VM settings, remove the optical disk or unmount it after the first boot: Devices → Optical Drives → Remove disk from virtual drive.
SSH connection refused
This is almost always a network or SSH issue. Check inside the VM:
sudo systemctl status ssh
# Ensure port 22 is listening
ss -tulpn | grep 22
If it’s listening, your port forwarding is wrong. Double-check that the guest port is 22 and the host port matches what you connect to (-p 2222). Also, make sure the VM is running and you’re not trying a different port.
Network is working, but DNS fails
If ping 8.8.8.8 works but ping google.com fails, you’re missing a DNS resolver. Edit /etc/resolv.conf (or use systemd-resolve) and set nameservers to 8.8.8.8 or your local router’s IP.
The VM is super slow
If you allocated only 1 GB RAM, don’t expect miracles. Recommendation: give the VM at least 2 GB, and if possible enable 3D acceleration in display settings. For heavy telemetry tools, 4 GB is more comfy. Also, close unnecessary host apps while the VM runs.
What you learned & what's next
You now have a working Linux VM for practice, which is the single best investment you can make for this track. You can:
- Explain how a VM isolates a guest OS from your host and why that makes learning safe.
- Complete the practical exercise: create a VM, install Ubuntu Server, and connect via SSH.
- Apply this setup to future lessons — every networking and telemetry experiment you’ll do from here starts inside this VM.
What you built is more than just a sandbox: it’s your future test bench for curl, traceroute, tcpdump, and systemd services. Now that you have a Linux VM, you’re ready for the next lesson: Linux shell basics inside the VM — you’ll run a series of commands that will become second nature for DevOps work. Keep your VM ready; you’ll need it soon.
A final nudge: Before you move on, take one more snapshot of your clean system. Future-you will be grateful that you can always reset to a known-good state without losing progress.
Keep learning
Related tutorials, quizzes, and articles for this topic.
Discussion
Questions, corrections, and tips help everyone reading this page.
0 comments
Add a comment
No comments yet — start the thread.