Windows linux subsystem windows server

While the second generation of the Linux subsystem has been on board with Windows 10 since version 20H1, Windows Server users have had to settle for WSL1 until now. After some back and forth, Microsoft has now decided to offer WSL2 for Windows Server 2022. However, Server 2019 will be left out.

  • Author
  • Recent Posts

Wolfgang Sommergut has over 20 years of experience in IT journalism. He has also worked as a system administrator and as a tech consultant. Today he runs the German publication WindowsPro.de.

WSL2 is based on a new architecture for which Microsoft provides its own Linux kernel. This runs on a lightweight virtual machine. You don’t have to create this utility VM yourself, but of course its hardware requirements must still be met. Therefore, you have to activate nested virtualization if you want to run WSL2 in a VM.

In addition, Linux programs can use the native interfaces of the Linux kernel. This allows more applications to run under WSL2 than before, including Docker containers.

Another benefit of the architecture change is that WSL2 can use a native EXT4 file system within the VHDX.

WSL support for Windows Server

To date, Windows Server 2004, which appeared in the now-abandoned semiannual channel, was the only version to benefit from WSL2. However, support for this server version has recently expired, so WSL2 is no longer available for any current version of the server OS.

After WSL2 was included in previews for Windows Server 2022, Microsoft decided at the end of 2020 that the final version would only be shipped with WSL1. After feedback from the community, the company changed its stance and announced WSL2 for Server 2022 and all subsequent LTSC versions. However, WSL2 will not be backported to Server 2019.

Installing WSL2

With the June 2022 cumulative update, Microsoft added the option of installing WSL2. Previously, the feature could be added via the optional update KB5014021.

Prior to the June update Microsoft made WSL2 available through KB5014021

Prior to the June update Microsoft made WSL2 available through KB5014021

For installation, you can also use the simplified procedure via wsl.exe on Server 2022. Before you start, you can get an overview of the available Linux distributions with the following command:

wsl -l -o

From the output, copy the name (not the friendly name) of the preferred distro for use in the next command. Subsequently, enter the following call to wsl.exe in a command line with administrative rights:

wsl.exe --install -d <name-of-distribution>

In our example, the distro is Ubuntu-20.04.

Installation of subsystem for Linux 2 using wsl.exe_

Installation of subsystem for Linux 2 using wsl.exe_

The setup routine will now install all WSL2 components and then require a reboot of the computer. After logging in again, the installation finishes with the configuration of the first Linux user and the user’s password.

After the reboot the setup configures the installed distribution

After the reboot the setup configures the installed distribution

With the help of

wsl --status

you can verify that WSL uses version 2 by default. WSL1 is still on board, and you can run several Linux distributions side by side, using either WSL1 or WSL2.

Installing WSL on Windows Server 2022 activates version 2 by default after the June update

Installing WSL on Windows Server 2022 activates version 2 by default after the June update

Installing WSL on Windows Server 2022 activates version 2 by default after the June update

Currently, there is still a problem with Windows Terminal. It recognizes the installed distributions but exits when a session is opened; it shows the following error:

The system cannot find the file specified.

[process exited with code 4294967295 (0xffffffff)]

Windows Terminal currently generates an error when invoking the Linux shel

Windows Terminal currently generates an error when invoking the Linux shel

Windows Terminal currently generates an error when invoking the Linux shell

Conclusion

After changing course several times, Microsoft finally decided to also support WSL2 in LTSC versions of its server operating system. However, this does not apply to Windows Server 2019, whose users will be stuck with WSL1.

Microsoft also points out WSL2’s limited usage scenarios. It is not intended to run productive Linux workloads. For this purpose, the company recommends the use of virtual machines. However, the feature is very popular for developer or lab environments.

The Windows Subsystem for Linux (WSL) is available in Windows Insider builds of Windows Server. Now developers and application administrators can run tools they use in Linux environments alongside Cmd and PowerShell.

