WSL2 (Windows Subsystem for Linux 2) lets you run a real Linux environment inside Windows, ideal for managing servers, running scripts and developing web apps. Under the hood it uses a lightweight virtual machine with a genuine Linux kernel. This guide explains WSL2 and how to use it for server work.
Before you start
- Windows 10 (recent build) or Windows 11 with virtualization enabled in firmware; see enable VT-x/AMD-V.
- Administrator rights to install.
How WSL2 works
- Windows runs a small utility VM on the Hyper-V platform with a Microsoft-maintained Linux kernel.
- Each distribution (Ubuntu, Debian, etc.) runs as a container-like environment inside that VM.
- It starts in seconds and shares files and networking with Windows.
Install WSL2
In an administrator PowerShell:
wsl --installThis installs WSL and Ubuntu by default. Restart when asked, then create your Linux username and password. List and install other distributions:
wsl --list --onlineUse it for server work
- SSH: generate keys in WSL with
ssh-keygen -t ed25519and connect to your VPS; see first steps on a new VPS. - Ansible and Terraform: run them from WSL as from any Linux machine; see Ansible.
- VS Code: install the WSL extension and open projects inside Linux with
code .. - Docker: Docker Desktop can use the WSL2 backend, or install Docker Engine directly inside a distribution.
File performance tip
Keep project files inside the Linux filesystem (e.g. ~/projects), not under /mnt/c. Cross-filesystem access is much slower. From Windows, open Linux files at \\wsl$.
Networking
- Services running in WSL are usually reachable from Windows on
localhost. - Recent Windows versions offer a mirrored networking mode (configured in
.wslconfig) that improves VPN and IPv6 compatibility.
Limit resources
Create %UserProfile%\.wslconfig:
[wsl2]
memory=4GB
processors=2Then run wsl --shutdown to apply.
WSL2 vs a VM vs a VPS
| WSL2 | Local VM (VirtualBox, Hyper-V) | VPS | |
|---|---|---|---|
| Setup effort | Minimal | Moderate | Minimal |
| Feels like a real server | Partly | Yes | Yes, with a public IP |
| Best for | Tools and development | Labs, testing OS installs | Hosting real services |
Frequently asked questions
Does WSL2 conflict with VirtualBox or VMware?
Modern versions of both can run alongside Hyper-V, sometimes with lower performance.
Can I host a website from WSL2?
For local testing, yes. For public hosting, use a VPS or web hosting.
Is systemd supported?
Yes, recent WSL versions support systemd when enabled in /etc/wsl.conf.
