>_ Operating systems & Linux

WSL: running Linux inside Windows without virtual machines

What the Windows Subsystem for Linux is, how to install it and pick a distribution, where to keep files for good performance and which limits to expect.

For years, anyone working on Windows who needed Linux tools had to choose between dual booting, a full virtual machine or partial compatibility tools. The Windows Subsystem for Linux, WSL, changed the picture: it lets you run a real Linux distribution, with its own shell and packages, inside Windows, opening it like an ordinary terminal window. For people who build websites, write scripts or are learning system administration, it is often the most convenient option.

WSL 1 and WSL 2

There are two versions with different architectures:

  • WSL 1 translated Linux system calls into Windows calls. There was no real Linux kernel, and some programs didn't work.
  • WSL 2 runs a real Linux kernel inside a lightweight virtual machine that Windows manages transparently. Compatibility is much broader and operations on Linux files are faster.

Today WSL 2 is the default and the one to use, except in particular cases where you need to work heavily on files stored on the Windows disk.

Installation

On current versions of Windows 10 and Windows 11 a single command from a terminal opened as administrator is enough:

wsl --install

The command enables the required components and installs Ubuntu as the default distribution. After rebooting you are asked to create a Linux user with its own password, which doesn't need to match your Windows one. To see the other available distributions and install a different one:

wsl --list --online
wsl --install -d Debian

Virtualisation must be enabled in the computer's firmware; on many laptops it already is, otherwise it has to be switched on in the UEFI settings.

Useful management commands

From the Windows terminal, PowerShell or Command Prompt:

Command Effect
wsl -l -v lists installed distributions and their version
wsl --shutdown shuts down all distributions and the virtual machine
wsl --update updates the WSL component and the kernel
wsl --set-default Debian chooses the default distribution
wsl --export Ubuntu ubuntu.tar creates a complete copy of the distribution
wsl --import restores or duplicates a distribution from an archive

--export is a simple way to back up the whole environment before a risky experiment. Inside the distribution you then use the normal package manager: sudo apt update && sudo apt upgrade on Ubuntu and Debian.

Where to keep files

This is the point that makes the biggest difference to performance. The two worlds can see each other:

  • from Linux, the Windows drives are mounted at /mnt/c, /mnt/d and so on;
  • from Windows, Linux files can be reached in File Explorer at \\wsl$\Ubuntu or \\wsl.localhost\Ubuntu.

Crossing this boundary has a cost, though. With WSL 2, a project stored in /mnt/c/Users/... and built or managed by Linux tools is noticeably slower than the same project in the Linux home, for example ~/projects. The practical rule: files that Linux tools work on belong in the Linux filesystem. Modern editors can open a folder inside WSL and run their extensions there, so you edit from Windows without losing speed.

From Linux you can open the current folder in File Explorer with explorer.exe ., and in general launch Windows programs by giving their name with the .exe extension.

Networking, resources and graphical programs

Services started in WSL, such as a development server on port 3000, are normally reachable from Windows at localhost. The virtual machine uses part of the computer's memory and processors; the limits are set in the .wslconfig file in the Windows user folder, with entries such as memory= and processors=. If memory usage stays high after heavy use, wsl --shutdown frees it.

On recent versions WSL also supports Linux applications with a graphical interface, which appear as ordinary Windows windows, and access to the graphics card for compute workloads, where the drivers allow it.

Enabling systemd

Many Linux guides assume systemd for managing services. In current versions of WSL you can enable it by adding the file /etc/wsl.conf to the distribution with:

[boot]
systemd=true

and restarting with wsl --shutdown. New Ubuntu installations often have it enabled already.

Limits to be aware of

  • It is not a server: when you close all the windows, the distribution is stopped shortly afterwards.
  • Performance on Windows files remains lower than on Linux files.
  • Direct hardware access is limited; USB devices need additional tools to be attached.
  • It doesn't replace a real installation if you want to try a complete Linux desktop environment or test drivers.

In my work, WSL is what I recommend to people who need to learn the Linux command line without leaving Windows: mistakes have no consequences, and a broken distribution can be reinstalled in a few minutes.

In short

  • WSL 2 runs a real Linux kernel in a lightweight, transparent virtual machine.
  • wsl --install sets everything up; wsl -l -v, --shutdown and --export cover management.
  • Projects used by Linux tools should live in the Linux home, not in /mnt/c.
  • .wslconfig caps memory and processors; /etc/wsl.conf lets you enable systemd.
  • It is ideal for development and learning, not as an always-on server.
MM
Marco Marzaduri

Marco Marzaduri works in cybersecurity, digital forensics and web development. With degrees in computer science and psychology, he combines technical analysis with an understanding of the human factor.

Read also