How to Install Linux on Windows 10/11 Using WSL | DevOps Tutorial

Learn how to install Linux on Windows 10 and Windows 11 using WSL. Step-by-step guide to installing Ubuntu, configuring WSL 2, and running Linux comma
Linux Networking, SSH, SCP, curl

How to Install Linux on Windows Using WSL

Want to learn Linux commands without removing Windows or setting up a traditional virtual machine? The Windows Subsystem for Linux (WSL) allows you to run a Linux distribution directly on your Windows computer. You can use Linux commands, Bash, development tools, and applications while continuing to use Windows.

In this guide, you will learn how to install WSL on Windows 10 or Windows 11, install Ubuntu, configure your Linux user account, check your WSL version, and run basic Linux commands.

What Is Windows Subsystem for Linux (WSL)?

Windows Subsystem for Linux (WSL) is a Windows feature that allows you to run a Linux environment directly on your Windows computer without requiring a traditional dual-boot setup.

With WSL, you can install Linux distributions such as Ubuntu, Debian, Kali Linux, openSUSE, and other supported distributions. It is particularly useful for developers, students, and DevOps beginners who want to practice Linux commands on a Windows machine.

Benefits of Using WSL

  • Run Linux commands directly on Windows.
  • Practice Linux administration and command-line tools.
  • Learn DevOps tools and development workflows.
  • Use Bash and Linux utilities without dual-booting.
  • Work with development tools such as Git and Visual Studio Code.
  • Run supported Linux distributions alongside Windows applications.

Prerequisites for Installing WSL

Before installing WSL, make sure your computer meets the following requirements.

Requirement Details
Operating System Windows 11 or Windows 10 version 2004 and higher
Windows Build Windows 10 build 19041 or higher for the standard installation command
Terminal Windows PowerShell or Windows Terminal
Permissions Administrator privileges for installation
Internet Internet connection for downloading WSL and a Linux distribution

Info!
If you are using an older Windows version, you may need to follow Microsoft's manual WSL installation instructions.

Step 1: Open PowerShell as Administrator

First, open PowerShell with administrator privileges.

  1. Click the Windows Start menu.
  2. Search for PowerShell or Windows Terminal.
  3. Right-click the application.
  4. Select Run as administrator.
  5. Approve the User Account Control prompt if it appears.

After opening PowerShell, you are ready to install WSL.

Step 2: Install WSL with One Command

The easiest way to install WSL is by using the built-in installation command. It enables the required Windows features and installs Ubuntu as the default Linux distribution.

Run the following command in an administrator PowerShell window:

wsl --install
  1. Enter the command in PowerShell.
  2. Wait for Windows to download and install the required components.
  3. Restart your computer if prompted.
  4. Launch Ubuntu after installation.
  5. Wait for the initial Linux setup to finish.

The first time you launch Ubuntu, Windows prepares the Linux distribution. This may take a little time. After the initial setup, subsequent launches should generally be much faster.

Info!
New Linux installations made with the standard wsl --install command use WSL 2 by default.

Step 3: Install a Specific Linux Distribution

By default, WSL installs Ubuntu. If you want to install another supported Linux distribution, first check the available distributions.

Run this command in PowerShell:

wsl --list --online

The command displays the Linux distributions available for installation.

To install a particular distribution, use the following command:

wsl --install -d Debian

In this example, Debian is installed instead of the default Ubuntu distribution. Replace Debian with the exact distribution name shown in the online list.

Popular Linux Distributions for WSL

Distribution Best For
Ubuntu Linux beginners, development, and DevOps practice
Debian Stable Linux environments and server-related practice
Kali Linux Cybersecurity learning and authorized security testing
openSUSE Linux administration and development
Arch Linux Experienced users who want a customizable Linux environment

Step 4: Create Your Linux Username and Password

After Ubuntu launches for the first time, it will ask you to create a Linux user account.

  1. Enter a Linux username when prompted.
  2. Press Enter.
  3. Enter a password.
  4. Confirm the password if requested.
  5. Wait for the setup process to finish.

Your Linux username and password are separate from your Windows account credentials. When typing a password in the Linux terminal, the characters may not appear on the screen. This is normal behavior.

After completing the setup, you can start running Linux commands.

Step 5: Verify the WSL Installation

After installing WSL, check whether your Linux distribution is installed correctly.

Run the following command in PowerShell:

wsl --list --verbose

This command lists your installed Linux distributions and indicates whether each one uses WSL 1 or WSL 2.

Example output:

  NAME      STATE           VERSION
* Ubuntu    Stopped         2

The output may differ depending on the distributions installed and whether they are running.

Step 6: Understand WSL 1 and WSL 2

WSL has two versions: WSL 1 and WSL 2. WSL 2 uses an actual Linux kernel and provides benefits for many Linux workloads.

Feature WSL 1 WSL 2
Architecture Translation layer Uses a real Linux kernel
Linux kernel Does not use a full Linux kernel Uses a Linux kernel
Compatibility Supports many Linux command-line tools Offers broader compatibility for many Linux workloads
Default for new installations No Yes, with the standard installation command

Check Your Current WSL Version

Run this command in PowerShell:

wsl -l -v

Set WSL 2 as the Default Version

To configure WSL 2 as the default version for newly installed distributions, run:

wsl --set-default-version 2

Convert an Existing Distribution to WSL 2

If Ubuntu is currently using WSL 1, you can convert it to WSL 2 with this command:

wsl --set-version Ubuntu 2

Replace Ubuntu with the name of your installed distribution. The conversion may take some time.

Step 7: Set Your Default Linux Distribution

If you have installed multiple Linux distributions, you can select which distribution runs when you use the default wsl command.

For example, to make Debian your default distribution, run:

wsl --set-default Debian

To launch a particular distribution without changing the default, use:

