Install Windows Subsystem for Linux

28/12/2020
Chưa phân loại

Install and Use Windows Subsystem for Linux(WSL)

Windows Subsystem for Linux is a utility developed by Microsoft to enable developers and Linux enthusiasts to run their favorite Linux environment natively on Windows 10 without the overhead of running a virtual machine. The way it works is similar to the way WINE works on Linux. WSL enables Linux binaries to run on Windows using a compatibility layer which translates the Linux system calls into Windows system calls.

Architecture

Arguably, WSL works better on Windows, than WINE does on Linux and the reason behind it is because Linux is peculiar in terms of its architecture. While most Operating systems consist of a Kernel and a whole suite of libraries and features built around that Kernel, Linux is just a Kernel. Most GNU/Linux distros take this Kernel and build an operating system stack on top of it. Depending on how you chose to build this stack you get different distributions like Debian, RedHat, etc.

To run Linux environment on Windows you would need to enable the WSL feature (we will cover this shortly) and then go to the Microsoft store to get a copy of your favourite distribution (Ubuntu, Debian, OpenSUSE, etc).

The first step enables the syscall translation layer and the second step brings in a light-weight stack of software to give you a complete Linux OS to run atop the WSL feature. Doing the opposite, that is to say running Windows applications on Linux is much harder because Windows is much more than just the NT kernel.

Because of this reason there’s no virtual machine involved in implementing WSL, making it an attractive option. You won’t have any loss in performance because no VMs are involved, just a native light-weight syscall translation layer.

Installation and Setup

On your Windows 10 PC, search for “Turn Windows features on or off” by clicking the Windows key and typing the same into the Start Menu. Once the Windows Features menu is opened scroll to the bottom where you will find “Windows Subsystem for Linux” feature. Check that box and click OK.

Windows would take care of the set up from here on and once everything is done it would require you to reboot your system to finalize the changes. After the reboot you can go to Microsoft Store and look for your favorite distribution in there.

You can search the store for your favorite distribution. Below is a screenshot of some of the most used distributions. You can see two variants of OpenSUSE, a Debian app and Kali Linux.

Of course, the most popular distribution is still Ubuntu with both 16.04 and 18.04 LTS available in the store.

Now you just have to pick the distribution that you want and install the corresponding app. We will be installing Ubuntu 18.04 LTS for our WSL environment. It is about 215 MB in size, much smaller than an entire Ubuntu installation.

Once, the app is installed you can launch it directly from the Microsoft Store app or by searching for it in your Start Menu. Upon being launched for the first time, it will take some time to set things up for you.

It might take upto 5 minutes, but once that is done you will be prompted to enter your new UNIX username and password and you are good to go!

The terminal launched will offer you almost all the functionalities of a Ubuntu system, except the GUI. Since most of the UNIX/Linux capabilities come for the power of the terminal this can get you a long way.

For example, we can start using this environment by updating all the packages installed in it.

$ sudo apt update && sudo apt upgrade -y

Things you can and can’t do in WSL environment

Now, the question that arises in everyone’s mind is — What’s the catch?

Let’s consider the opposite case. With technologies like WINE we know that not everything that can be done in Windows can be done on Linux. Low level system libraries like DirectX will not be available on Linux and a lot of applications on Windows rely on such libraries.

Operating systems like Windows 10, FreeBSD or Illumos are full-fledged operating systems, not just the kernel. With Windows since most of the libraries are proprietary and that makes the matter more difficult. This makes the job of a project like WINE, much harder.

With trying to emulate Linux on Windows, the opposite is true. Linux’s tight set of ABI calls (or syscalls) is all you need to translate into Windows to run everything on top of it. If we try to ask the Ubuntu on WSL what Kernel it is running, it will give you a Linux kernel version number, with Microsoft mentioned alongside the  version number to indicate that this is not the head branch of the Linux kernel project.

$ uname -a

If we dig deeper, we will find that while high level functionalities like filesystem layout, and network configurations are shown, the lower level activities like block storage layout won’t work.

For example, the following commands would work as expected:

$ df -h

$ ifconfig

Both the commands tell you information about your native system which is actually running Windows. It is not anything like running a VM where there are different network interfaces and different filesystems entirely.

However, commands like lsblk won’t work, because lower level block storage isn’t what Linux expects it to be. Similarly, installing OpenZFS is futile because OpenZFS installs a few loadable kernel modules and we don’t have a Linux kernel just an illusion of it.

The same is true if you are trying to run docker. When installing Docker, Ubuntu won’t complain, however, Docker service would not start, as it depends on Systemd which is absent in this subsystem.

You can, however, run a plethora of services and bash utilities to make your life easier. If you manage Linux servers for a living, you don’t have to have Linux on your desktop as well. You can run SSH clients, Docker client, bash, utilities like grep and awk, as well as your favorite programming language from Python to Rust in this environment without polluting your Windows system.

You can also run your CD/CI automation using Ansible, Puppet or any other technology that you prefer. That is to say, anything a DevOp, a web or application developer or tester would require from a Linux system can be achieved with WSL except for the people working with system software and/or kernel development.

Conclusion

Got your own thoughts or experience with Windows Subsystem on Linux? Or maybe you still have questions that you need answers to. Contact us with your queries and we will cover that topic for you.

ONET IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, ONET IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

Python Plotly Tutorial

Plotly is an analytics company known for developing real-time analytics, statistics and graphing tools for web-based application...
29/12/2020

Linux cp Command

“cp” is a built-in tool for all the UNIX-based platforms that are used to make copies of the file(s) and directory(s)....
29/12/2020

How to Create a Bootable Linux USB Flash Drive?

One great thing about Linux is that you can try it out without installing it on your hard drive. Most Linux distributions...
29/12/2020
Bài Viết

Bài Viết Mới Cập Nhật

Mua Proxy V6 Nuôi Facebook Spam Hiệu Quả Tại Onetcomvn
03/06/2024

Hướng dẫn cách sử dụng ProxyDroid để duyệt web ẩn danh
03/06/2024

Mua proxy Onet uy tín tại Onet.com.vn
03/06/2024

Thuê mua IPv4 giá rẻ, tốc độ nhanh, uy tín #1
28/05/2024

Thuê địa chỉ IPv4 IPv6 trọn gói ở đâu chất lượng, giá RẺ nhất?
27/05/2024