What is Windows Subsystem for Linux?

store

What is WSL?

WSL (Windows Subsystem for Linux) is a way of running Linux programs on Windows. It brings the powerful Linux tools and programs to Windows.

Why should I install WSL?

Let’s say you want to get a load of photos printed, but they are stored in a whole load of folders from every date you imported them from your camera to your computer.

To do this in Windows, you’d have to open the first folder, selecting all the photos, copying them, then opening the destination folder and pasting them there, then repeating the operation for every folder you have photos in. This would take ages, depending on how many folders you have.

In WSL, you would simply type:

cd /mnt/c/Users/[username]/Pictures/

cp */*.jpg newfolder

The first line tells WSL to change into the Pictures library for the user, where [username] can be replaced by the user’s name. The second line tells WSL to copy all jpeg files stored in all of the folders into the folder called “newfolder”. Make sure the folder exists before running this command.

Additionally, if you wish to learn Linux or write programs in it, WSL is a good stepping stone. You can even install a web server and host websites from your computer.

 

How do I install WSL?

In order to install WSL you need to enable the optional feature by searching for PowerShell, right clicking and choosing “Run as Administrator” then clicking Yes. Then copy and paste the following command, followed by pressing return (or enter):

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
Powershell command to install Optional Feature Microsoft-Windows-Subsystem-Linux

Next stop is to open Microsoft Store and search for Linux

Microsoft Store showing available distributions.

Now we can click on one, for this example, we will click on Ubuntu and press Get.

Click Get to install Ubuntu

Now we can Launch the new app, this installs the app to your computer. You may be asked to set a username and password to use the system, this can be different to the details you use to log into your computer.

Once this is done, you will see a Linux prompt.

Type:

sudo apt-get update

sudo apt-get upgrade

Answer Y to any questions and your system will be up to date and ready for you to use.

Installing X-Windows

In order to install X-Windows, you need to install an external program called an X server. Download VcXsrv and install it.

Start Ubuntu and type:

sudo apt-get install xfce4

sudo apt-get install xfce4-goodies

Next run:

nano .bashrc

Add at the bottom of the file, the following:

export DISPLAY=:0.0

Save and exit Ubuntu.

Next time you start Ubuntu you can type:

startxfce4

If everything went well, you will see the X-Windows GUI start up.

Xfce4 running on a Windows desktop in a Debian instance.

How do I uninstall a distribution from WSL?

Distributions are installed as apps, so they can easily be removed using Settings -> Apps, searching for the distribution (in this example, Ubuntu) and pressing Uninstall.

Share this post with your friends