If you want to jump straight in, the installation guide is available here.

Why include WSL on Windows Server?

We want Windows, including Windows Server, to be a great place for developers. We know developers, system administrators, people managing services and people building services all occasionally need tools available on Linux.  Many more would like to run Linux tools as part of their workflow as a matter of convenience.

Previously, there were a few options:

  1. Run something like Cygwin and rely on Win32 ports of common GNU tools.
    Cygwin is a great toolset but it runs into issues when using tools that haven’t been ported to Windows. Many tools simply aren’t available. This is especially common when trying to build and run Ruby & Java solutions, which utilize some Linux-only Gems, libraries and components.
    The tools available through Cygwin and other Win32 ports are also notorious for being out of date – which is understandable since updating them requires recompiling them for Windows. For Windows users, however, this is both inconvenient and often leads to troublesome compatibility issues when running, building or deploying software.
  2. Use Linux in a virtual machine.
    Virtual machines are designed for production workloads on Windows Server. They aren’t ideal for things closely tied to the Windows Server host. If you need basic Linux command-line tools integrated with their Windows system, a virtual machine will be cumbersome.

This is where running Linux on WSL provides value: WSL runs unmodified Linux (ELF64) binaries natively. It can install and run almost any Linux command-line tool integrated in Windows.

With the additions of WSL and Linux containers with Hyper-V isolation, Windows Server offers a wide variety of Linux options that make it a great place and platform for modern developers.

If you’re a server engineer that needs to run node.js, Ruby, Python, Perl, Bash scripts or other tools that expect Linux behaviors, environment or filesystem-layout, the ability to install and run Linux with WSL expands the tools at your disposal on Windows Server.

What this isn’t — WSL is not a Linux server

Just as with WSL on Windows Client, you can run daemons and jobs like MySQL, PostgreSQL, sshd, etc., via an interactive shell, but you cannot currently use WSL to run persistent Linux services, daemons, jobs, etc. as background tasks.

For these sorts or tools, read more about Linux containers with Hyper-V isolation from the Build 2017 announcement.

How do I get started using WSL on Server?

Windows Subsystem for Linux arrived in Windows Server Insider Build 16237. Follow our new Windows Server WSL Installation Instructions to get started running Linux alongside Cmd and PowerShell on your Servers.

Feel free to comment below or reach out to Sarah and Rich via Twitter.

Run Linux on Windows Server

Welcome to the world of Windows Subsystem for Linux (WSL) on Windows Server! With WSL, you can run Linux applications natively as Linux processes on your Windows Server, bridging the gap between the Windows and Linux ecosystems. In this guide, we will explore the process of installing and using WSL on Windows Server, allowing you to leverage the power and versatility of Linux within your Windows Server environment. In this article, I will show you how to install Windows Subsystem for Linux on Windows Server. Please see WSL: What is Windows Subsystem for Linux, how to fix WSL Error 0x8007019e: WSL Registrater Distribution failed with error, and How to install Windows Subsystem for Linux on Windows 11 via the Command line, and Microsoft Store.

Version of Windows Server Support for WSL

Before we dive into the installation steps, let’s clarify which versions of Windows Server support WSL. According to Microsoft documentation, WSL is available for installation on Windows Server 2019 (1709) and above, including various Windows Server Semi-Annual Channel (SAC) releases such as versions 1909, 2004, 20H1, 20H2, and the latest Windows Server 2022. This provides a broad range of options for Windows Server users to embrace the capabilities of WSL.

Before we proceed, here are other related guides on how to run the Linux distributions on Windows: Install Ubuntu 20.04 LTS on Windows via WSL, Setup GitLab Runner on Windows WSL, How to install Windows Subsystem for Linux on Windows 11 via the Command line, and Microsoft Store, WSL: What is Windows Subsystem for Linux, Windows Subsystem for Linux: How to install WSL on Windows 10, and Windows Subsystem for Linux: How to install WSL on Windows Server via Server Manager and PowerShell.

