Install Windows Subsystem for Linux on your EC2 Windows instance
There are two versions of Windows Subsystem for Linux (WSL) that you can install depending
on your instance type and instance operating system: WSL 1 and WSL 2. For .metal
instance types, you can install either WSL 1 or WSL 2. For all other instance types, the
following requirements apply:
-
For virtualized EC2 instances, you must install WSL 1.
-
For instances that run Windows Server, the operating system version must be one of the following to install WSL:
-
Windows Server 2019
-
Windows Server 2022
-
For more information about WSL, see the Windows Subsystem for Linux Documentation
Install WSL
The following instructions install WSL on an EC2 instance running Windows Server 2022.
For the instructions to install WSL on an EC2 instance running Windows Server 2019, see
Install WSL on previous versions of Windows Server
Install WSL 1
-
To install WSL, run the following standard installation command on your EC2 instance, but make sure to enable WSL 1 by including
--enable-wsl1
. By default, WSL 2 is installed. If your instance was launched using a virtualized instance type, you must complete step 3 in this procedure to set the version to WSL 1.wsl --install --enable-wsl1 --no-launch
-
Restart your EC2 instance.
shutdown -r -t 20
-
To configure WSL to use WSL 1, run the following command on your instance. For more information about setting the WSL version, see Manual installation steps for older versions of WSL
on the Microsoft Build website. wsl --set-default-version 1
-
Install the default distribution.
wsl --install
Install WSL 2
-
To install WSL, run the following standard installation command on your EC2 instance. By default, WSL 2 is installed. If you are installing WSL on a
.metal
instance, then this is the only step to perform.wsl --install
For more information, see Install Linux on Windows with WSL
on the Microsoft Build website.