Monday, November 12, 2018

Windows Subsystem for Linux, the best way to learn Linux on Windows

Looking to learn Linux but don't know how/where to start? WSL may be a good option for you.
Earlier this year, Microsoft released the Windows Subsystem for Linux (WSL). WSL lets developers run the GNU/Linux shell environment on a Windows 10 PC, including most command-line tools, utilities and some services, directly from source repos without the overhead of a virtual machine.

WSL is also the best way to learn Linux on Windows!

About WSL

Currently WSL supports Ubuntu, Debian, Suse and Kali distributions and can:
  • run bash shell scripts 
  • run GNU/Linux command-line applications including: vim, emacs, tmux
  • run programming languages like Javascript/Node.js, Ruby, Python, C/C++, C# & F#, Rust, Go, etc.
  • run background services like sshd, MySQL, Apache, lighttpd;
  • install additional software using own GNU/Linux distribution package manager.
  • invoke Windows applications.
  • access your Windows filesystem

Installing WSL on Windows 10

Installing WSL is covered by Microsoft on this article and is as easy is two steps. Let's take a quick look.

Step 1 - Run a Powershell Command

To install WSL on your Windows PC, it will be necessary to run PowerShell as Administrator (shift + right-click) and run the following command:
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux 
After the installation ends, restart your PC.

Step 2 - Install WSL

After installing the PowerShell, WSL can be installed through the Windows Store. To open the Windows Store on your Windows 10, click:
Start -> Type Store -> Click on the Windows Store:
Then type "Linux" on the search box and you should get something similar results to this:

To install any of those Distros, just click on the thumbnail, accept the terms and click Get!  Windows will download and install WSL for you

Running WSL

After installation started, you will be prompted to enter your username and password. After done, you'll get a cool Linux terminal to start playing with. You can even have multiple Distros installed on your Windows 10 machine.

On mine, I installed Debian and Ubuntu. Here's the last bit of the Debian installation :

Using the Terminal

After installation is done and you entered your credentials, potential next questions would be:
  • Where are my files? 
  • Do I have internet?
  • How do I install software?

Accessing my Windows Files

It's all there on the /mnt/c mount point. To verify on yours type mount on the command prompt and look for C: on it. Your windows files should be there.

Which I can list contents with ls:

Accessing the Internet

The WSL instance should have working internet out of the box. Testing the internet is as simple as doing a ping to Google:

If you're using Ubuntu, you can also verify your network info with ifconfig:

Installing Software

On Debian-based systems (Ubuntu included), installation is done by the apt command. For example, this is how we search packages:

Then, if I wanted to install packages, I could use apt-get install to install Ruby on the Ubuntu subsystem is just running the command below:
$ sudo apt-get install ruby-full

Other Tasks

Now that you understood how to locate your PC files, validated your access to the internet and installed some software, I'd recommend that you:


So you have the WSL installed on your machine and a Linux terminal ready to starting interacting with. Now what?

I would suggest that you learn basic system commands (ls, cp, man, rm, ps, etc), understand the filesystem, learn to manage software, understand the networking stack, install a new shell and review how to perform certain administrative tasks on the terminal. The Linux terminal is perfect for users who want to learn Linux and to those who spent a lot of time on Windows but need access to a Linux terminal.

Maybe you too realize that Linux is awesome and decides to use it as your main OS? For your information, here's why I use Fedora with the amazing i3 window manager.

See Also

Why I use Fedora
How I fell in love with i3 
Creating a Ubuntu Desktop instance on Azure
Building and Running ASP.NET Core apps on Linux
.NET Core and .NET merging as .NET 5.0
Installing and Running Docker on Linux

For other Linux posts on this blog, please click here.

Further Reading

    WSL - FAQ
    WSL - Installing
    WSL - Documentation
    WSL - Command Line Reference
    An A-Z of Linux – 40 Essential Commands You Should Know
    Linux Command Line tips that every Linux user should know
    Must-Know Linux Commands For New Users
    Do you have any comment on one this post? Contact me @BrunoHilden