wsl --distribution Ubuntu

Replace Ubuntu with the distribution you want to launch.

Step 8: Run Linux Commands on Windows

Once WSL is installed, you can run Linux commands in several ways.

Method 1: Open Ubuntu from the Start Menu

  1. Open the Windows Start menu.
  2. Search for Ubuntu.
  3. Click the Ubuntu application.
  4. Run Linux commands in the terminal window.

Method 2: Launch Linux from PowerShell

Open PowerShell and enter:

wsl

This opens your default Linux distribution in the current command-line session.

Method 3: Run a Linux Command Directly

You can also run a Linux command directly from PowerShell without opening a separate Linux shell.

For example:

wsl pwd
wsl date
wsl ls -la

These commands run Linux utilities through your default WSL distribution.

Exit the Linux Terminal

To exit a Linux shell, enter:

exit

Step 9: Use Windows Terminal with WSL

Windows Terminal is a convenient way to work with WSL. It supports multiple tabs and panes, allowing you to switch between Linux distributions, PowerShell, and Command Prompt.

  1. Install or open Windows Terminal.
  2. Open the terminal profile menu.
  3. Select Ubuntu or another installed Linux distribution.
  4. Open additional tabs when you need multiple shells.

You can customize terminal colors, fonts, window appearance, and keyboard shortcuts according to your preferences.

Step 10: Start Practicing Linux Commands

After installing Ubuntu, practice these basic Linux commands to become familiar with the terminal.

Command Purpose
pwd Displays the current working directory
ls Lists files and directories
ls -la Lists files, including hidden files, with detailed information
cd Changes the current directory
mkdir test Creates a directory named test
touch file.txt Creates an empty file
cat file.txt Displays the contents of a file
whoami Displays the current Linux username
sudo apt update Refreshes package information on Ubuntu and other compatible Debian-based distributions
clear Clears the terminal display

Warning!
Be careful when running commands that delete files or modify system settings. Learn what a command does before executing it.

Common WSL Problems and Solutions

Problem 1: The wsl --install Command Shows Help Text

If the command displays WSL help information instead of installing Linux, check which distributions are available:

wsl --list --online

Then try installing a distribution explicitly:

wsl --install -d Ubuntu

Problem 2: Installation Stays at 0%

If the distribution download remains stuck at 0%, Microsoft's documentation recommends trying the web-download option:

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

Problem 3: WSL Does Not Start Properly

Check your WSL installation and distribution status with:

wsl --status
wsl --list --verbose

Depending on the error, you may need to update WSL, restart Windows, or follow Microsoft's troubleshooting instructions.

Problem 4: An Older WSL Installation Needs Additional Components

If you installed WSL manually on an older Windows build, additional steps may be required to enable the Virtual Machine Platform feature and install the appropriate Linux kernel package for WSL 2.

Follow the official manual installation guide for instructions that match your Windows version.

How to Update WSL

To update WSL, open PowerShell and run:

wsl --update

To shut down running WSL distributions and the WSL 2 virtual machine, use:

wsl --shutdown

After updating, you can launch your Linux distribution again.

How to Uninstall a Linux Distribution

If you no longer need an installed distribution, you can unregister it using the appropriate WSL command.

For example, to unregister Ubuntu, run:

wsl --unregister Ubuntu

Warning!
Unregistering a Linux distribution permanently deletes its associated distribution data. Back up any important files before running this command.

Useful WSL Commands Cheat Sheet

Command Description
wsl --install Installs WSL and the default Linux distribution
wsl --list --online Lists available distributions
wsl --list --verbose Lists installed distributions and their WSL versions
wsl --status Displays WSL status information
wsl --update Updates WSL
wsl --set-default-version 2 Sets WSL 2 as the default for new distributions
wsl --set-version Ubuntu 2 Converts Ubuntu to WSL 2
wsl --set-default Ubuntu Sets Ubuntu as the default distribution
wsl --shutdown Shuts down running WSL distributions
wsl Opens the default Linux distribution

Frequently Asked Questions (FAQ)

Can I install Linux on Windows 11 without removing Windows?

Yes. WSL lets you run supported Linux distributions alongside Windows without removing your Windows installation or setting up a traditional dual-boot configuration.

Can I use WSL on Windows 10?

Yes. The standard installation command is supported on Windows 10 version 2004 and higher, with build 19041 or higher, as well as Windows 11. Older versions may require manual installation.

Which Linux distribution should a beginner install?

Ubuntu is a practical starting point for beginners because it is the default distribution in the standard WSL installation process and is widely used for development and Linux practice.

Is WSL 2 better than WSL 1?

WSL 2 uses an actual Linux kernel and offers broader compatibility for many Linux workloads. The most suitable version depends on your specific workflow.

Can I use WSL for DevOps learning?

Yes. WSL provides a Linux command-line environment where you can practice Linux commands and work with development tools. Tool compatibility and installation requirements may vary.

How do I open Ubuntu after installing WSL?

You can open Ubuntu from the Windows Start menu, select it from Windows Terminal, or run wsl in PowerShell if Ubuntu is your default distribution.

Conclusion

Windows Subsystem for Linux is a convenient way to learn Linux and practice development tasks without replacing Windows. With the wsl --install command, you can install WSL and Ubuntu, create a Linux user account, check your WSL version, and start practicing Linux commands.

If you are beginning your DevOps journey on Windows 10 or Windows 11, installing WSL is a useful first step before moving on to Linux administration, Git, networking, Docker, and other DevOps tools.

Official Resources

Related Posts
```

About the author

Daud
Hey! I'm Daud, Currently Working in IT Company BD. I always like to learn something new and teach others.

Post a Comment

To avoid SPAM, all comments will be moderated before being displayed.
Don't share any personal or sensitive information.