{"id":8465,"date":"2023-12-23T00:20:14","date_gmt":"2023-12-23T00:20:14","guid":{"rendered":"https:\/\/cheapwindowsvps.com\/blog\/a-comprehensive-guide-to-installing-windows-subsystem-for-linux-wsl-on-various-windows-editions-and-server-core\/"},"modified":"2025-03-31T16:30:58","modified_gmt":"2025-03-31T16:30:58","slug":"a-comprehensive-guide-to-installing-windows-subsystem-for-linux-wsl-on-various-windows-editions-and-server-core","status":"publish","type":"post","link":"https:\/\/cheapwindowsvps.com\/blog\/a-comprehensive-guide-to-installing-windows-subsystem-for-linux-wsl-on-various-windows-editions-and-server-core\/","title":{"rendered":"A Comprehensive Guide to Installing Windows Subsystem for Linux (WSL) on Various Windows Editions and Server Core"},"content":{"rendered":"<div>For some time now, Microsoft has been offering a simplified installation of WSL via the wsl.exe utility. Hence, most guides refer to this method. However, in practice, it is not quite as straightforward because this command does not work on Server Core and is only suitable for WSL 2.<\/div>\n<p>Ideally, the Windows Subsystem should be installed, updated, or removed using the same command across all supported versions of Windows. However, this is not the case. The issue lies not in the different methods, all leading to the same goal, but in the inconsistencies between OS versions and WSL implementations.<\/p>\n<h2>Simple setup with wsl.exe<\/h2>\n<p>For the easy installation method, you only run this command:<\/p>\n<pre>wsl --install<\/pre>\n<p>It downloads WSL from the Microsoft Store and additionally installs the default Linux distribution, which is currently Ubuntu. If you prefer a different distro, you can specify it with the -d or &#8211;distribution switch.<\/p>\n<p>To find out the exact names of available distributions, run wsl.exe as follows:<\/p>\n<pre>wsl --list --online<\/pre>\n<div><a href=\"https:\/\/4sysops.com\/wp-content\/uploads\/2023\/12\/Display-available-Linux-distributions.png\" target=\"_blank\" rel=\"nofollow noopener\">Display available Linux distributions<\/a><\/div>\n<p>Display available Linux distributions<\/p>\n<p>To install Debian, use the following command:<\/p>\n<pre>wsl.exe --install -d Debian<\/pre>\n<h2>Limits of the simple installation<\/h2>\n<p>This simple <a href=\"https:\/\/4sysops.com\/archives\/install-windows-subsystem-for-linux-wsl-in-windows-11\/\" target=\"_blank\" rel=\"nofollow noopener\">installation using wsl.exe typically works on Windows 11<\/a> and <a href=\"https:\/\/4sysops.com\/archives\/install-subsystem-for-linux-2-wsl2-on-windows-server\/\" target=\"_blank\" rel=\"nofollow noopener\">Server 2022<\/a>, but only on the server with desktop. On Server Core, the command either aborts silently or hangs for an extended period, eventually exiting with an error 0xc004000d if virtualization extensions are not available (e.g., in a VM).<\/p>\n<p>Another limitation of this installation method is that it only supports WSL 2. If WSL 1 is needed, for instance, when running Windows in a VM where Nested Virtualization is not possible, you must install the WSL version that is still included with Windows. This optional feature includes WSL 2, but it is no longer updated.<\/p>\n<p>If you install the subsystem via wsl.exe, you will only get the second generation (WSL2)<\/p>\n<p>Basically, wsl.exe is also suitable for installing the subsystem shipped with Windows because it provides a dedicated switch:<\/p>\n<pre>wsl --install --inbox<\/pre>\n<p>The only difficulty ensues from the fact that wsl.exe does not accept the <em>&#8211;inbox<\/em> switch on Windows Server 2022 Core. Moreover, in Windows Server 2019, the WSL utility is accessible only post the installation of the optional feature.<\/p>\n<h2>Configuring WSL as an optional feature<\/h2>\n<p>If the Subsystem for Linux isn&#8217;t installable on a Windows version via wsl.exe, the conventional method has to be followed. This method involves leveraging the <em>Activate or Deactivate Windows features<\/em> within the Control Panel on a client; on the server, the task can be completed using the <em>Add Roles and Features Wizard<\/em>.<\/p>\n<div><a href=\"https:\/\/4sysops.com\/wp-content\/uploads\/2023\/12\/Add-subsystem-for-Linux-as-a-feature-in-Server-Manager..png\" target=\"_blank\" rel=\"nofollow noopener\">Add subsystem for Linux as a feature in Server Manager.<\/a><\/div>\n<p>Alternatively, execute this command in PowerShell:<\/p>\n<pre>Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux<\/pre>\n<p>On the server, you can also use:<\/p>\n<pre>Install-WindowsFeature -Name Microsoft-Windows-Subsystem-Linux<\/pre>\n<p>For Windows Server 2019, the job is completed at this point since it only supports WSL1. If you want to use WSL2 on Server 2022, you must now also activate the VM platform:<\/p>\n<pre>Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform<\/pre>\n<p>After a restart, you will have WSL2, but you still need to add the Linux kernel separately using:<\/p>\n<pre>wsl.exe --update<\/pre>\n<p>However, this will not work under Server Core, so you will be stuck with WSL1 even with Server 2022.<\/p>\n<p><a href=\"https:\/\/4sysops.com\/wp-content\/uploads\/2023\/12\/Executing-wsl---update-fails-on-Server-Core,-thus-preventing-the-download-of-the-Linux-kernel-for-WSL2.png\" target=\"_blank\" rel=\"nofollow noopener\">Executing wsl &#8211;update fails on Server Core, thus preventing the download of the Linux kernel for WSL2<\/a><\/p>\n<h2>Install previews<\/h2>\n<p>Similarly to other Windows components that undergo independent development from the operating system, for instance, PowerShell or Windows Terminal, you can experiment with WSL using the current preview versions.<\/p>\n<p>For this purpose, wsl.exe introduces the <em>&#8211;pre-release<\/em> option as a supplement to <em>&#8211;install<\/em>:<\/p>\n<pre>wsl --install --pre-release<\/pre>\n<p>Nonetheless, at present, this is exclusively supported on Insider previews of Windows 11. For other versions, it is requisite to <a href=\"https:\/\/github.com\/microsoft\/WSL\/releases\" target=\"_blank\" rel=\"nofollow noopener\">acquire the WSL installation file from GitHub<\/a> and execute it.<\/p>\n<p>If you want to upgrade a preview to the latest version, running<\/p>\n<pre>wsl --upgrade<\/pre>\n<p>will not achieve the goal. Instead, you need to remove the outdated preview first and then install the latest one with the above command.<\/p>\n<h2>Installation using winget<\/h2>\n<p>WSL is also available as a package for <em>winget<\/em>. However, it does not provide a uniform installation option, as the package manager is not supported on Windows Server and would <a href=\"https:\/\/4sysops.com\/archives\/install-winget-on-windows-server-and-activate-preview-features\/\" target=\"_blank\" rel=\"nofollow noopener\">need to be set up first<\/a>.<\/p>\n<p>In theory, you can install WSL with <em>winget<\/em> on Windows 10 \/ 11:<\/p>\n<pre>winget install \"Windows Subsystem for Linux\"<\/pre>\n<p>In practice, however, the installation got stuck during my test and was not successfully completed.<\/p>\n<h2>Determining the WSL version<\/h2>\n<p>Before installing the first Linux distribution, it&#8217;s recommended to check which WSL version is installed:<\/p>\n<pre>wsl.exe --status<\/pre>\n<p>By default, Microsoft now activates WSL2. You can explicitly ensure this with the following command:<\/p>\n<pre>wsl.exe --set-default-version 2<\/pre>\n<p>Moreover, you have the option to select the WSL version for each Linux distribution on a case-by-case basis utilizing the following format:<\/p>\n<pre>wsl.exe --set-version &lt;name-of-distribution&gt; 2<\/pre>\n<h2>Adding a Linux distribution<\/h2>\n<p>Now you can proceed to install Linux distributions. This is done on a per-user level, so each account gets its own copy of the distros. If you added the subsystem via wsl.exe, then either the default Ubuntu or the distro specified during installation is already present (unless you used the <em>&#8211;no-distribution switch<\/em>).<\/p>\n<p>Further distros can be added using:<\/p>\n<pre>wsl.exe --install -d &lt;Distro&gt;<\/pre>\n<p>If you have set up WSL using the optional feature from the OS, this command may result in an error 0x8000ffff.<\/p>\n<p>Alternatively, you can download additional distros from the Microsoft Store on client systems.<\/p>\n<h3>Download the latest distro from Github<\/h3>\n<p>The above method retrieves distributions from the Microsoft Store. If you want to download the latest distro release from GitHub, the command would look like this:<\/p>\n<pre>wsl.exe --install -d Debian --web-download<\/pre>\n<p>However, this has the unpleasant side effect that the distro cannot be shut down or removed with <em>wsl -t<\/em> or <em>wsl &#8211;unregister<\/em>.<\/p>\n<p><a href=\"https:\/\/4sysops.com\/wp-content\/uploads\/2023\/12\/Even-though-wsl--l-shows-the-distro-installed-with-the-web-download-option,-it-cannot-be-removed-using-this-tool.png\" target=\"_blank\" rel=\"nofollow noopener\">Even though wsl -l shows the distro installed with the web-download option, it cannot be removed using this tool<\/a><\/p>\n<p>In this case, you need to remove the distro through the <em>Settings<\/em> app or PowerShell:<\/p>\n<pre><\/pre>\n<p>Get-AppxPackage -Name *kali* | Remove-AppxPackage<\/p>\n<h3>Setting up a distribution under Server Core<\/h3>\n<p>The approach doesn&#8217;t work on Server Core because it doesn&#8217;t have a web browser, so APPX can&#8217;t be installed the usual way. This is why we use PowerShell to download it with the <a href=\"https:\/\/4sysops.com\/archives\/powershell-invoke-webrequest-parse-and-scrape-a-web-page\/\" target=\"_blank\" rel=\"nofollow noopener\">Invoke-WebRequest<\/a> command.<\/p>\n<p>Here are the links for each distribution:<\/p>\n<ul>\n<li>Ubuntu 18.04: <a href=\"https:\/\/aka.ms\/wsl-ubuntu-1804\" target=\"_blank\" rel=\"nofollow noopener\">https:\/\/aka.ms\/wsl-ubuntu-1804<\/a><\/li>\n<li>Debian GNU\/Linux: <a href=\"https:\/\/aka.ms\/wsl-debian-gnulinux\" target=\"_blank\" rel=\"nofollow noopener\">https:\/\/aka.ms\/wsl-debian-gnulinux<\/a><\/li>\n<li>Kali Linux: https:\/\/aka.ms\/wsl-kali-linux<\/li>\n<li>OpenSUSE: <a href=\"https:\/\/aka.ms\/wsl-opensuse-42\" target=\"_blank\" rel=\"nofollow noopener\">https:\/\/aka.ms\/wsl-opensuse-42<\/a><\/li>\n<li>SLES: <a href=\"https:\/\/aka.ms\/wsl-sles-12\" target=\"_blank\" rel=\"nofollow noopener\">https:\/\/aka.ms\/wsl-sles-12<\/a><\/li>\n<\/ul>\n<p>For Ubuntu, you can use the following command in PowerShell:<\/p>\n<pre>Invoke-WebRequest https:\/\/aka.ms\/wsl-ubuntu-1804 `<\/pre>\n<p>-OutFile ubuntu-1804.zip -UseBasicParsing<\/p>\n<p><a href=\"https:\/\/4sysops.com\/wp-content\/uploads\/2023\/12\/When-downloading-with-Invoke-WebRequest-on-Server-Core,-you-should-use-the--UseBasicParsing-switch..png\" target=\"_blank\" rel=\"nofollow noopener\">When downloading with Invoke-WebRequest on Server Core, you should use the -UseBasicParsing switch.<\/a><\/p>\n<p>APPX is essentially a ZIP archive with a different file extension. The example download above saves the package with the .zip extension because the <em>Expand-Archive<\/em> cmdlet would otherwise refuse to work. The distribution is extracted with the following command:<\/p>\n<pre>Expand-Archive -Path .ubuntu-1804.zip<\/pre>\n<p>The contents of the archive will then be in the subdirectory <em>ubuntu-1804<\/em>, where you can start the .exe file to set up Linux.<\/p>\n<h2>Delete distro and WSL<\/h2>\n<p>If you want to remove a distro from WSL, terminate it with the command:<\/p>\n<pre>wsl.exe -t &lt;Distro name&gt;<\/pre>\n<p>and delete it with this command:<\/p>\n<pre>wsl.exe --unregister &lt;Distro name&gt;<\/pre>\n<p>If you didn&#8217;t install a distribution using <em>wsl.exe<\/em>, you cannot remove it using this utility. In this case, you would use the <em>Settings<\/em> app or PowerShell, as shown above.<\/p>\n<h2>Integrating WSL with Windows Terminal<\/h2>\n<p>When you install Windows Terminal on a system where WSL is already set up, it automatically creates profiles for the installed distros. As such, you can easily open a new bash window from the menu that has all the shells.<\/p>\n<p>If you are using Windows 11, Terminal comes pre-installed and new shells are not automatically registered. This means you&#8217;ll need to manually set up profiles for any Linux distros you want to use.<\/p>\n<p><a href=\"https:\/\/4sysops.com\/wp-content\/uploads\/2023\/12\/Automatically-created-profile-for-Ubuntu-18.04-in-Windows-Terminal..png\" target=\"_blank\" rel=\"nofollow noopener\">Automatically created a profile for Ubuntu 18.04 in Windows Terminal.<\/a><\/p>\n<p>To do this, open the Terminal settings and execute the <em>Add new profile<\/em> command. In the next window, click on <em>Duplicate<\/em> and copy the profile for PowerShell. Then, edit the new profile, change the name, and modify the command line. In doing so, replace<\/p>\n<pre><\/pre>\n<p>%SystemRoot%System32WindowsPowerShellv1.0powershell.exe<\/p>\n<p>with<\/p>\n<pre><\/pre>\n<p>%SystemRoot%System32wsl.exe -d &lt;Distro name&gt;<\/p>\n<div><a href=\"https:\/\/4sysops.com\/wp-content\/uploads\/2023\/12\/Copy-the-PowerShell-profile-in-Windows-Terminal-and-customize-it-for-Ubuntu..png\" target=\"_blank\" rel=\"nofollow noopener\">Copy the PowerShell profile in Windows Terminal and customize it for Ubuntu.<\/a><\/div>\n<p>Copy the PowerShell profile in Windows Terminal and customize it for Ubuntu.<\/p>\n<h2>Summary<\/h2>\n<p>While Microsoft attempts to simplify the installation of the relatively complex Linux Subsystem using wsl.exe, in reality, the setup is still inconsistent. It works reasonably well under Windows 11, as long as you don&#8217;t need WSL1 there. Otherwise, you have to deal with two WSL variants: the one from the Store and the one included in the OS.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>For some time now, Microsoft has been offering a simplified installation of WSL via the wsl.exe utility. Hence, most guides refer to this method. However, in practice, it is not quite as straightforward because this command does not work on Server Core and is only suitable for WSL 2. Ideally, the Windows Subsystem should be [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":8466,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[92,116,147,146,119],"tags":[],"class_list":["post-8465","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-articles","category-linux","category-server-core","category-window-server","category-windows"],"_links":{"self":[{"href":"https:\/\/cheapwindowsvps.com\/blog\/wp-json\/wp\/v2\/posts\/8465","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cheapwindowsvps.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cheapwindowsvps.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cheapwindowsvps.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cheapwindowsvps.com\/blog\/wp-json\/wp\/v2\/comments?post=8465"}],"version-history":[{"count":3,"href":"https:\/\/cheapwindowsvps.com\/blog\/wp-json\/wp\/v2\/posts\/8465\/revisions"}],"predecessor-version":[{"id":10718,"href":"https:\/\/cheapwindowsvps.com\/blog\/wp-json\/wp\/v2\/posts\/8465\/revisions\/10718"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cheapwindowsvps.com\/blog\/wp-json\/wp\/v2\/media\/8466"}],"wp:attachment":[{"href":"https:\/\/cheapwindowsvps.com\/blog\/wp-json\/wp\/v2\/media?parent=8465"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cheapwindowsvps.com\/blog\/wp-json\/wp\/v2\/categories?post=8465"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cheapwindowsvps.com\/blog\/wp-json\/wp\/v2\/tags?post=8465"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}