LINUX IN WINDOWS
Step into the exciting world of Windows Subsystem for Linux and open source PowerShell, with Matthew Holder.
Over the years Microsoft’s feelings towards the open source community have changed significantly. Contrast it to the Steve Ballmer days, when he described it as a cancer, to more recently when Azure runs a majority of Linux distros, submits code to the Linux kernel and is a platinum member of the Linux Foundation.
Microsoft also releases some key parts of its technology stack as open source. .NET Core is a version of its .NET programming stack that runs and compiles on multiple platforms. PowerShell also has a native Linux version and the replacement for the terminal emulator, cmd.exe, is developed on GitHub. Historical integrations between Windows and other operating systems have included Windows Services for Unix and support for mapping NFS shares.
To explore deeper into this we’ll be discussing Windows Subsystem for Linux (WSL), how to run command line and GUI Linux tools from within Windows, before looking at how to use PowerShell on the Linux platform.
WSL was first released in 2016 and its functionality and performance has been greatly enhanced in the years since. WSL1 was essentially a software translation layer, which covered the instructions from the Linux distribution and converted them to ones that are compatible with the Windows installation, like Wine but in reverse. Unfortunately, performance wasn’t amazing, especially with disk IO, and when WSL2 was released it was re-architected to utilise a real Linux kernel, running in a Hyper-V VM to provide the means of system call translation. Windows files can be accessed from the Linux distribution using a location in the /mnt directory structure and from Windows, Linux files can be accessed using the \\wsl$ network share, which utilises the 9P protocol to provide the file-sharing capabilities.
In recent versions of Windows 11 it’s been possible to run GUI programs from within the WSL environment that integrate nicely with Windows tools, which is known as WSLg. File selectors enable access to the Windows and Linux filesystems, and icons for programs appear in the Start menu, next to Windows applications, with a Tux logo superimposed to denote a Linux application.
For this GUI magic to be possible the Microsoft engineers have used Wayland, XWayland, FreeRDP and PulseAudio to allow X applications and applications with direct support for Wayland to integrate well. The PulseAudio server is also used to enable audio to work. Microsoft has written its own plugins to the Weston Wayland compositor and PulseAudio server to allow RDP to be used as the transport method of application display. Essentially, whenever a program is opened, it seamlessly uses RDP to render on your screen. Microsoft has also created a method to share USB devices between the Windows host and Linux programs, and this will be discussed in the box (below).