Save 10%Pay yearly on any plan. 6% half-yearly, 3% quarterly. Help centreWhatsAppTelegram TeamsOpen a ticket

How to Enable WSL on Windows Server 2022

Install Windows Subsystem for Linux on Windows Server 2022 with one command, choose between WSL 1 and WSL 2, and fix the errors you meet on a VPS.

3 min readBy Daniel

Reviewed by the AmazingRDP technical team

Enabling Windows Subsystem for Linux on Windows Server 2022

WSL 2 needs hardware virtualization, which a dedicated server has. See our dedicated server plans. See Cheap Dedicated Servers from $38.99

Windows Subsystem for Linux (WSL) runs a Linux distribution such as Ubuntu inside Windows, without a separate virtual machine to manage. Windows Server 2022 supports it, including WSL 2. On an updated server one command installs everything.

Before you start

  • Windows Server 2022 with current updates. The simple wsl --install command arrived on Server 2022 with an update in mid-2022. Install pending updates first.
  • Administrator rights.
  • For WSL 2: hardware virtualization. WSL 2 runs a small virtual machine. A dedicated server has what it needs. A VPS is already a virtual machine, and WSL 2 works there only if the provider has switched on nested virtualization. WSL 1 has no such requirement.

1. Install WSL

Open PowerShell as administrator and run:

wsl --install

This switches on the Windows features WSL needs, downloads the Linux kernel and installs Ubuntu. Restart the server when asked:

Restart-Computer

After the restart, sign in again. A window opens and finishes the Ubuntu setup; it asks you to choose a Linux user name and password. These are separate from your Windows login.

2. Choose another distribution (optional)

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

The first command lists what is available; the second installs the one you name.

3. Check it

wsl --list --verbose
wsl --status

The list shows each distribution, whether it is running, and whether it uses WSL version 1 or 2. Start Linux by typing wsl.

WSL 1 or WSL 2?

WSL 1WSL 2
How it worksTranslates Linux calls to WindowsRuns a real Linux kernel in a light virtual machine
Needs virtualizationNoYes
Works on a typical VPSYesOnly with nested virtualization
Docker, systemdNoYes
Speed inside Linux filesSlowerFaster

To use WSL 1 for new installations, and to convert an existing one:

wsl --set-default-version 1
wsl --set-version Ubuntu 1

If wsl --install does not work

The command only prints help text. The server lacks the update that added it. Install Windows updates, or switch the features on by hand, restart, and then update WSL:

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
Restart-Computer
wsl --update
wsl --install -d Ubuntu

"Please enable the Virtual Machine Platform Windows feature and ensure virtualization is enabled in the BIOS", or error 0x80370102. The machine cannot run WSL 2. On a VPS this means nested virtualization is off. Use WSL 1 (commands above), or run it on a dedicated server.

The distribution list will not download. The server cannot reach Microsoft's servers. Check the firewall and proxy settings.

Good to know on a server

  • WSL belongs to the user who installed it. Each Windows user has their own distributions.
  • WSL does not start with the server. Linux programs run while a WSL session is open; for a service that must always run, a real Linux server is the better tool.
  • Your Windows drives appear inside Linux under /mnt/c, /mnt/d and so on. The Linux files are reachable from Windows at \\wsl$.
  • Stop everything with wsl --shutdown.

Which machine to use

For WSL 2 with Docker, choose a dedicated server. If you only need Linux, a Linux VPS is simpler than Linux inside Windows. Related guides: fix "sudo: command not found" in Linux, copy and paste in Ubuntu Server and enable audio in Windows Server 2022.

Questions

Does Windows Server 2022 support WSL 2?

Yes, with current updates installed and hardware virtualization available to the machine.

Can I run WSL 2 on a VPS?

Only if the provider has enabled nested virtualization for the virtual machine. Otherwise use WSL 1.

What is the command to install WSL on Windows Server 2022?

wsl --install in PowerShell as administrator, then restart.

Does WSL keep running after I sign out?

Not reliably. WSL is tied to the user's session and does not start with the server.