Linux Format

Linux in Windows

Never mind Windows 11, the latest version of the Windows Subsystem for Linux is where it’s at.

-

HASSLE-FREE SETUP “One of the amazing things about WSL 2.0 is that it supports GUI tools without any extra configurat­ion”

Are you part of the slightly sinister sounding Windows Insiders Program? Have you installed an even more sinister-sounding Preview Build of Windows 10 (at least build 20262)? Then it’s easy to run Linux as part of WSL 2.0: just open an administra­tor-privilege Windows command prompt and run wsl --install . This also works on Preview Builds of Windows 11. A few clicks and pops and a restart later and you’ll be in business.

Actually the GUI App Support download is pretty large, so now might be a good time to make a cup of tea. On return WSL, Microsoft’s Virtual Machine Platform, their custom Linux Kernel and Ubuntu should all have been downloaded. Other distros are available and one can specify, for example, wsl --install -d Fedora , to install Fedora instead, or additional­ly if you already have WSL Ubuntu installed. Users of non Preview Builds can either join the Insiders Program and upgrade to one, or follow the manual installati­on steps below.

Start by firing up Administra­tor-powered PowerShell,

then acknowledg­ing that the command line can get ugly on Windows too, enter the incantatio­n:

> dism.exe /online /enable-feature / featurenam­e:Microsoft-Windows-Subsystem-Linux / all /norestart

This will install WSL 1, at which point you might wish to reboot and play with that. Or you could continue to get the latest incarnatio­n. If you’re not running Build 18362 (check by running winver.exe) or higher (or 19041 or higher form ARM64) you’ll need to persuade the Windows Update Assistant to get you there. To enable WSL 2 we first must enable the Virtual Machine Platform, which requires this doozy of a line to be entered at an Administra­tor PowerShell:

> dism.exe /online /enable-feature /featurenam­e:Virtu alMachineP­latform /all /norestart

One restart later and you’ll be running the subsystem sequel. To get Microsoft’s latest frankenker­nel, download and run the package at https://wslstorest­orage.blob. core.windows.net/wslblob/wsl_update_x64.msi. There’s a separate package for ARM devices, so change x64 for arm64 in the previous link if that applies to you. Before we get to installing Linux we need to set WSL 2 as the default version from PowerShell, easy enough:

>wsl --set-default-version 2

Then get ye to the Microsoft Store (https://aka.ms/ wslstore) and install a distributi­on. The recognisab­le flavours are all free, but if you’re feeling flush you might want to try the Microsoft Research’s WSL-tailored Pengwin distro, currently on sale for about half of its £16.74 (or 2.5x a copy of LXF–ED) price tag.

Create a standalone account

Whatever you choose, and however you got there, the first step post-install is to follow the prompts and set up a username and password. This is entirely unrelated to any other accounts you have set up on Windows, and also separate from WSL accounts set up by other Windows users on the same machine. In other words WSL machines are effectivel­y single-user affairs, since they’re the concern of a single Windows user. Then just as if it were a real Linux machine, you should do a system update:

$ sudo apt update

$ sudo apt upgrade

Where you go from here is up to you. You could just install Vim and the build-essentials package and get hacking on your latest C project. Or you might want to install the Nvidia Container Toolkit, which sets up everything you need to run GPU accelerate­d Docker

images, so you can use CUDA, PyTorch and TensorFlow to machine-learn your way to freedom.

Or you might want to try something else. One of the amazing things about WSL 2.0 is that it supports GUI tools without any extra configurat­ion. It even has its own Wayland compositor. In the previous version, graphical tools could be used, but required an X server (such as GWSL, VcXsrv or X410) to be running on the Windows side. A quick poll of LXF staff suggests that our favourite GUI tool is Microsoft Edge, and our favourite type of humour is sarcasm. So if you wanted to run the Linux edition of Microsoft’s browser in a Microsoft-flavoured version of Linux, you could go right ahead and do:

$ sudo apt install software-properties-common apttranspo­rt-https wget

$ wget -q https://packages.microsoft.com/keys/ microsoft.asc -O- | sudo apt-key add $ sudo add-apt-repository “deb [arch=amd64] https:// packages.microsoft.com/repos/edge stable main” $ sudo apt install microsoft-edge-dev

Now Edge should appear in the start menu, or you can start it with a simple microsoft-edge .

In this way, one could also install such Redmondian wonders as Microsoft Teams or Skype. Or perhaps something that isn’t so Windows-centric. Popular open source programs are just that, so the likes of GIMP, Blender, VLC et al all have official Windows equivalent­s. If for some reason these don’t work well, then now you have options. The Transmissi­on BitTorrent client is perhaps an exception – it has a Windows port, but it’s described as an early preview. You may have your own Windows torrent client preference­s (uTorrent is popular), but if not you can enjoy the solid reliabilit­y of the Linux version. ‘Tis but a matter of:

$ sudo apt install transmissi­on

Visual Studio Code (or the VSCodium fork) are becoming increasing­ly popular on Linux. And it’s fast becoming the code editor of choice for Raspberry Pi users. We can install the Linux version in much the same way as we installed Edge above, but we can also do something different. Recent VS Code versions support the WSL-remote extension, so you can install the Windows version (from https://code.visualstud­io.com) and then have easy access to your WSL files.

For this to work ensure “Add to PATH” is checked in the Select Additional Tasks dialog at the start of the installati­on. Then from the Extensions marketplac­e, search for Remote Developmen­t and install the extension pack (which enables remoting to WSL, Containers or over SSH). According to the docs at https://docs.microsoft.com/en-us/windows/wsl/ tutorials/wsl-vscode you should now be able to start VS

code from within WSL by opening the Ubuntu command line and running code . . This didn’t work for us, but we were able to use F1 to bring up the command palette in VS Code and search for Remote-WSL, which reveals some of its many functions. These include being able to open a folder in WSL, complete with its own Terminal.

If you run the top command within a freshly started WSL 2.0 instance, you’ll see there’s not really all that much running. A couple of init processes, Bash and Top

itself. Not a hint of the bloat some accuse Microsoft of. This is a slight subterfuge, because a lot of the magic is happening in an invisible service virtual machine. This runs a containeri­sed distro based on Microsoft’s own CBL Mariner Linux (developed for its Azure cloud) which handles Wayland, X, PulseAudio and beams it back into Windows via FreeRDP. Read more about this marvel, known as WSLg, at https://github.com/microsoft/wslg.

 ?? ?? It’s time to upgrade Windows 11, by adding a Linux kernel and some Microsoft magic.
It’s time to upgrade Windows 11, by adding a Linux kernel and some Microsoft magic.
 ?? ?? Now you can pore over logs and try and see what went wrong with RDP.
Now you can pore over logs and try and see what went wrong with RDP.
 ?? ??
 ?? ?? Having a whole Marketplac­e inside a code editor isn’t everyone’s cup of tea, but you’ll find WSL extension fortifying and refreshing.
Having a whole Marketplac­e inside a code editor isn’t everyone’s cup of tea, but you’ll find WSL extension fortifying and refreshing.

Newspapers in English

Newspapers from Australia