Setting Up WSL2 on Windows

WSL2 (Windows Subsystem for Linux) is the easiest way to get a real Linux environment on Windows. Microsoft built it directly into Windows 10/11, and it runs at near-native speed.

Requirements

  • Windows 10 version 2004+ (Build 19041+) or Windows 11
  • Admin access on your computer
  • ~1GB disk space

Check Your Version

Press Win + R, type winver, and hit Enter. Make sure you're on build 19041 or higher.

Step 1: Enable WSL

Open PowerShell as Administrator (right-click Start > "Windows Terminal (Admin)" or search "PowerShell" > Run as Administrator).

Run this single command:

hljs powershell
wsl --install

That's it. This command:

  • Enables WSL
  • Enables Virtual Machine Platform
  • Downloads and installs Ubuntu (default)
  • Sets WSL2 as the default version

Restart Required

You'll need to restart your computer after this. Do it now.

Step 2: Set Up Ubuntu

After restart, Ubuntu will launch automatically (or search "Ubuntu" in Start menu).

You'll be asked to create a username and password:

Enter new UNIX username: yourname
New password: ********
Retype new password: ********

Username Tips

  • Use lowercase letters only
  • This is separate from your Windows username
  • Remember your password - you'll need it for sudo

Step 3: Update Your System

First thing you should always do with a fresh Linux install - update everything:

hljs bash
sudo apt update && sudo apt upgrade -y

Enter your password when prompted. You'll see packages being updated.

Step 4: Verify Your Setup

Let's make sure everything works:

hljs bash
# Check your Linux version
cat /etc/os-release

# Check your username
whoami

# Check your current directory
pwd

# List files
ls -la

If you see output for all these commands, you're ready to go.

Accessing Your Files

Your Windows files live at /mnt/c/ in WSL:

hljs bash
# Go to your Windows Documents folder
cd /mnt/c/Users/YourWindowsUsername/Documents

# List your Windows files from Linux
ls

Your Linux files live in a separate filesystem. To access them from Windows, type \\wsl$ in File Explorer.

Opening WSL

You can launch WSL anytime by:

  • Searching "Ubuntu" in Start menu
  • Opening Windows Terminal and selecting Ubuntu
  • Typing wsl in PowerShell or Command Prompt

Pro Tips

Make Windows Terminal your default: Windows Terminal is way better than the default console. Install it from Microsoft Store if you don't have it.

Set Ubuntu as default profile: Open Windows Terminal Settings > Startup > Default profile > Ubuntu

Install useful tools:

hljs bash
sudo apt install git curl wget htop tree -y

Troubleshooting

Common Mistakes

  • Wrong PowerShell: Make sure you're running PowerShell as Administrator, not regular PowerShell
  • Skipping restart: The restart after wsl --install is mandatory, not optional
  • Forgetting password: Write down your Linux password somewhere safe - you'll need it for sudo
  • Working in /mnt/c: For best performance, keep files in your Linux home (~), not Windows folders

"WSL 2 requires an update to its kernel component" Download and install the kernel update from: https://aka.ms/wsl2kernel

Ubuntu doesn't show up after install Run in PowerShell (Admin):

hljs powershell
wsl --list --online  # See available distros
wsl --install -d Ubuntu  # Install Ubuntu specifically

"The virtual machine could not be started" Enable virtualization in your BIOS. Restart, enter BIOS (usually F2, F12, or Del), find "Virtualization Technology" or "VT-x", enable it.

Slow filesystem when accessing /mnt/c That's normal - cross-filesystem operations are slower. Keep your project files in your Linux home directory (~) for best performance.

"Error: 0x80370102" Virtualization isn't enabled. Check your BIOS settings or run in PowerShell (Admin):

hljs powershell
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

You're Ready!

You now have a fully functional Ubuntu Linux environment. This is the same Ubuntu that runs on millions of servers worldwide.

Head back to the course introduction and start learning - remember to type every command in your new WSL terminal!

Knowledge Check

Where are your Windows C: drive files accessible in WSL?