How to enable Windows Subsystem for Linux
Can you run Linux on Windows? Yes you can, and there are many options open to you, VMWare, VirtualBox which all let you run a virtual machine using your Windows as the host, but using the Windows Subsystem for Linux you can run Linux directly on your Windows 10 computer (well just about!)
This WSL tutorial will show you how to install Windows Subsystem for Linux on Windows 10 (it only works on Windows 10 btw) and then run Ubuntu directly (well via a compatibility layer) on Windows
Sound Good? Let’s get started.
So first of all what is Windows Subsystem for Linux?
WSL is a compatibility layer for running Linux binary executables (in ELF format) natively on Windows 10 and Windows Server 2019 – wikipedia
This means that just by installing this extra (Free) feature on Windows 10 you can then install many Linux distros onto your Windows 10 device without the use of any virtual machine software and for free.
How to install Windows Subsystem for Linux
Installation is very easy and you don’t actually have to download any software you just need to enable a feature in Windows 10
Click on your start button and type windows features
Once you have typed most of the word you should see the following icon – just click on Turn Windows Features on or Off
This will open up the Windows Features box, scroll to the bottom until you see a screen like the below and tick the box next to Windows Subsystem for Linux
Once you have ticked the box, click OK, you will be prompted to restart your computer. Say Yes and let your computer restart.
Once your computer has restarted click on the start button again and type Store you should see Microsoft Store at the top – Click on that.
When the Microsoft Store opens up search for Ubuntu and you should see a screen something like this
If you click on the Ubuntu button (far left) this will take you to the next screen where you click on Get – This will then download the latest version of Ubuntu – currently 18.0.4 – if you click on the 18.04 button it will take you to the same place.
You can also download Centos and other versions of Linux including Kali Linux.
Installation takes only a few minutes once the files are downloaded and you will be prompted to check out Ubuntu
Click on the Start button and you should see an Ubuntu icon – Click on it
This will now open a window that will probably say Ubuntu is still installing, once it is done it will prompt you to create a new username and password
By default it will take the username and password of your current logged in windows account.
You now have a fully operational version of Ubuntu 18.04 running on Windows!
I am still just trying WSL out to see if it will be a good fit for my network automation toolset, I currently use VMWare Workstation to run my Ubuntu machines, but one thing I have noticed so far is the IP address is the same on the Ubuntu machine as my Windows 10 laptop. I am sure there are going to be other differences to running Ubuntu natively but for now it seems to be a great way to spin up Ubuntu to try out some Linux!
I hope this WSL Tutorial has been helpful, and if you have any unaswered questions they may be answered below, if not just leave a comment and I will try to answer them for you.
What does Windows Subsystem for Linux do?
It enables you to run a Linux distribution on Windows 10 without needing to use any kind of virtualization software.
Is WSL a VM?
No, WSL is a compatibility layer that enables you to run Linux directly on Windows.
You may encounter this error
|windows subsystem for linux has no installed distributions|
This just means you have not installed any Linux Images yet – go to the microsoft store and search for your distro and click on Get.
If you want to start or stop your WSL machines or check the running status here are a few simple commands
How to check status of WSL
wsl -l -v
This command will show the status of any WSL images you have installed. in this case I have Ubuntu 18.04 and it is stopped
How to start a WSL2 machine
wsl -d <imagename>
In this case I started an Ubuntu-18.04 image. It takes a few seconds and your prompt will change to a Linux prompt when it’s done.
How to stop WSL2 image
First you have to exit from the Linux prompt by typing exit
Then enter the command below in the windows prompt
wsl --shutdown <imagename>
This takes a bit longer – up to 20 seconds to shut down your image, but when done the wsl -l -v should show as shutdown