Starting with a vanilla Windows 10 environment, it took just a few simple steps to get going with Linux on my Windows machine in the Windows Subsystem for Linux (WSL). Note: this is not yet Version 2 of wsl which is currently in (limited) preview
- install Ubuntu App from Windows App Store
- enable Windows Linux Subsystem feature
- run Ubuntu (in elevated mode – as Windows Admin)
- create Linux user
- update Ubuntu (optional)
- do your Linux things
- understand interaction between Linux and Windows file system
- as an example: install and run Apache server (and access from web browser on Windows)
1. Download Ubuntu (or any other Linux distro) App from Windows App Store
2. Enable Windows Linux Subsystem feature
3. run Ubuntu (in elevated mode – as Windows Admin)
You are prompted to create a Linux user.
Update Ubuntu (optional)
sudo apt upgrade
4.do your Linux things
I did the somewhat confusing act of creating a user called linux – hence the weird home directory
and yes, I used vi to edit file myfile.txt!
5. understand interaction between Linux and Windows file system
The Linux file system is mapped to the Windows file system - in the following way (as I learned from this thread)
C:\Users\<Windows Username>\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState\rootfs\home\<Linux Username>
6. Install Apache
(see: https://www.how2shout.com/how-to/install-apache-on-windows-10-wsl-http-server.html)
Start the Apache HTTPD service
sudo service apache2 start
In my case, the popup for Windows Defender Firewall appeared and the initial startup of Apache failed.
By pressing Allow Access and trying again, I got Apache to start:
Access the Apache web server from the Windows Browser (outside WSL – at http://127.0.0.1):
Note on Docker:
I have tried to get Docker running no WSL. However, the most recent version of Docker Community Edition that has been verified to run on Windows Subsystem Linux is 17.09.0 (see: https://medium.com/faun/docker-running-seamlessly-in-windows-subsystem-linux-6ef8412377aa) and I could not easily find that version of Docker CE – though I did not try very hard.
Note 2: WSL is quite neatly separated from my regular Windows environment and in that sense is similar to a container or a VM. However, I can not run applications from or as a Docker Container – which is a bit of a shame.