What Is Windows Subsystem for Linux?
Operating system (OS) virtualization can accomplish incredible things. By abstracting the hardware layer, virtualization makes an OS believe it is running natively on hardware – when it is, in fact, hosted within another OS.
It opens up a world of possibilities. For example, with virtualization you can run more than one fully functioning OS on a machine – or run a different OS than the host OS, like running Windows on a Linux system or vice versa.
That’s exactly what Microsoft has done with Windows Subsystem for Linux (WSL), a virtualization tool that allows you to run the Linux kernel, filesystem, and Linux GUI on a Windows 10 or Windows 11 PC.
How Windows Subsystem for Linux Works
The Windows Subsystem for Linux (WSL) is a collection of Microsoft components designed to enable native Linux 64-bit Executable and Linkable Format (ELF64) binaries to operate within the Windows 10 or Windows 11 operating system (OS).
It is an abstraction layer that enables Windows users to seamlessly install and run a Linux build on their Windows system without the need for a dual boot setup or to run a virtual machine.
Once the Windows Subsystem for Linux feature is activated in Windows, the Linux bash shell can be utilized to install, for example, the Ubuntu user-mode image – which runs atop the Windows kernel layer, enabling ELF64 binaries to function in Windows.
WSL encompasses a user-mode session manager service to manage the Linux instance, minimized Pico processes to address Linux system calls, and Pico drivers to emulate the Linux kernel. Collectively, this structure allows Linux system calls to be directed to and managed by the Windows kernel.
Following installation, users can execute files from the Ubuntu package repository, use Linux command-line utilities, such as grep, navigate the Linux file system, and run scripts with command-line interface (CLI) utilities.
Who Is Windows Subsystem for Linux Aimed at?
To a degree, the primary users of Windows Subsystem for Linux are Linux developers working in a Windows environment. For instance, web developers who frequently utilize Linux and other open-source tools from sources like GitHub but have limited access to complete Linux systems for development and experimentation. Use cases include:
- Development: WSL enables developers to employ familiar Linux tools and programming languages, such as Ruby and Python, within Windows. You can run Linux-based development environments, such as Docker and Kubernetes.
- Server management: You can use WSL to manage Linux servers. This is useful if you are a system administrator or if you need to manage a Linux server from a Windows computer. WSL can help you to manage Linux servers without having to use a remote desktop connection and use Linux tools and applications to manage your servers.
- Education: Linux education is another great use case for WSL, because you can learn about Linux without having to install a separate Linux operating system. With WSL, you can follow Linux tutorials and documentation and set up a Linux development environment.
- Productivity: For some people who are familiar with Linux environments, a WSL instance can be used to improve their workflows because they can use familiar Linux tools and applications on their Windows computer – saving time and effort.
Part of what powers these use cases is the fact that it’s so easy to install Windows Subsystem for Linux, but the close integration with the surrounding Windows OS also helps.
WSL 1 vs. WSL 2
Microsoft provides two distinct versions of Windows Subsystem for Linux: WSL 1 and the more recent WSL 2. Both facilitate integration between Windows and Linux, are lightweight, and have rapid boot times. Additionally, both WSL 1 and WSL 2 are compatible with non-Microsoft hypervisors, such as VMware and Oracle VM VirtualBox.
A primary difference between WSL 1 and WSL 2 is that the latter operates within a managed virtual machine (VM). As the VM is managed, IT professionals don’t need to concern themselves with configuration or management tasks typically associated with virtual machines.
Another crucial difference is that WSL 2 utilizes a complete Linux kernel. Since this kernel is developed by Microsoft, it is regularly updated through Windows Update.
Microsoft generally recommends using WSL 2 due to its superior performance compared to WSL 1 and its 100% system call compatibility. But you can use WSL 1 if a project needs to be stored on the Windows File System or if cross-compilation using both Windows and Linux tools is required for a project.
Why Use WSL Instead of Linux in a VM?
While Linux instances can operate within Windows inside a VM, WSL offers two benefits. Firstly, it demands less overhead on computing resources – processor, memory, and storage – compared to a full VM. Secondly, WSL enables Windows and Linux environments to run simultaneously, allowing developers to utilize Windows applications and Linux utilities on the same files, if necessary.
WSL 2 has made it possible for Linux GUI applications to feel native and intuitive to operate on Windows. Users can launch Linux applications directly from the Windows Start menu, pin them to the Windows taskbar, and switch between them seamlessly using alt-tab. Additionally, it is now possible to perform cut and paste functions across Windows and Linux applications.
Advantages and Limitations of WSL
One of the primary advantages of using WSL is its simplicity in running Linux applications on a Windows PC without the need to run a separate virtualization application. However, it also provides another benefit: the ability to support multiple Linux distributions, such as Ubuntu, OpenSUSE, Kali, Arch Linux, and Debian – side-by-side.
Furthermore, Microsoft fully supports WSL and ensures it runs smoothly on Windows 10 (version 2004 or higher) and Windows 11. In other words, if you encounter problems using WSL, you can rely on Microsoft’s documentation and support to help fix the problem.
WSL has some limitations, however, because it is not a full Linux environment. It is a compatibility layer that allows you to run Linux binaries on Windows. This means that not all Linux features are available in WSL. For example, WSL does not support some Linux file systems, such as ext4. Furthermore, WSL does not support all Linux distributions.
Additionally, using WSL is not as fast as a native Linux installation. This is because WSL is a virtualization layer that has to translate Linux system calls into Windows system calls. This translation process adds overhead, which can slow down performance.
A Key Windows Feature?
Overall, there are plenty of development environments that would hugely benefit from using WSL – and many other use cases. However, there are some limitations too. Will Windows Subsystem for Linux work for you? Well, that depends on your unique usage requirements. If you want to try WSL you can follow Microsoft’s simple set of instructions here.