Skip to main content

Command Palette

Search for a command to run...

How to setup WSL in Windows?

Published
3 min read
How to setup WSL in Windows?
A

Hey, I am a Full-stack developer with over 1.5 years of experience in building real-world end-to-end web applications. I am proficient in Next.js, Docker, MERN, CI & CD pipelines & AI integrations.

Introduction

Windows Subsystem for Linux (WSL) is a feature of Windows that allows you to run a Linux environment on your Windows machine, without the need for a separate virtual machine or dual booting.

The primary reason for developing WSL, according to Microsoft, was to allow developers who were using open-source tools to keep developing on Windows.

WSL offers numerous benefits over native windows operating system such as --

  • Linux environment on Windows – Use native Linux tools (bash, apt, Docker, Git) without dual-booting or virtual machines.

  • Lightweight and fast – Consumes far fewer resources than traditional VMs while delivering near-native performance.

  • Cross-Platform Development – With WSL, you can access the Windows file system from Linux & call Windows executables from Linux, or vice versa.

  • Enhanced VS Code Integration – The WSL extension lets you edit Linux files directly in VS Code and run commands in an integrated terminal—no context switching between Windows and Linux environments.

  • Cost-Effective Solution – Unlike virtual machines that require extra resources and licensing, WSL runs natively on Windows at zero additional cost.

Step-by-Step Guide

Step 1: Open Windows PowerShell as Administrator

Run this command.

## By default, it'll install Ubuntu
wsl --install
## To install a specific Linux Distro
wsl --install <distro_name>
## To install Debian
wsl --install Debian

You can see the list of available WSL distros by running this command.

wsl --list --online

Step 2: Set username & password for your WSL distro

After the installation is successful, it'll prompt you to create a username & password for your distro. Provide a suitable username & password.

After successful setup, you'll be automatically inside WSL.

Now, you can start to run commands here just like inside a Linux operating system.

Step 3: Launch WSL from Windows PowerShell

Now whenever you want to re-enter WSL, run this command in your Windows PowerShell.

wsl -d <distro_name>
## For ubuntu
wsl -d ubuntu

To set Ubuntu as your default WSL distro, run this command.

wsl --set-default <distro_name>
## To set ubuntu as default
wsl --set-default Ubuntu

How to exit WSL?

To exit the WSL environment, you can run these commands --

exit -> Ends current shell session.
logout -> Similar to exit, logs out of the shell.
Ctrl + D -> Keyboard shortcut for exit.

These closes the current shell session but does not stop the WSL instance if other processes are running.

To gracefully shutdown all the running WSL instances, use this command.

## From Windows PowerShell
wsl --shutdown

## Inside WSL
wsl.exe --shutdown

Limitations of WSL

While WSL has lots of upsides, it has some downsides too --

  • GUI Support Limitations – WSL does not support full GUI applications as well as a native Linux installation, which may be a drawback for users who rely heavily on GUIs.

  • File System Performance Issues – Accessing Windows files from WSL is significantly slower than native Linux file operations, impacting build times and file-heavy workflows.

  • Performance Limitations – While WSL is faster than native windows for everyday use, it can be noticeably slower than native Linux, especially for resource-intensive applications.

  • Memory Issues in WSL– When using WSL, you might encounter memory issues where WSL consumes a significant amount of RAM or runs out of memory.

Conclusion

WSL is excellent for development and CLI tools, but falls short for hardware-dependent tasks, GUI applications, performance-critical workflows, and resource-constrained machines. For those use cases, dual-boot or native Linux still remains superior.

54 views