Getting Started with WSL (Windows Subsystem for Linux): A Step-by-Step Guide

Updated: July 31, 2025, 01:44 PM IST

Transform Your Windows Machine into a Powerful Linux Development Environment

Introduction to WSL (Windows Subsystem for Linux)

WSL lets you run Linux directly on your Windows computer— no need for heavy virtual machines or dual-boot setups. It gives you access to real Linux tools and environments while still using your regular Windows apps.

With WSL, developers and system admins can use Linux commands, install packages, run servers, and work on open-source projects — all from Windows. WSL 2 makes this even better by using a lightweight virtual machine for faster performance and better compatibility.

This guide will help you install, set up, and use WSL for everyday tasks, making Linux easy and accessible right from your Windows desktop.

1. What is WSL and Why Use It?

WSL is a compatibility layer for running Linux distributions (like Ubuntu, Debian, Fedora) natively on Windows.

Why use WSL?

  • Run Linux tools (Git, Python, Node.js, etc.) alongside Windows apps.
  • Access Linux file systems and commands from Windows.
  • Ideal for developers, data scientists, and Linux learners.

2. Installing WSL

Step 1 – Enable WSL

You can now set up WSL with just one command:

  1. Open PowerShell or Command Prompt as an administrator.
    (Right-click and choose "Run as administrator".)
  2. Type this command and press Enter:
bash
Copy Copied!
wsl --install

This installs WSL, the default Linux kernel, and Ubuntu as the default distro. (On Windows 10, you may need to enable features manually.)

3. Restart your computer when it asks you to.

This command will:

  • Turn on everything Windows needs to run WSL.
  • Download and install Ubuntu Linux (you can change this later if you want).

The first time you open Ubuntu after installation, it will take a few minutes to set up.
After that, it will open almost instantly.

If you are using an older version of Windows and this doesn’t work, you can follow the manual installation steps.

Choosing a Different Linux Distribution

By default, WSL installs Ubuntu, but you can pick another Linux distribution.

  • To install a specific one:
    wsl --install -d <DistributionName>
    (Replace <DistributionName> with the name, like Debian or Kali.)
  • To see all available distributions:
    wsl --list --online
    or
    wsl -l -o

You can use the same wsl --install -d <name> command anytime to add more distributions later.

Step 2 – Restart Your Computer

After installation, restart Windows.

Step 3 – Setup Ubuntu

On first launch, you’ll be asked to:

  • Choose a username
  • Set a password for your Linux user

For more details, check the official Microsoft WSL installation guide:

3. Launching WSL

You can now open Ubuntu (or another installed distro) in several ways:

  • Open Command Prompt/PowerShell and type:
bash
Copy Copied!
wsl


  • Or specify a distribution:
bash
Copy Copied!
wsl -d Ubuntu

  • Or open directly from the Start Menu.

4. Using wsl Commands

Here are the main wsl commands you can use in PowerShell or Command Prompt:

View Installed Distributions

wsl --list --verbose

Shows all installed Linux distributions and their WSL version.

Run a Linux Command Without Entering the Shell

wsl -- ls -la

Set Default Distro

wsl --set-default Ubuntu

Convert Between WSL 1 and WSL 2

wsl --set-version Ubuntu 2

Shutdown WSL

wsl --shutdown

Update the Kernel

wsl --update

Export and Import a Distro

Export:

bash
Copy Copied!
wsl --export Ubuntu D:\backup\ubuntu.tar

Import:

bash
Copy Copied!
wsl --import MyDistro D:\wsl\ D:\backup\ubuntu.tar

5. Working Inside Ubuntu

Once inside WSL, you are using a real Linux terminal. You can use all the normal Linux commands:

Update the Package List

sudo apt update
sudo apt upgrade

bash
Copy Copied!
sudo apt update && sudo apt upgrade

Install Software

bash
Copy Copied!
sudo apt install git python3 nodejs

Basic Linux Commands

  • Navigate:
    cd /mnt/c/Users
  • View files:
    ls -la
  • Create files:
    touch test.txt

Run Windows Apps from Linux

notepad.exe test.txt
explorer.exe .

6. File Access

  • From Linux to Windows:
    Windows drives are mounted at /mnt/c, /mnt/d, etc.
  • From Windows to Linux:
    Type \\wsl$ in File Explorer to open Linux files.

7. Useful Shortcuts

  • Open the current Linux directory in File Explorer:
    explorer.exe .
  • Check system info:
    uname -a
  • Stop all WSL sessions:
    wsl --shutdown

8. What Can You Do Next?

  • Install Docker Desktop (integrates with WSL 2)
  • Use Linux tools for development (Python, Node, Rust)
  • Learn Bash scripting and Linux server management