• Home
  • |
  • Blog
  • |
  • What You Should Know About The Windows Subsystem For Linux In 2022?
What You Should Know about the Windows Subsystem for Linux in 2022

Are Linux and Windows being mentioned together? If yes, then what a mash-up? Is it something that might allow bridging the gap between the two worlds? In the past, people who used the Microsoft tech stack used Windows as their development environment, whereas others who were more interested in the open-source community preferred Linux. Before the advent of the Windows Subsystem for Linux (WSL), there was a distinct divide between the two, and they had never shared anything. But with WSL, developers now can work natively within Linux on their Windows 10 version desktop with the help of the Windows Subsystem for Linux or Windows WSL. Running a Linux system alongside a Windows system is greatly simplified and made more flexible by WSL.

What Is Windows Subsystem For Linux?

Windows Subsystem for Linux (WSL) enables native Linux 64-bit Executable and Linkable Format (ELF64) binaries to run on the Windows kernel in the Windows 10 operating system (OS).

WSL is a component that enables Linux development tools on Windows computers, but not workloads. It was initially developed as a Windows client system installation option.

To administer the Linux instance, WSL comes with a user-mode session management service, reduced Pico processes to handle Linux system calls, and Pico drivers to simulate the Linux kernel. This architecture allows the Windows kernel to receive and process Linux system calls.

This past week, Microsoft announced that Windows Subsystem for Linux version 2 (WSL2) is now compatible with Windows Server 2022.

The primary justifications for updating from WSL 1 to WSL 2 are:

  • Speed up the file system
  • Support system call compatibility.

WSL 2 runs a Linux kernel inside a lightweight utility virtual machine using the most recent virtualization technology (VM). WSL 2 is not a typical VM experience, though.

Comparison of WSL1 and WSL2

Except for performance across OS file systems, which can be solved by keeping your project files on the same operating system as the tools you are using to work on the project, the WSL 2 architecture performs better than WSL 1 in many areas.

Only Windows 11 or 10, Version 1903, Build 18362 or later support WSL 2. Other key differences between both versions are:

  • Architectural Difference

It is often time-consuming and resource-intensive to manage and boot up VMs in WSL 1. Neither of these characteristics exists in WSL 2.

WSL 2 offers advantages over WSL 1. These include seamless Windows and Linux integration, a tiny resource footprint, and no need to set up or manage virtual machines. Even though WSL 2 implements a virtual machine in the background, the interface is identical to WSL 1.

  • File IO Performance

A significant amount of time can be saved while performing file-intensive operations.The speed of your application may increase depending on how it communicates with the file system. WSL 2 performs more than 20 times faster than WSL 1 when unzipping a tarball, and 2 or 5 times faster when using git clone, npm install, or cmake.

  • WSL 2 Provides Full system call compatibility

In Linux, system calls are used to access files, request memory, and start processes. Contrary to WSL 1, which was based on a translation layer created by the WSL team, WSL 2 has a native Linux kernel that works with all system calls.

What Is The Use Of The Windows Subsystem For Linux?

With Windows subsystems for Linux, you can:

  • Select the GNU/Linux distributions you prefer from Microsoft store
  • Start up some ELF-64 binaries or standard command-line tools like grep, sed, or awk.
  • Run GNU/Linux command-line programs and Bash shell scripts, including: Tools: tmux, emacs, and vi, Languages like Go, Rust, NodeJS, Javascript, Python, Ruby, C/C++, C#, and F#, and Services: PostgreSQL, MongoDB, Apache, MySQL, SSHD, and lighttpd.
  • Install extra software using the package manager on your own GNU/Linux distribution.
  • Use a command-line shell similar to Unix to launch Windows apps.
  • Run GNU/Linux programs on a Windows computer.
  • Run Linux in a Bash shell (Ubuntu, Debian, OpenSUSE, Kali, Alpine, etc.). You may use Bash to run Linux command-line utilities and programs.

Why Use WSL Instead Of Linux In A Virtual Machine?