Now, let’s address the installation process and any differences you may encounter when installing WSL on Windows Server compared to Windows 10 or Windows 11. Generally, the installation process remains quite similar across these platforms, but there is one crucial distinction when it comes to running WSL on Windows Server. Unfortunately, WSL 2 distributions are not available or supported on Windows Server 2019 but are supported on Windows Server 2022. However, this limitation doesn’t hinder the usage of WSL version 1 for all your distributions, so you can still enjoy the benefits of WSL on your server.

Install WSL on Windows Server 2022

Windows Server 2022 has made the installation process of WSL incredibly simple. With just a single command, you can install all the necessary components and get started with WSL. Here’s how:

Open an administrator PowerShell or Windows Command Prompt. Enter the following command:

   wsl --install

After executing the command, restart your machine to apply the changes.

running the command

Wsl –install command

Congratulations! You now have WSL installed on your Windows Server 2022.

By running the `wsl –install` command, you not only enable the required optional components but also download the latest Linux kernel, set WSL 2 as the default version, and install the Ubuntu Linux distribution by default.

How to Install Your Preferred Distribution on Linux on Windows Server 2022

If you prefer a different Linux distribution, you can install it by following the process below.

Open an administrator PowerShell or Windows Command Prompt. Enter the following command:

wsl -l -o

By running the command “wsl -l -o,” you can view the list of available Linux distributions and select the preferred one.

running the command

Command to view Linux distributions

Then, with administrative rights, execute the command shown below to initiate the installation:

wsl.exe --install -d <name-of-distribution>

After the installation completes, a reboot is required. Upon logging back in, the setup procedure will finalize the configuration by setting up the first Linux user and password.

Windows Linux integration

Command to install Linux distribution

Install WSL on Previous Versions of Windows Server

If you are using Windows Server 2019 (version 1709+) or an earlier version, you can still install WSL manually. Follow these steps:

Enable the Windows Subsystem for Linux (WSL) optional feature by opening PowerShell as an administrator and running the following command:

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

After executing the command, reboot your server to activate the changes.

Linux compatibility on Windows

Enable Windows Optional Feature

Download your preferred Linux distribution by visiting the official WSL documentation and following the instructions provided. Once you have downloaded the Linux distribution, navigate to the location of the downloaded file and open PowerShell in that directory.

Extract the contents of the distribution’s `.appx` package using the following PowerShell command:

Rename-Item .\Ubuntu.appx .\Ubuntu.zip
Expand-Archive .\Ubuntu.zip .\Ubuntu

After extracting the contents, install the Linux distribution by running the following command in the same directory, replacing `app-name` with the name of the Linux distribution `.appx` file:

Add-AppxPackage .\app_name.appx

Install Linux distro on Windows Server

Install Linux distro on Windows Server

Note: If you encounter the error message “Installation failed with error 0x8007007e,” ensure that your system meets the minimum requirements for WSL and that you have enabled WSL and restarted your computer.

Add the path of your Linux distribution to the Windows environment PATH using the following PowerShell command, substituting `C:\Users\Administrator\Ubuntu` with the path of your Linux distribution:

$userenv = [System.Environment]::GetEnvironmentVariable("Path", "User")
[System.Environment]::SetEnvironmentVariable("PATH", $userenv + ";C:\Users\Administrator\Ubuntu", "User")

Congratulations! You can now launch your Linux distribution from any path by typing `<DistributionName>.exe`. For example, to launch Ubuntu, simply type `ubuntu.exe`.

Conclusion

By following this installation guide, you have successfully enabled the Windows Subsystem for Linux (WSL) on your Windows Server environment. Whether you’re using the latest Windows Server 2022 or an earlier version, WSL empowers you to leverage the strengths of both Windows and Linux ecosystems seamlessly. Explore the vast Linux software repository, utilize Linux command-line tools, and unlock a world of possibilities for your Windows Server. Get ready to take your server administration and development tasks to new heights with WSL!

