DEV Community

Cover image for Unlock your web development superpowers with WSL (Windows Subsystem for Linux)
Khalid ElGazzar
Khalid ElGazzar

Posted on • Originally published at swac.blog

Unlock your web development superpowers with WSL (Windows Subsystem for Linux)

As a web developer working on Windows, you may have felt left out when it comes to certain tools and technologies that are more readily available on Linux-based operating systems. However, the introduction of Windows Subsystem for Linux (WSL) has changed the game for Windows developers, providing a way to run Linux commands and tools natively on Windows.

In this post, we’ll introduce you to WSL, explain how to install it, and explore some of the ways in which it can benefit your web development workflow. Note that All IP rights to this blog post are reserved. Since I have been facing several content piracy cases lately, this blog post has ONLY been published on the Software, Architecture, and Cloud blog - SWAC.blog and canonically to dev.to only. If you are reading it elsewhere, then please let us know

What is WSL (Windows Subsystem for Linux) ?

Windows Subsystem for Linux is a feature of Windows 10 that allows you to run Linux-based applications directly on your Windows machine. This means that you can use tools and commands that were previously only available on Linux, without needing to set up a separate virtual machine or dual-boot your system.

There are two versions of WSL: WSL 1 and WSL 2. WSL 1 uses a translation layer to run Linux commands, while WSL 2 runs a full Linux kernel within a lightweight virtual machine. WSL 2 offers better performance and compatibility with Linux applications, but requires a more recent version of Windows 10.

Prerequisites

To use WSL, you’ll need a few things:

  • A Windows 10 machine with version 1903 or later
  • 64-bit Windows
  • At least 4 GB of RAM

You’ll also need to enable the Windows Subsystem for Linux feature on your system. To do this, follow these steps:

  1. Open the Start menu and search for “Turn Windows features on or off”.
  2. Select the “Windows Subsystem for Linux” option and click OK.
  3. Restart your computer when prompted.

Supported Distributions

WSL supports a variety of Linux distributions, including Ubuntu, Debian, Fedora, and more. You can install multiple distributions side-by-side and switch between them as needed.

Each distribution has its own set of packages and tools available, so you can choose the one that best suits your needs. For example, Ubuntu is a popular choice for web development due to its wide range of development tools and packages.

Installing WSL

There are a few different ways to install WSL on your system. Here are a few options:

Installing WSL through the Command Prompt (CLI)

To install WSL using the command prompt, follow these steps:

  1. Open the Start menu and search for “Command Prompt”.
  2. Right-click on the Command Prompt app and select “Run as administrator”.
  3. Enter the following command and press Enter:

    dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

  4. Restart your computer.

Installing WSL from the Windows CLI

Using the Microsoft Store to Install WSL

You can also install WSL through the Microsoft Store:

  1. Open the Microsoft Store app.
  2. Search for the Linux distribution you want to install (e.g. Ubuntu).
  3. Click on the distribution and select “Get”.
  4. Follow the prompts to install the distribution.

Installing Linux Distributions on WSL via the Terminal or GUI

Once you’ve enabled WSL on your system, you can install Linux distributions via the command line or using a graphical interface.

To install a distribution via the command line, open a terminal window and enter the following command:

wsl --install -d <distro>
Enter fullscreen mode Exit fullscreen mode

Replace <distro> with the name of the distribution you want to install (e.g. “ubuntu”).

Alternatively, you can use the GUI method to install a Linux distribution:

  1. Open the Microsoft Store app.
  2. Search for the Linux distribution you want to install (e.g. Ubuntu).
  3. Click on the distribution and select “Get”.
  4. Wait for the distribution to download and install.

Running WSL for the first time

Accessing Linux Files from Windows

One of the benefits of using WSL is that you can access Linux files from within Windows, and vice versa. This means you can easily work with files and folders across both operating systems.

To access Linux files from Windows, you’ll need to know the file path. The file path for Linux files is different from the file path for Windows files, so you’ll need to use the appropriate path format.

For example, to access the home directory for the Ubuntu distribution, you would use the following path:

\\wsl$\Ubuntu\home\<username>
Enter fullscreen mode Exit fullscreen mode

Replace <username> with your Ubuntu username.

Using WSL for Web Development

Now that you have WSL installed and set up, you can use it to improve your web development workflow in a variety of ways. Here are a few examples:

Running Web Servers

You can use WSL to run web servers on your local machine, just as you would on a Linux-based operating system. For example, you could install Apache or NGINX on your Ubuntu distribution and use it to serve web pages and applications.

Using Linux-Based Development Tools

Many web development tools and frameworks are designed to work best on Linux-based operating systems. With WSL, you can use these tools directly on your Windows machine, without needing to set up a separate virtual machine or dual-boot your system.

For example, you could use the command line tool “grep” to search for text within files, or use the “awk” tool to manipulate and analyze text data.

Developing Cross-Platform Applications

If you’re developing applications that need to run on both Windows and Linux, WSL can be a valuable tool for testing and debugging. You can use WSL to run your application in a Linux environment, ensuring compatibility and identifying any issues that may arise on different operating systems.

Removing WSL

If you decide you no longer need WSL on your system, you can easily remove it. To do so, follow these steps:

  1. Open the Start menu and search for “Control Panel”.
  2. Click on “Programs”.
  3. Click on “Turn Windows features on or off”.
  4. Uncheck the “Windows Subsystem for Linux” option and click OK.
  5. Restart your computer.

Conclusion

Windows Subsystem for Linux (WSL) is a powerful tool for web developers working on Windows machines. With WSL, you can run Linux-based tools and applications directly on your Windows system, streamlining your workflow and improving your productivity. Note that All IP rights to this blog post are reserved. Since I have been facing several content piracy cases lately, this blog post has ONLY been published on the Software, Architecture, and Cloud blog - SWAC.blog and canonically to dev.to only. If you are reading it elsewhere, then please let us know

By installing and using WSL, you can take advantage of Linux-based development tools, run web servers on your local machine, and develop cross-platform applications. And with support for a wide range of Linux distributions, you can customize your development environment to suit your needs.

So why not unlock your web development superpowers with WSL today? With a few simple steps, you can be up and running with a powerful Linux-based development environment on your Windows machine.

Top comments (0)