WSL uses fewer resources (CPU, memory, and storage) than an entire virtual machine. Along with running Linux command-line tools and applications alongside Windows command-line, desktop, and store apps, WSL also enables you to access Windows files from Linux and run Linux command-line tools and apps. This makes it possible for you to utilize both Windows applications and Linux command-line tools on the same set of files.

How To Set Up A WSL Development Environment?

As part of the Windows operating system, there is a subsystem for Linux called Windows Subsystem for Linux. Here’s a brief guide to setting up a WSL Development Environment:

Install Linux Distribution

Install a Linux distribution before enabling WSL. In order to take advantage of the streamlined-install command, you must use a recent version of Windows (Build 20262+). In order to find out what version and build number you have, press Windows logo key + R, enter winver, and click OK. Updates can be performed through the Settings menu or the Windows Update Assistant.

For additional information on how to install a Linux distribution other than Ubuntu or how to carry out these steps manually, check the WSL installation page.

Create a Linux Login and Password

After the WSL installation process has been completed, open the Linux distribution (Ubuntu by default). Usernames and passwords must be created for your Linux distribution.

Package Updates and Upgrades

Use your distribution’s package manager to update frequently and upgrade your packages.

No automatic updates or upgrades are performed by Windows. This is a task that most Linux users prefer to handle themselves.

Include More Distributions

If you’d like to install more Linux distributions through the Microsoft Store, you can sideload your own distribution, use the —import command, or sideload your own distribution from the Internet. Additionally, you might wish to create unique WSL images and distribute them throughout your enterprise company.

Configure Windows Terminal

Any application having a command line interface can be executed through Windows Terminal. A GPU accelerated text rendering engine, numerous tabs and panes, Unicode and UTF-8 character compatibility, the ability to build custom themes, and the ability to change text, background colors, and shortcuts are just a few of its key features.

When a new WSL Linux distribution is installed, a fresh instance of it inside the Windows Terminal will be generated and can be tailored to your tastes.

File Storage

Keep your project files on the same computer as the equipment you intend to utilize.

The fastest performance speed is achieved by saving files in the WSL file system (Ubuntu, OpenSUSE, etc.). You can use the Windows command line (PowerShell, Command Prompt) and Windows tools to save files on the Windows file system. Although files can be viewed from any operating system, performance may be noticeably slowed.

Choose a Code Editor of Your Choice

Since they natively allow remote development and WSL debugging, we advise using Visual Studio Code or Visual Studio. You may utilize WSL as a fully functional programming environment with Visual Studio Code. Visual Studio provides native WSL support for C++ cross-platform development.

Use Visual Studio Code

You can utilize WSL as your primary development environment from VS Code with the help of the Remote – WSL extension and Visual Studio Code.

Once VS Code is installed and configured, you can use a remote VS Code server to launch your WSL project.

Use Visual Studio

Using the same instance of Visual Studio 2022, you can build and debug CMake projects on Windows, WSL distributions, and SSH connections.

Using Git for Version Management

The most prevalent version control program is called Git. You can keep track of the changes you make to files using Git, so you have a record of what has been done and can go back to older versions if necessary. Git also facilitates cooperation by enabling the merging of several contributors’ edits into a single repository.

Configure Docker for Remote Development

Docker Desktop offers a development environment for creating, distributing, and running dockerized apps for Windows. You may run Linux and Windows containers in Docker Desktop on the same machine by turning on the WSL 2-based engine.

Create a Database

Start by connecting your project in WSL to a database. With MySQL, PostgreSQL, MongoDB, Redis, Microsoft SQL Server, or SQLite, you can get started in no time.

Set up GPU 

The Windows Subsystem for Linux (WSL) provides an excellent environment for running the most prevalent and well-liked GPU-accelerated machine learning applications, regardless of whether you’re a data scientist, ML engineer, or just getting started with ML. So, your next step should be installing and running GPU. 

Use Basic WSL Commands

The best way to administer Linux distributions installed via WSL is through PowerShell or Windows Command Prompt (CMD).

Mount an External Drive or USB

Use WSL 2 to mount your drive and read its content if you need to access a Linux disc format that Windows does not support. The procedures for locating the disc and partition to attach to WSL2, mounting them, and gaining access to them are covered in this lesson.