Одним из новшеств Windows Server 2016 версии RedStone 3 (1709) является встроенная поддержка запуска нативных бинарных файлов Linux ELF64. Данный функционал реализуется за счет отдельного компонента Windows Subsystem for Linux (WSL), который обеспечивает нужный слой совместимости. В этой обзорной статье мы покажем, как включить подсистему Windows для Linux в Windows Server 2016 и использовать ее для запуска Linux приложений.

Возможность запуска Linux приложений в Windows ранее была представлена в Windows 10. Эта функция носила название Bash on Windows. Начиная с Windows 10 Fall Creators Update это название более не используется и официально эта подсистема теперь называется WSL — Windows Subsystem for Linux. Кроме того, для ее использования более не нужно переключать ОС в режим разработчика (Developer Mode). WSL доступна как Windows Server, так и в виртуальных машинах Microsoft Azure

Предполагаем, что вы уже скачали и установили релиз Windows Server >= 1709. Это может быть сервер с полноценным GUI или в Core режиме.

Проверить текущую версию ОС можно так:

systeminfo | Select-String "^OS Name","^OS Version"

Чтобы проверить, что в вашей версии Windows Server имеется функционал WSL, выполните следующую команду:

Get-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

Get-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

Чтобы включить поддержку подсистемы Linuх, выполните команду:

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

После чего сервер нужно перезагрузить.

Далее необходимо скачть архив с адаптированным дистрибутивом Linux. На данный момент Microsoft предлагает поддержку следующих дистрибутивов:

  • Ubuntu – https://aka.ms/wsl-ubuntu-1604
  • OpenSUSE – https://aka.ms/wsl-opensuse-42
  • SLES – https://aka.ms/wsl-sles-12 — корпоративный вариант SUSE

В ближайшем будущем планируется добавить дистрибутивы CentOS и Fedora.

К примеру, с помощью PowerShell по HTTP протоколу, скачаем архив с дистрибутивом Ubuntu:

Invoke-WebRequest -Uri https://aka.ms/wsl-ubuntu-1604 -OutFile ~/Ubuntu.zip -UseBasicParsing

Invoke-WebRequest -Uri https://aka.ms/wsl-ubuntu-1604

Размер архива около 200 Мб. Распакуем его:

Expand-Archive ~/Ubuntu.zip ~/Ubuntu

Expand-Archive ~/Ubuntu.zip ~/Ubuntu

Исходный архив можно удалить:

Remove-Item Ubuntu.zip

Для запуска установки дистрибутива достаточно запустить файл:

Ubuntu.exe

Запустится мастер установки, который в том числе попросит указать имя пользователя и пароль, который вы будете использовать для доступа к середе Linux (эта учетная запись не связана с Windows и входит в группу sudoers, таким образом ей разрешено использовать команду sudo для установки пакетов)

Ubuntu.exe

Запустим обновление дистрибутива:

sudo apt-get update
sudo apt-get upgrade

Чтобы выйти из командой оболочки Linux и вернуться в PowerShell, наберите:

Exit

Открыть shell в любой момент можно командой:

bash

Имеется возможность запускать команды Linux из консоли Windows и наоборот. К примеру, в консоли PowerShell можно вывести список файлов в каталоге командой ls. Формат команды должен быть такой:

bash -c “ls -la”

Запуск команд Linux из Windows

Чтобы из Linux вызвать команду Windows, формат должен быть такой:

cmd.exe /c dir

Примечание. Обратите внимание, что при запуске исполняемых файлов Windows нужно обязательно указывать расширение и соблюдать регистр имени оригинального файла.

Запуск команд Windows из Linux

Нужно отметить, что из Linux можно запускать только те исполняемые файлы Windows, которые описаны в специальной переменной окружения. Чтобы добавить в переменную окружения новый путь, выполните команду:

