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.
In 2018, Microsoft released the Windows Subsystem for Linux (WSL). WSL lets developers run the GNU/Linux shell on a Windows 10 PC, a very convenient way to access the beloved tools, utilities and services Linux offers 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, Golang, Rust, C/C++, C# & F#, etc.
  • run background services like ssh shells, 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

On your Windows PC, you will need to run this PowerShell script as Administrator (shift + right-click):
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows -Subsystem-Linux
After the installation ends, restart your PC.

Step 2 - Install WSL

After the reboot, 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:

Click on the icon, accept the terms and 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

Okay, so now that we have access to our Linux shell, what to do next? Let's go through these use cases:
  • Accessing my Windows files
  • Access internet resources
  • I install software

Accessing my Windows Files

WSL mounts your Windows files 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.
In case you don't know Linux, listing files is done with   ls  . This is the content of my C drive as as seen from WSL:

Accessing the Internet

Your WSL instance should have access to the internet. Testing the internet is as simple as doing a ping to Google:

You can also verify your network info with ifconfig:

Installing Software

Installing software on Ubuntu/Debian is done by the apt command. For example, this is how we search packages:

To install packages, use apt-get install to install Ruby on the Ubuntu WSL by 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:
  • navigate and learn the basics of the filesystem;
  • try to edit files with vim or nano;
  • install software with apt (for Debian-based systems);
  • try some development (maybe write som Python scripts using the python console?);
  • run Node.js
  • test out cool terminal tools like the Ranger file manager and running Reddit, DuckDuckGo on the terminal


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

I would suggest that you learn basic system commands (ls, cp, man, rm, ps, etc), understand the filesystem, learn to add/remove software and run 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.

If you want to know more, here's why I use Fedora and 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 posts about Linux 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 or suggestion about this post? Please contact me @BrunoHilden