DEV Community

Cover image for How to Install a Linux Distro Using WSL on Windows
Farhad Rahimi Klie
Farhad Rahimi Klie

Posted on

How to Install a Linux Distro Using WSL on Windows

If you use Windows but want a Linux development environment, you don't necessarily need dual boot, a virtual machine, or a second computer.

Windows Subsystem for Linux (WSL) lets you run a Linux distribution directly inside Windows.

In this guide, we'll install WSL, choose a Linux distribution, create a Linux user, and verify that everything is working.


What Is WSL?

WSL (Windows Subsystem for Linux) is a Windows feature that allows you to run Linux distributions alongside Windows.

You can use a Linux terminal and tools such as:

  • Bash
  • Git
  • GCC
  • Python
  • Rust
  • Node.js
  • Vim
  • SSH
  • Linux package managers

without installing Linux as a separate operating system.

For developers, WSL is especially useful because you can keep Windows for your normal desktop applications while using Linux tools for development.


Requirements

Before starting, make sure you're running a supported version of Windows.

Open PowerShell and run:

winver
Enter fullscreen mode Exit fullscreen mode

You can also check your Windows version with:

systeminfo
Enter fullscreen mode Exit fullscreen mode

For the easiest installation method, use a modern Windows 10 or Windows 11 system with WSL support.


1. Open PowerShell as Administrator

Press:

Windows + X
Enter fullscreen mode Exit fullscreen mode

Then select:

Windows PowerShell (Admin)
Enter fullscreen mode Exit fullscreen mode

or:

Terminal (Admin)
Enter fullscreen mode Exit fullscreen mode

You should see a terminal window with administrator privileges.


2. Install WSL

The easiest method is:

wsl --install
Enter fullscreen mode Exit fullscreen mode

This command enables the required Windows components, installs the WSL components, and normally installs Ubuntu as the default Linux distribution.

After installation, Windows may ask you to restart your computer.

Restart:

shutdown /r /t 0
Enter fullscreen mode Exit fullscreen mode

After Windows starts again, the Linux distribution setup should continue.


3. Check Available Linux Distributions

You don't have to use Ubuntu.

To see the distributions available through WSL, run:

wsl --list --online
Enter fullscreen mode Exit fullscreen mode

You may see distributions such as:

NAME
Ubuntu
Debian
kali-linux
openSUSE-Tumbleweed
Ubuntu-24.04
Enter fullscreen mode Exit fullscreen mode

The exact list can change over time.


4. Install a Specific Linux Distribution

For example, to install Ubuntu:

wsl --install -d Ubuntu
Enter fullscreen mode Exit fullscreen mode

Or, if you want Debian:

wsl --install -d Debian
Enter fullscreen mode Exit fullscreen mode

You can replace the distribution name with one from:

wsl --list --online
Enter fullscreen mode Exit fullscreen mode

For example:

wsl --install -d Ubuntu-24.04
Enter fullscreen mode Exit fullscreen mode

5. Create Your Linux User

After the distribution starts for the first time, Linux will ask you to create a username.

For example:

Enter new UNIX username:
Enter fullscreen mode Exit fullscreen mode

You might enter:

farhad
Enter fullscreen mode Exit fullscreen mode

Then create a password.

When typing the password, nothing will appear on the screen.

That's normal behavior in Linux terminals.

Type the password and press Enter.


6. Verify the Installation

Inside your Linux terminal, run:

uname -a
Enter fullscreen mode Exit fullscreen mode

Then:

cat /etc/os-release
Enter fullscreen mode Exit fullscreen mode

You should see information about your Linux distribution.

You can also check the current user:

whoami
Enter fullscreen mode Exit fullscreen mode

And check your home directory:

pwd
Enter fullscreen mode Exit fullscreen mode

You should get something similar to:

/home/farhad
Enter fullscreen mode Exit fullscreen mode

Your Linux environment is now running.


7. Check WSL From Windows

Close the Linux terminal and open PowerShell.

Run:

wsl --list --verbose
Enter fullscreen mode Exit fullscreen mode

You should see something similar to:

  NAME      STATE           VERSION
* Ubuntu    Running         2
Enter fullscreen mode Exit fullscreen mode

The important part is:

VERSION
2
Enter fullscreen mode Exit fullscreen mode

That means you're using WSL 2.

WSL 2 uses a lightweight virtualized Linux environment and provides much better Linux compatibility than the original WSL 1 architecture.


8. Start Your Linux Distribution

You can start your default distribution by simply running:

wsl
Enter fullscreen mode Exit fullscreen mode

Or you can specify a distribution:

wsl -d Ubuntu
Enter fullscreen mode Exit fullscreen mode

For Debian:

wsl -d Debian
Enter fullscreen mode Exit fullscreen mode

You can also see installed distributions with:

wsl -l
Enter fullscreen mode Exit fullscreen mode

9. Update Linux

After installing Linux, update its package information.

For Ubuntu or Debian:

sudo apt update
Enter fullscreen mode Exit fullscreen mode

Then upgrade installed packages:

sudo apt upgrade
Enter fullscreen mode Exit fullscreen mode

You can combine them:

sudo apt update && sudo apt upgrade
Enter fullscreen mode Exit fullscreen mode

It's a good idea to do this before installing development tools.


10. Access Windows Files From Linux

One of the useful features of WSL is that you can access your Windows drives.

Your Windows C: drive is normally available at:

/mnt/c
Enter fullscreen mode Exit fullscreen mode

