Using Linux on Windows with WSL 2: Tips on Installation and Usage

wsl Journey as a Software Developer

Windows has long been the go-to operating system for most PC users, thanks to its ease of use and broad compatibility with hardware and software. However, for those who are interested in the power and flexibility of Linux, there has always been a trade-off: either switch to Linux completely or set up a dual-boot system, which can be time-consuming and cumbersome. Fortunately, with the advent of Windows Subsystem for Linux (WSL) 2, you can now run Linux on your Windows machine, without having to sacrifice your Windows environment.

What is WSL 2?

WSL 2 is a feature in Windows 10 and 11 that allows you to run a Linux distribution directly on your Windows machine. Unlike a virtual machine, which emulates a separate operating system on top of your existing operating system, WSL 2 integrates Linux into Windows at a system call level, allowing for faster and more seamless performance.

WSL 2 uses a lightweight virtual machine to run the Linux kernel, which means you can run a wide range of Linux applications and utilities, without having to install a full-blown Linux distribution. This makes it an ideal solution for developers, system administrators, and anyone who needs access to Linux tools and utilities on a Windows machine.

Installation

To get started with WSL 2, you need to enable it on your Windows machine. Here’s how:

  1. Make sure you’re running Windows 10 version 2004 or later.
    You can check this by going to Settings > System > About and looking under “Windows specifications”.
  2. Enable virtualization in your BIOS settings. Most modern CPUs support virtualization, but it may be disabled by default. You’ll need to check your motherboard manual or manufacturer’s website to find out how to enable virtualization.
  3. Enable WSL 2 in Windows.
    To do this, follow these steps:
    1. Open the Start menu and search for “Windows Features”.
    2. Select “Turn Windows Features on or off”.
    3. Scroll down to “Windows Subsystem for Linux” and check the box next to it.
    4. Scroll further down to “Virtual Machine Platform” and check that box too.
    5. Click “OK” and let Windows install the necessary components.
  4. Install a Linux distribution from the Microsoft Store.
    Some popular options include Ubuntu, Debian, and Kali Linux.
    Once you’ve installed a distribution, launch it from the Start menu or by typing “wsl” into the command prompt.

Usage

After you’ve installed a Linux distribution, you can launch it from the Start menu or by typing “wsl” into the command prompt. When you launch a Linux distribution for the first time, you’ll be asked to create a username and password.

Here are some tips to make the most of your Linux experience on Windows:

  1. Use the Windows Terminal:
    The Windows Terminal is a powerful tool that allows you to open multiple tabs and panes, and switch between them with ease.
    You can also customize the appearance and behavior of the Terminal to suit your needs.
    To install the Terminal, go to the Microsoft Store and search for “Windows Terminal”.
  2. Share files between Windows and Linux: By default, your Linux file system is isolated from your Windows file system. However, you can access your Windows files from within Linux by navigating to /mnt/c (or /mnt/d, /mnt/e, etc. for other drives). You can also access your Linux files from within Windows by going to \wsl$.
  3. Install your favorite Linux tools: One of the biggest advantages of using Linux on Windows is the ability to use Linux tools and utilities.
    You can use the apt-get package manager to install your favorite Linux programs, such as Git, Vim, and Node.js.
    To install a package, open the Terminal and type “sudo apt-get

Conclusion

WSL 2 is a powerful tool that allows Windows users to enjoy the benefits of Linux without having to give up their Windows environment. With the right setup and some basic Linux skills, you can use WSL 2 to run powerful Linux tools and utilities, share files between Windows and Linux, and even develop and deploy Linux-based applications on your Windows machine. Give it a try and see how much you can accomplish with this powerful combination of operating systems.