Linux apps on Windows 10 and Chrome OS
Penguin Travel
Although Linux has so far failed to make the big breakthrough on the desktop, the success of the open source project is undisputed. As the foundation for countless servers, it forms the backbone of the Internet. In conjunction with the Raspberry Pi and related small-board computers, Linux is just as much a fixture in Internet of Things as it is in the smart home.
If you want to use Linux applications or develop scripts and applications yourself, you do not necessarily have to set up a full-fledged virtual or even physical system. Instead, you can set up a Microsoft or Google Linux subsystem.
WSL Version 2
An article in this issue already looks at Microsoft's version 2 of Windows Subsystem for Linux (WSL2) and its use with containers [1]. WSL1 was not a big hit in terms of functionality and performance because it only provided a compatibility layer that translated Linux system calls to their counterparts on Windows (i.e., it emulated system calls). In May 2020, however, Microsoft changed the technical underpinnings in Windows 10 version 2004 and backported the new functionality to Windows 10 versions 1903 and 1909 a few months later. The backport is only for the x64 platform. On ARM systems, WSL2 is reserved for Windows editions from 2004 upward.
Unlike its ancestor, WSL2 does not rely on emulation; it uses Microsoft's in-house virtual computing platform to run a native Linux kernel on a lightweight virtual machine (VM). Microsoft now serves updates for this Linux kernel in the scope of the usual Windows updates – only after you have manually installed a one-off update. That said, WSL1 has not completely disappeared; it is still there and you can switch flexibly between the worlds for each Linux distribution by upgrading and downgrading.
Basically, Microsoft recommends using the newer version and only gives a few reasons for staying loyal to the predecessor. For example, WSL1 uses RAM more sparingly in certain scenarios and offers better performance if you need to access the Windows filesystem frequently from Linux, but if the folders and files are in the Linux filesystem, you are up to 20 times faster with WSL2, according to Microsoft.
Manual Installation
Microsoft and Canonical announced last year in the scope of the Insider Program that the installation of WSL would be significantly simplified with the help of the simple wsl.exe --install
command. Unfortunately, this command had not made it into the final version at the time of writing this article, which meant I still had to take action manually. Up to and including Windows 10 20H2, the easiest way to enable WSL was to run the following commands in a command-line session launched with administrative rights:
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
After rebooting the system, I then installed the required kernel update [2] and finally defined WSL2 as the default:
wsl --set-default-version 2
Since September 2021, the wsl.exe --install
command works and will significantly simplify your installation.
Selecting a Distribution
You have now successfully set up the basic subsystem, and only the Linux distributions are missing. They find their way onto the system from the Microsoft Store, where you can choose between various distributions, such as Debian, Fedora, several versions of Ubuntu, or even Kali Linux.
To begin, download the desired flavor of Linux. You will then find a shortcut in the Start menu that matches the respective distribution. Use it to initialize the distribution and create a Linux user and password, which does not have to be identical to your user account for Windows. Next, you will want to update the Linux instance; because of similar architectures among Ubuntu, Debian, and Kali Linux, you can do this with the familiar shell commands:
sudo apt-get update sudo apt-get dist-upgrade sudo apt-get clean
The command
wsl --list -verbose
lists all the Linux distributions available on Windows. In the output, the Linux distribution that you installed first is marked with an asterisk as the default. This distro starts automatically when you invoke the wsl
command without parameters. By typing
wsl --set-default kali-linux
you can change the default (here, to Kali Linux). You can also update Linux instances installed before the release of WSL2 at the command line with:
wsl --set-version Ubuntu 2
Similarly, a downgrade to WSL1 is possible, if required.
Buy this article as PDF
(incl. VAT)