DEV Community

Cover image for Windows Subsystem for Linux (WSL) Installation and Configuration Guide
Dhananjay Haridas
Dhananjay Haridas

Posted on • Edited on

Windows Subsystem for Linux (WSL) Installation and Configuration Guide

This comprehensive guide offers detailed instructions on setting up and configuring Ubuntu within the Windows Subsystem for Linux (WSL). WSL is a compatibility layer provided by Microsoft that enables users to run native Linux command-line tools directly on Windows 10 and Windows 11. By integrating a Linux kernel interface, WSL bridges the gap between the Windows and Linux ecosystems, providing users with the flexibility to leverage the strengths of both operating systems without the need for dual-booting or virtual machines.

Why Use WSL?

  • Seamless Integration: With WSL, users can seamlessly integrate Linux tools and utilities into their Windows workflow, enhancing productivity and development capabilities.

  • Compatibility: WSL ensures compatibility with a wide range of Linux software, allowing users to run popular applications, programming languages, and development environments natively on Windows.

  • Resource Efficiency: Unlike traditional virtual machines, WSL offers lightweight resource utilization, minimizing overhead and maximizing system performance.

  • Development Environment: WSL provides developers with a familiar Linux environment for software development, enabling them to utilize command-line tools, package managers, and development frameworks seamlessly.

Installing WSL (Windows Subsystem for Linux)

  1. Open PowerShell as Administrator: Right-click the Start menu, then select "Windows PowerShell (Admin)".

  2. Install WSL: Run the following command in PowerShell:

   wsl --install
Enter fullscreen mode Exit fullscreen mode

This command will enable the WSL feature on your system.

Switching to WSL 2

  1. Set Default WSL Version to 2: After installing WSL, switch to WSL 2 by running:
   wsl --set-default-version 2
Enter fullscreen mode Exit fullscreen mode

This ensures that any new Linux distributions installed will use WSL 2.

Managing Linux Distributions

  1. List Available Linux Distributions: To see all available Linux distributions in the Microsoft Store, use:
   wsl --list --online
Enter fullscreen mode Exit fullscreen mode

This command will display a list of Linux distributions that you can install.

  1. Install Ubuntu: If you choose Ubuntu, you can install it directly using:
   wsl --install -d Ubuntu
Enter fullscreen mode Exit fullscreen mode

This command will download and set up Ubuntu on your system.

  1. Check Installed Distributions: To see which Linux distributions are installed and their versions, run:
   wsl -l -v
Enter fullscreen mode Exit fullscreen mode

This will list all installed distributions along with their respective versions.

Configuring Ubuntu

  1. Set Default Distribution: If Ubuntu is not your default distribution, you can set it using:
   wsl --setdefault Ubuntu
Enter fullscreen mode Exit fullscreen mode

This will make Ubuntu the default distribution to launch when using WSL.

  1. Configure Ubuntu: After setting Ubuntu as default, update its package lists by running:
   sudo apt update
Enter fullscreen mode Exit fullscreen mode

This ensures that you have the latest package information.

This Markdown document provides a step-by-step guide for installing, managing, and configuring WSL with Ubuntu on your Windows system.
Enter fullscreen mode Exit fullscreen mode

Top comments (3)

Collapse
 
indraja profile image
indrajanambiar

This guide has been very helpful. Thank you.

Collapse
 
subi_ss_c1f0156f1294e770 profile image
Subi S S

Thanks🤞.Very useful information!!!

Collapse
 
agraj_pdas_f7d46bca700fd profile image
Agraj P Das

Was so helpful. Great article