export PATH=$PATH:/mnt/c/Windows/System32

Теперь можно вызвать любой файл из каталога %WinDir%\system32.

run notepad.exe from linux

Чтобы передать параметр на вход исполняемого файла, нужно воспользоваться такими конструкциями:

$notepad.exe “C:\temp\test.txt”
$notepad.exe C:\\temp\\test.txt

Все исполняемые файлы в этом случае запускаются в контексте учетной записи, запустившей bash.exe.

Итак, подсистему WSL можно использовать для тестирования, разработки и запуска утилит Linux, недоступных в Windows окружении без необходимости развертывать и настривать отдельную виртуальную машины с Linux.

With the latest Windows Server 2022 cumulative update (June 2022), you are also able to run WSL 2 on Windows Server. In this blog post, I am going to show you how you can install the Windows Subsystem for Linux 2 (WSL 2) on Windows Server. The Windows Subsystem for Linux was already available in earlier versions of Windows Server; however, WSL 2 brings a lot of new advantages. WSL 2 will be available on Windows Server 2022 broadly with the June cumulative update and if you want to run it today, you can install the 5C update here.

WSL 2 on Windows Server

WSL 2 on Windows Server

The Windows Subsystem for Linux was in Windows 10 and Windows 11 for a while now and allowed you to use different versions of Linux on your Windows client machine. With WSL 2, the architecture will change drastically and will bring increased file system performance and full system call compatibility. WSL 2 is now using virtualization technology (based on Hyper-V) and uses a lightweight utility VM on a real Linux kernel. You can find out more about WSL 2 in the release blog or on the Microsoft Docs Page for WSL 2.

Install Windows Subsystem for Linux 2 (WSL 2) on Windows Server

Here is how you can install WSL 2 on Windows Server.

Prerequisites:

  • Windows Server 2022 June cumulative update or 5c preview update (May)
  • A machine that supports Hyper-V Virtualization.
  • If you are installing your Windows Server in a virtual machine, make sure Nested Virtualization is enabled.

KB5014021 for WSL 2 on Windows Server

KB5014021 for WSL 2 on Windows Server

After you have installed Windows Server 2022 with the latest update, you will need to add the following features:

  • Microsoft-Windows-Subsystem-Linux
  • VirtualMachinePlatform

To enable these features, run the following command:

wsl --install

This command will need a restart to complete.

Install Windows Subsystem for Linux 2 (WSL 2) on Windows Server 2022

Install Windows Subsystem for Linux 2 (WSL 2) on Windows Server 2022

This will also download Ubuntu as for your WSL 2 Linux distro.

Windows Subsystem for Linux 2 on Windows Server 2022

Windows Subsystem for Linux 2 on Windows Server 2022

I hope this gives you a step-by-step guide on how you can install WSL 2 on Windows Server. If you want to install the Windows Subsystem for Linux (1( on Windows Server 2019, check out this blog post: Install Windows Subsystem for Linux on Windows Server.

Tags: Hyper-V, install, installation, Microsoft, Windows Server, Windows Server 2019, Windows Server Insider Preview, Windows Subsystem for Linux 2, Windows Subystem for Linux, WSL, WSL 2, WSL 2 on Windows Server, WSL on Windows Server Last modified: May 31, 2022

About the Author / Thomas Maurer

Thomas works as a Senior Cloud Advocate at Microsoft. He engages with the community and customers around the world to share his knowledge and collect feedback to improve the Azure cloud platform. Prior joining the Azure engineering team, Thomas was a Lead Architect and Microsoft MVP, to help architect, implement and promote Microsoft cloud technology.
 
If you want to know more about Thomas, check out his blog: www.thomasmaurer.ch and Twitter: www.twitter.com/thomasmaurer

  • Windows license manager по русски
  • Windows kill process by pid
  • Windows is loading files что это
  • Windows keylogger бесплатно usd49 windows
  • Windows linux mac os что выбрать