Back to all posts

Install WSL and Ubuntu on Windows the Modern Way

A step-by-step guide to installing WSL and Ubuntu from PowerShell, confirming WSL 2, and preparing Ubuntu for development.

When I installed Windows Subsystem for Linux, also called WSL, I opened PowerShell as administrator and ran one command. Windows downloaded WSL and Ubuntu, then the same terminal took me directly into Ubuntu. I did not have to restart Windows.

This guide follows that path. Some computers may still ask for a restart, so I include that as an exception instead of making it part of the main steps.

Watch the video

What this setup gives you

  • WSL installed on Windows
  • WSL 2 as the default for new Linux distributions
  • The default Ubuntu distribution
  • A Linux terminal and home directory for development work

For the normal setup, you do not need to enable Windows features by hand or install Ubuntu separately from the Microsoft Store.

What you need

  • Windows 11 or Windows 10 version 2004, build 19041, or higher
  • An administrator account
  • An internet connection

Step 1: Open PowerShell as administrator

  • Open the Windows Start menu.
  • Search for PowerShell.
  • Run PowerShell as administrator.
  • Approve the Windows security prompt if it appears.

The installation command needs administrator access because it enables and installs Windows components.

Step 2: Install WSL and Ubuntu

Run this command in the administrator PowerShell window:

wsl --install

This command:

  • installs WSL
  • sets WSL 2 as the default for new Linux distributions
  • installs the default Ubuntu distribution

What happened for me:

  • WSL and Ubuntu started downloading in the PowerShell window.
  • When the installation finished, the same terminal took me directly into Ubuntu’s first-time setup.
  • Windows did not ask me to restart.

If your terminal does the same, continue to Step 3. If Windows explicitly asks you to restart, restart it, open Ubuntu from the Start menu, and then continue to Step 3.

If it prints WSL help text instead of installing Ubuntu, WSL may already be installed. Skip to If WSL is already installed.

Step 3: Create your Linux user

  • Wait while Ubuntu finishes its first-time setup.
  • Create a Linux username and password when prompted.
  • Continue when the Ubuntu shell prompt appears.

Your Linux password is separate from your Windows password. The terminal does not display characters while you type the password. That is normal.

Step 4: Update Ubuntu

You are already in the Ubuntu shell. Run:

sudo apt update
sudo apt upgrade -y

Important notes:

  • sudo runs a command with administrator access inside Ubuntu.
  • Enter the Linux password you created during setup when prompted.
  • The terminal does not display characters while you type the password.

For development work, I also install these basic packages:

sudo apt install -y git curl ca-certificates build-essential

Using sudo is normal for system packages installed with apt. Later, when installing Node.js with nvm, do not use sudo for Node or npm commands.

Step 5: Create a folder for your projects

Keep development projects inside your Ubuntu home directory:

mkdir -p ~/code
cd ~/code

Why I use this location:

  • Linux development tools can work directly with the files.
  • Node.js, Python, and web development tools generally work better here than under /mnt/c/Users/....
  • Windows can still access these files through WSL when needed.

Step 6: Confirm Ubuntu is using WSL 2

Leave the Ubuntu shell:

exit

This returns you to the PowerShell window where the installation started. If the terminal closes instead, open PowerShell.

Run:

wsl --list --verbose

The shorter form of the same command is:

wsl -l -v

Read the output and confirm:

  • Ubuntu appears in the distribution list.
  • The version column for Ubuntu is 2.

If Ubuntu shows version 1, skip to If Ubuntu is using WSL 1.

Step 7: Use VS Code with WSL

  • Install VS Code on Windows.
  • Open the Extensions view in VS Code.
  • Search for WSL.
  • Install the WSL extension published by Microsoft.

From PowerShell, return to Ubuntu:

wsl

Move into your projects folder and open it in VS Code:

cd ~/code
code .

VS Code opens on Windows, while the project files, terminal, and development commands run in Ubuntu.

If WSL is already installed

If wsl --install prints help text instead of installing Ubuntu:

  • List the Linux distributions available through WSL:

    wsl --list --online
  • Install the default Ubuntu distribution:

    wsl --install -d Ubuntu
  • Restart Windows if prompted.

  • Open Ubuntu and create your Linux username and password.

If you want a specific Ubuntu version

Most people can use the default Ubuntu distribution. If you need a specific numbered release:

  • List the available distributions:

    wsl --list --online
  • Copy the exact distribution name from the output.

  • Install that name. For example:

    wsl --install -d Ubuntu-24.04

The available names change over time, so use the name shown by wsl --list --online instead of guessing.

If Ubuntu is using WSL 1

If wsl --list --verbose shows that Ubuntu is using WSL 1:

  • Copy the exact Ubuntu distribution name from the output.

  • Run this command, replacing Ubuntu if your distribution has a different name:

    wsl --set-version Ubuntu 2
  • Run wsl --list --verbose again and confirm the version is now 2.

Converting a distribution can take time. Back up important project files before converting a distribution that already contains work.

If the installation stays at 0.0 percent

Microsoft documents a web-download option for an installation that stays at 0.0 percent:

wsl --install --web-download -d Ubuntu

Use the exact distribution name from wsl --list --online if you are installing a different Ubuntu version.

Once WSL and Ubuntu are working, the next guide is Build and Deploy a Website with Astro and Firebase.

Sources and further reading