PC Pro

Run Linux in Windows 10

How to install it and why you should

-

L inux has long been positioned as an alternativ­e to Windows. If you don’t like Microsoft’s way of doing things, you can download a free installer for Ubuntu, Fedora or some other Linux distributi­on and dive into a whole different platform, with its own library of applicatio­ns and a philosophy that tends to emphasise openness and versatilit­y over ease of use.

Today, though, it’s no longer an either-or choice. As of 2016’s Anniversar­y Update, Windows 10 includes a framework that lets you run Linux commands and even launch Linux programs directly from the Windows desktop. It’s called the Windows Subsystem for Linux (WSL), and it’s not achieved by emulation, virtualisa­tion or any such tricks: what you get is a genuine Linux kernel running natively within Windows.

But, before you get too excited, let’s be clear that WSL is aimed primarily at developers. It’s not something you’re likely to use day-to-day for managing your correspond­ence or gameplay. In Microsoft’s words, it’s particular­ly aimed at “those who work on or with open-source projects”, using languages such as Python or Ruby.

Still, thanks to low-cost platforms such as the Raspberry Pi, those technologi­es are more popular than ever – so it makes sense for Microsoft to support anyone who wants

to take things further. There’s now no need for Windows users to mess about with dual booting or virtual machines, and no need to look further afield at macOS; its UNIX-based core has historical­ly made it a better fit for those who need to dip into Linux from time to time.

Indeed, WSL may even be an attractive alternativ­e to everyday Windows developmen­t. For example, if you want to develop websites using WordPress, you can run Apache, PHP and MariaDB within Windows – but many developers will already be familiar with Linux commands and its file system, and there will likely be more documentat­ion and support out there for Linux platforms. It also doesn’t hurt to develop in an environmen­t that resembles as closely as possible the platform to which you intend to deploy.

So, how do you get started? Here’s our guide to setting up WSL, and installing all the tools you need to get stuck into some good old-fashioned web developmen­t.

Installing the Windows Subsystem for Linux

WSL is an optional part of Windows, and it’s disabled by default. To activate it, use the Start menu to find and open a control panel named “Turn Windows features on or off”. Once this appears, scroll through the list of available features and tick the box beside Windows Subsystem for Linux. Click OK to update your installati­on and reboot.

Having installed the framework, you now need to install the Linux kernel itself. The easiest way to do this is to open the Microsoft Store and search for Linux: you will find several kernels to choose from, including Debian, SUSE and Ubuntu, and they’re naturally all free. We have chosen Ubuntu 18.04 LTS as it’s a “long-term support” release with a focus on stability, but the other choices should work perfectly well.

After selecting your kernel, click “Get” in the Store app to download it; as the package doesn’t include all the support software that comes with a full distributi­on, the download is a relatively modest 221MB. Once it’s arrived, click the “Launch” button on the Store page and wait for Ubuntu (or your chosen version of Linux) to initialise. The first time you do this it will take a few minutes to install all the components, but subsequent launches should take just a few seconds.

When it’s finished, you will be prompted to enter a new username and password for your Linux system. These will control your access to Linux files and resources; note that they’re completely separate to your Windows or Microsoft Account credential­s. You can make them the same if you like, but updating one won’t affect the other.

Staying up to date

Once you have set your password, you’ll immediatel­y find yourself looking at a (possibly unfamiliar) command prompt. You can now start entering Linux commands as if you were running a full distributi­on.

One command we suggest you run right away – well, actually a pair of commands – is the following: These commands will fetch and install the latest updates for your Linux system, something it’s important to do periodical­ly as they won’t be automatica­lly updated by Windows Update.

To explain what’s actually happening here, the “sudo” command tells Linux to run a command as a superuser – the equivalent of an administra­tor on Windows – so after entering it, you’ll be prompted to provide your password. The command itself is “apt”, which stands for Advanced Package Tool. This is the Linux tool for downloadin­g, installing and updating software.

You can use APT to install all sorts of packages because it’s effectivel­y a nongraphic­al app store. For example, the textbased Lynx web browser can be installed with a single command: It should take less than 30 seconds for Lynx to be installed; you can then run it by simply entering the command “lynx”. Within the app you can use the cursor keys to move between links, and the return key to follow one; press G (for go) to visit a specific URL, and Q to quit.

At this point you’re probably thinking that web browsing works better in a graphical environmen­t. It is technicall­y possible to install a windowing server in WSL, but it’s a complicate­d process that Microsoft doesn’t currently support: unless you’re an expert user, we suggest you stick with the command line.

Getting started with the command line

You don’t need to provide your username or password every time you launch the subsystem, as you will be automatica­lly logged in under the username

you provided during setup. This isn’t a major security risk, as your user account is itself restricted: you can only access system-level resources when you use sudo, as we did when updating the system files above, and this will require your password.

If you want to know what commands you can use, there’s no shortage of online guides. Linux also has a built-in manual, which you can search by typing “man” followed by the command you want to look up – “man sudo”, “man apt”, “man grep” and so on.

It’s possible to launch WSL commands directly from the Windows command prompt by prefixing your Linux command with “wsl”: entering “wsl nano”, for example, opens the Nano text editor within the Linux environmen­t. You can enter commands like this directly from the Start menu too, but take note that the top search is usually a search link; the second result in the list is normally the one you want.

Conversely, if you want to run a Windows applicatio­n from the WSL prompt, you can simply type its name and hit return. Just remember to enter the full name of the executable, including the extension: for example, entering “notepad.exe” does just what you’d hope, and you don’t even need to specify which directory it’s located in.

Finding your files

Since the Linux kernel runs within Windows, it’s perfectly possible to access your files from both environmen­ts. The question is: where are those files?

It may take a while to get your head around the answer. On the Linux side, drives are treated in a similar manner to folders, with your physical media accessible as notional subdirecto­ries within the /mnt/ directory. To find your boot drive, therefore, you’d enter “cd /mnt/c”, changing the last letter to access drive D and so on. As in Windows, you can then use the cd command to explore subdirecto­ries, and enter “cd ..” to move up a level in the directory tree.

Unlike in a full Linux distributi­on, file and folder names aren’t case sensitive in WSL, so “cd /mnt/c/Users” and “cd /mnt/C/Users” will both take you to the same place. As per

the Linux convention, though, spaces and special characters must be preceded with a slash. So, to access your Program Files (x86) folder, you would type:

cd program\ files\ \(x86\)

Accessing Linux files from Windows can also be complicate­d, as Windows sees the Linux subsystem as a hidden network device called wsl$. A handy trick here is to enter “explorer. exe .” from the WSL command prompt – and note the dot after the command. This tells Explorer to open at the current directory, from where you can easily navigate around your Linux system – or create a desktop shortcut to quickly access WSL locations.

 ??  ??
 ??  ?? RIGHT The Windows Subsystem for Linux is an optional component of Windows 10
RIGHT The Windows Subsystem for Linux is an optional component of Windows 10
 ??  ?? ABOVE Windows sees the WSL file system as a hidden device on your network
ABOVE Windows sees the WSL file system as a hidden device on your network

Newspapers in English

Newspapers from United Kingdom