Run Linux GUI Apps

To run Linux GUI programs (X11 and Wayland) on Windows in a fully integrated desktop environment, you may now explore Windows Subsystem for Linux (WSL) compatibility. Linux GUI apps on Windows can now feel native and intuitive, thanks to WSL 2.

Pros and Cons of Using Windows Subsystem for Linux

Here are some pros and cons of using Windows Subsystem for Linux.

Pros

Ideal For Developers Who Use Open Source Tools

If you’re a developer already using open source tools, nothing beats the Windows subsystem for Linux. It’s ideal for those who want to use their existing development language and build tools or those who want to take advantage of their favorite programming languages that can run on both Windows and Linux.

Microsoft’s support for Linux has been steadily improving in recent years, but it’s still not as polished as the experience you get with a virtual machine or container. But if you need to run your code on multiple platforms, this is one of the only options to let you do it without having to install anything on your computer.

Windows-Linux Interoperability

Windows and Linux compatibility is made possible via WSL. Both Windows and the Linux file system are accessible for browsing. Additionally, they can run programs from one another’s command prompts.

This might result in some intriguing applications and perhaps a shift from viewing the two systems as competitors to seeing them as complementary settings.

Simpler Than Dual Boots or Virtual Machines

You don’t need to reboot or start a virtual machine because WSL already runs in Windows. When installing a system with dual booting, you must leave room on the hard drive and make sure you have backup media to boot from in case something goes wrong. You must restart your system if you want to use Windows to execute Linux software or vice versa.

Although a virtual machine (VM) is more straightforward and quicker to set up, Windows and Linux find it challenging to share data since the VM is still fundamentally a different machine. On the virtual system, a file server setup is frequently required. Additionally, virtual machines have a performance cost.

An Easy Introduction to Linux for Windows Users

For those who are unfamiliar with Linux, WSL can be the best starting point. They can become familiar with Linux commands without completely installing a new operating system. WSL may be set up with just a few mouse clicks from the Microsoft Store. Additionally, this will make it easier for people to adopt Linux.

Cons

You Continue to Use Windows

Because using WSL still entails being a part of that ecosystem, using it is objectionable to those who have an ideological objection to Microsoft and proprietary software.

The WSL would maintain participation. For ardent proponents of free software, nothing less than a PC running a free software version of GNU/Linux will do.

WSL wasn’t Created With Servers in Mind

The distributions aren’t made to function as servers, even though WSL can be installed on Windows Server. It is more challenging to start servers like Apache or MariaDB on Ubuntu because the system isn’t supported. Most users who require servers deploy regular Linux servers, so this may not be as significant a drawback.

WSL Could Discourage Desktop Linux Adoption

Fewer individuals might need to install a desktop version of Linux since WSL is compatible with Windows. Given that they already have a Windows desktop and can run Linux GUI applications on Windows, they may not see the need to adopt an entirely new desktop OS.

Suppose only a tiny percentage of Linux users run a complete desktop. In that case, there might not be as much effort to enhance hardware compatibility, which might only worsen issues with the Linux desktop.

Conclusion

As it currently stands, the WSL is pretty cool progress in Windows. Developers working in Windows can access a Linux environment thanks to Windows Subsystem for Linux. WSL offers a Linux kernel and enables you to install several distros inside the Windows environment, eliminating the need to launch a virtual machine or rely on a remote Linux computer for development.

The end goal is to provide an easy way to run Linux on Windows. Best of all, WSL doesn’t take up much memory (i.e., about 256 MB for Bash)—which means that your machine can run faster and smoother.

About the author

Arun KL

Hi All, I am Arun KL, an IT Security Professional. Founder of “thesecmaster.com”. Enthusiast, Security Blogger, Technical Writer, Editor, Author at TheSecMaster. To know more about me. Follow me on LinkedIn

Leave a Reply

Your email address will not be published. Required fields are marked

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

Learn Something New with Free Email subscription

Email is also one of the ways to be in touch with us. Our free subscription plan offers you to receive post updates straight to your inbox.