WSL2 - The Linux Setup I Had All Along (But Never Used)

Aranya Dutta • 16 June 2026

#

I had WSL installed on my laptop for a long time.

I don’t remember when or why I installed it. Probably while following some tutorial or trying something out. But after installing it, I never really used it. It just sat there.

Recently, I decided to actually explore it.

What I found was surprisingly powerful.


Table of Contents


What Even Is WSL2?

WSL2 (Windows Subsystem for Linux) lets you run a real Linux environment inside Windows.

Without:

It gives you:


Is It a Virtual Machine?

Short answer: yes, but not like the ones you are used to.

WSL2 uses a lightweight virtual machine powered by Hyper-V.

The difference from VirtualBox:

So you get VM-level isolation with near-native usability.


How WSL Actually Works (Mental Model)

Think of it like this:

[ Windows OS ]
      ↓
[ Hyper-V (hidden) ]
      ↓
[ WSL2 lightweight VM ]
      ↓
[ Linux Kernel ]
      ↓
[ Distros (Ubuntu, Docker, etc) ]

This mental model cleared most of my confusion.


Where Does Linux Live in My System?

Each WSL distro is stored as a .vhdx file.

This is a virtual hard disk containing the entire Linux filesystem.

Example locations:

So your “Linux system” is basically a single growing file.


Why I Was Seeing Docker Instead of Linux

When I first opened WSL, I saw:

docker-desktop:/#

I thought my system was broken.

Turns out:

So I wasn’t in Ubuntu. I was inside Docker’s internal environment.


Installing My Own Linux (Ubuntu)

I installed Ubuntu using:

wsl --install -d Ubuntu

Then:


Moving WSL from C Drive to D Drive

Since C drive space was limited, I moved it:

wsl --export Ubuntu D:\WSL\ubuntu.tar
wsl --unregister Ubuntu
wsl --import Ubuntu D:\WSL\Ubuntu D:\WSL\ubuntu.tar --version 2

Now my Linux system lives entirely in D:.


Understanding the File System (Windows ↔ Linux)

One of the most useful features:

Windows drives are mounted inside Linux:

So I can do:

cd /mnt/d/my-project

No copying required.


VS Code Integration (This Surprised Me)

From inside WSL:

code .

VS Code opens — using my Windows installation.

What’s happening:

VS Code (Windows UI)
        ↓
WSL Extension
        ↓
Linux Environment (runs code)

So:


Running Servers and Accessing Them

If I run a server in WSL:

npm start

And it runs on:

localhost:3000

I can open it directly in my Windows browser.

No configuration needed.


Windows vs Linux: Where Do I Install Things?

This was my biggest confusion.

Clear rule:

Windows:

WSL Linux:

Important: Installing something in Linux does NOT make it available in Windows.

They are separate environments.


Docker and WSL (Important Separation)

Docker uses WSL internally, but:

Docker Desktop
   ↓
docker-desktop (WSL distro)
   ↓
Containers

Ubuntu (your dev environment)

The Git Issue I Faced

Same project, same folder:

This happens because:

Lesson: Avoid mixing Git operations across Windows and WSL.

Pick one environment.


Disk Usage and Why It Keeps Growing

WSL uses .vhdx files.

Important behavior:

This is why Docker storage suddenly becomes huge.

You need manual compaction to shrink it.


Root Access and sudo vs su

I tried:

su

It failed.

Because:

Correct way:

sudo <command>

What WSL Is Actually Useful For

At first I thought it’s just for learning Linux commands.

It’s not.

It is useful for:

It replaces:


What I Am Planning Next

Now that I understand WSL:


Final Thought

I had this installed for months.

Never used it.

Turns out, it was one of the most useful tools already sitting in my system.


This is Part 1.

Part 2 covers my Git setup and development workflow inside WSL.