Introduction to WSL
WSL (short for Windows subsystem for Linux) is a compatibility layer to run Linux binary executables (inside ELF format) on Windows Server 2019, Windows 11, and Windows 10. WSL 2 was published in May 2019, introducing essential modifications like the Linux kernel from a Hyper V feature subset. It is available for the customers of Windows 10 from the Windows Insider program since June 2019 including the Home edition.
It will be precisely passed down to the Windows kernel which knows how to manage it if a command is a native command of Windows. If it is a command of Linux, the translation service would be called and through that point, the request would be forwarded to the freshly instantiated process in which the Linux instance has been hosted (i.e., Pico process). When the command is run, the outcome is again translated into an appropriate command that the NT kernel could understand.
History of WSL
The first foray of Microsoft into getting Unix-like compatibility over Windows started using the Microsoft POSIX Subsystem, overruled by Windows Services for UNIX by Interix/MKS which was ultimately detracted with the Windows 8.1 release. The technology behind the WSL originated within the unreleased Project Astoria that enabled a few Android applications to execute on Windows 10 Mobile editions. It was initially made present in Windows 10 Insider Preview build 14316.
On the other hand, the previous projects of Microsoft and the third-party Cygwin had concentrated on making their specific Unix-like environments that are based on the standard of POSIX. WSL focuses on the native compatibility of Linux. Rather than covering non-native functionality into the Win32 system calls as Cygwin did.
The initial design of WSL leveraged the NT kernel executive for serving Linux programs as the isolated and special minimal processes (called pico processes) connected to pico providers kernel mode as dedicated system call and many exception handlers different from a vanilla NT process, deciding for reutilizing previous implementations of NT wherever possible.
Microsoft published a test build of Windows 10 that also contains the ability to execute Linux GUI applications using CBL-Mariner and WSL 2 in April 2021. The WSLg (Windows Subsystem for Linux GUI) was officially published at a conference of Microsoft Build 2021. It is contained in the Windows 10 Insider build 21363 or later versions.
Microsoft published the WSL Windows Store version on 11 October 2021 for windows 11.
Features of WSL
WSL is accessible in Windows 10 versions (from the 1607 version) and Windows Server 2019, though just in 64-bit versions.
Microsoft considers WSL as "mainly a tool for developers - specifically web developers and those who work with or on open-source projects. In 2018 September, Microsoft stated that "WSL requires fewer resources (CPU, memory, and storage) than a complete virtual machine" (which before WSL was one of the most direct ways for running Linux software inside a Windows environment), while also permitting users for using Linux tools and Windows applications on a similar set of files.
The WSL architecture was recreated in WSL 2 along with a Linux Kernel executing in a lightweight environment of a virtual machine.
The command, i.e., wsl.exe is used for managing distributions in WSL within the command line. This command can list all distributions available, uninstall distributions, and set the default distribution. Also, it can be used for running Linux binaries through the Windows PowerShell or Windows Command Prompt. The wsl.exe command substitutes the lxrun.exe command which is detracted as of Windows 10 1803 and other versions.
It is an abbreviation for Windows Subsystem for Linux GUI created with the aim of enabling support to run Linux GUI applications (Wayland and X11) on Windows in a completely integrated experience of the desktop. Officially, WSLg was published at the conference of Microsoft Build 2021. It is contained in the Windows 10 Insider build 21364 or later versions.
Although, WSLg is finally ported with a production establishment of Windows bringing support for both audio and graphics in WSL applications with the Windows 11 introduction.
Prerequisites to run WSLg include:
Design of WSL
WSL 1 Design
LXSS Manager Service is a service in interacting charge with the subsystem (from the drivers lxcore.exe and lxss.exe) and the form that Bash.exe (don't be confused with the Shells given by the Linux distributions) releases the Linux processes, managing the Linux binary locks, and system calls at the time of their execution. Every process of Linux invoked by a specific user goes into the "Linux instance" (usually, init is the initial involved process). The instance is also closed once each application is closed.
WSL 2 Design
The WSL 2 version defines modifications within the architecture. Microsoft has assigned for visualization from a highly optimized Hyper V feature subset to execute the distributions and the kernel, promising performance similar to WSL 1. Developers do not need to modify anything in their released distributions for backward compatibility. The settings of WSL 2 can be pulled via the WSL Global configuration, included in an INI file called .wslconfig inside the User Profile folder.
The installation of the distribution resides in an ext4-formatted file system within a virtual disk. Transparently, the host file system is accessible from the 9P protocol, the same as the other technologies of a virtual machine such as QEMU. Microsoft guaranteed up to 20 times the write/read WSL 1 performance for the users. An IFS network redirector is given for the guest file excess of Linux with the \\wsl$ UNC path prefix from Windows.