For example:

cd /mnt/c
Enter fullscreen mode Exit fullscreen mode

You can see your Windows files:

ls
Enter fullscreen mode Exit fullscreen mode

Your Windows user directory might be accessible through:

cd /mnt/c/Users
Enter fullscreen mode Exit fullscreen mode

This makes it possible to work between Windows and Linux.


11. Access Linux Files From Windows

WSL also provides a way to access your Linux filesystem from Windows.

From Windows File Explorer, you can enter:

\\wsl$
Enter fullscreen mode Exit fullscreen mode

in the address bar.

You should see your installed WSL distributions.

For example:

\\wsl$\Ubuntu
Enter fullscreen mode Exit fullscreen mode

This allows Windows applications to interact with files inside your Linux environment.

For development projects, however, it's generally best to keep Linux-oriented projects inside the Linux filesystem rather than constantly working across /mnt/c.


12. Install Development Tools

Now you can use Linux normally.

For example, install Git:

sudo apt install git
Enter fullscreen mode Exit fullscreen mode

Install GCC:

sudo apt install build-essential
Enter fullscreen mode Exit fullscreen mode

Check GCC:

gcc --version
Enter fullscreen mode Exit fullscreen mode

Install Vim:

sudo apt install vim
Enter fullscreen mode Exit fullscreen mode

Now you have a basic Linux development environment running inside Windows.


Installing Another Distribution Later

You can install multiple Linux distributions on the same Windows installation.

For example:

wsl --install -d Debian
Enter fullscreen mode Exit fullscreen mode

Then check them:

wsl --list --verbose
Enter fullscreen mode Exit fullscreen mode

You might have:

  NAME      STATE           VERSION
* Ubuntu    Stopped         2
  Debian    Stopped         2
Enter fullscreen mode Exit fullscreen mode

You can start Debian with:

wsl -d Debian
Enter fullscreen mode Exit fullscreen mode

Making a Distribution Your Default

If you have multiple distributions installed, you can choose which one starts when you run:

wsl
Enter fullscreen mode Exit fullscreen mode

For example:

wsl --set-default Debian
Enter fullscreen mode Exit fullscreen mode

Now:

wsl
Enter fullscreen mode Exit fullscreen mode

will start Debian by default.


Useful WSL Commands

Here are some commands you'll use frequently.

List installed distributions

wsl --list --verbose
Enter fullscreen mode Exit fullscreen mode

List available distributions

wsl --list --online
Enter fullscreen mode Exit fullscreen mode

Start WSL

wsl
Enter fullscreen mode Exit fullscreen mode

Start a specific distribution

wsl -d Ubuntu
Enter fullscreen mode Exit fullscreen mode

Shut down WSL

wsl --shutdown
Enter fullscreen mode Exit fullscreen mode

Stop a specific distribution

wsl --terminate Ubuntu
Enter fullscreen mode Exit fullscreen mode

Check WSL version

wsl --version
Enter fullscreen mode Exit fullscreen mode

Update WSL

wsl --update
Enter fullscreen mode Exit fullscreen mode

Set the default distribution

wsl --set-default Ubuntu
Enter fullscreen mode Exit fullscreen mode

Common Problems

wsl --install Doesn't Work

First check whether WSL is available:

wsl --status
Enter fullscreen mode Exit fullscreen mode

Then try:

wsl --update
Enter fullscreen mode Exit fullscreen mode

You may also need to enable Windows virtualization features or restart Windows after enabling WSL.


The Distribution Download Fails

If you receive a network-related error while installing a distribution, check your internet connection first.

You can also check the available distributions:

wsl --list --online
Enter fullscreen mode Exit fullscreen mode

Then retry the installation:

wsl --install -d Debian
Enter fullscreen mode Exit fullscreen mode

Check Whether Virtualization Is Enabled

Open Task Manager:

Ctrl + Shift + Esc
Enter fullscreen mode Exit fullscreen mode

Go to:

Performance → CPU
Enter fullscreen mode Exit fullscreen mode

Look for:

Virtualization: Enabled
Enter fullscreen mode Exit fullscreen mode

If virtualization is disabled, you may need to enable the appropriate virtualization setting in your computer's UEFI/BIOS.


WSL vs Dual Boot

WSL and dual boot solve different problems.

With dual boot, you install Windows and Linux as separate operating systems and choose one when the computer starts.

With WSL, Linux runs alongside Windows.

For development, WSL can be much more convenient because you don't need to reboot your computer every time you want to use Linux.

A simple setup might look like:

Windows
   │
   └── WSL 2
        │
        ├── Ubuntu
        ├── Debian
        └── Other Linux distributions
Enter fullscreen mode Exit fullscreen mode

Conclusion

Installing Linux with WSL is one of the easiest ways to get a Linux development environment on Windows.

The basic workflow is:

wsl --install
Enter fullscreen mode Exit fullscreen mode

Then:

wsl --list --online
Enter fullscreen mode Exit fullscreen mode

Choose a distribution:

wsl --install -d Ubuntu
Enter fullscreen mode Exit fullscreen mode

Start it:

wsl
Enter fullscreen mode Exit fullscreen mode

And verify it:

uname -a
Enter fullscreen mode Exit fullscreen mode

Once it's installed, you can use Linux tools, package managers, compilers, Git, editors, programming languages, and other development tools directly from Windows.

Windows doesn't have to mean giving up the Linux development environment. With WSL, you can have both.

Top comments (0)