How to Run Linux on Windows with WSL | A Comprehensive Guide
7 mins read

How to Run Linux on Windows with WSL | A Comprehensive Guide

Running Linux on Windows has never been less difficult, thanks to the Windows Subsystem for Linux (WSL). Whether you’re a developer, a machine admin, or clearly exploring Linux, WSL gives a effective, light-weight manner to run Linux right away inner your Windows surroundings

Let’s dive into how you could run Linux on Windows 10 the usage of WSL.

What is Windows Subsystem for Linux (WSL)?

Windows Subsystem for Linux (WSL) is a function advanced with the aid of Microsoft that allows you to run Linux distributions which encompass Ubuntu, Debian, and Kali Linux proper away on Windows, with out the want for a digital system. It bridges the distance among Windows and Linux, allowing the use of Linux gear, utilities, and command-line device within the Windows surroundings.

There are two variations of WSL:

  • WSL1: A compatibility layer that translates Linux system calls into Windows system calls.
  • WSL2: A more advanced version that includes a full Linux kernel running inside a lightweight virtual machine, offering better system compatibility and performance.

Benefits of Using WSL

  • No Dual-Booting Required: No need to reboot your system to interchange among Windows and Linux.
  • Developer-Friendly: Run Linux-primarily based packages and development equipment directly inside Windows.
  • Performance: WSL, particularly WSL2, offers great performance for Linux applications without the overhead of a full virtual machine.
  • Seamless File Sharing:Easily access and manipulate files between Linux and Windows systems.

How to Set Up WSL2 in Windows 10

Setting up WSL2 on Windows 10 is a easy procedure. Just follow these steps:

Step 1: Enable WSL

To allow WSL, open PowerShell as an administrator and run the following command:

Enable WSL

 

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

This command will permit the Windows Subsystem for Linux characteristic in your gadget.

Step 2: Enable the Virtual Machine Platform

Next, you may need to allow the Virtual Machine Platform, which is required for WSL2:

  • Enter: “dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart”

This step sets up the virtualization technology needed for WSL2 to run.

Step 3: Install the WSL2 Kernel

Go to the official Microsoft website and download the Linux kernel update package for WSL2. Install the downloaded package on your PC.

Step 4: Set WSL2 as the Default Version

Now that you’ve installed the kernel, set WSL2 as the default version:

set wsl2 as the default version

  • Enter:“wsl –set-default-version 2”

This guarantees that WSL2 will be used by any Linux distributions you install in the future.

Step 5: Install a Linux Distribution

Open the Microsoft Store, look for your chosen Linux distribution (e.g., Ubuntu), and install it. Use the Start menu to launch the distribution after installation.

On the first release, you’ll want to set up your username and password.

Pro Tip: To transfer between WSL1 and WSL2, run the subsequent command:

Installation on linux distribution

  • Enter: wsl –set-version <distro_name> 2

Replace <distro_name> with the call of the mounted Linux distribution.

How to Access Linux Files from Windows

One of the largest advantages of using WSL is the potential to seamlessly access Linux documents from Windows. Here’s how:

Method 1: Access Linux Files via File Explorer

You can open Linux directories in Windows File Explorer with the following steps:

  • Open your Linux terminal.
  • Type the command: explorer.exe .

This will open the cutting-edge Linux directory in Windows File Explorer, permitting you to browse and manage your Linux documents as though they have been native Windows documents.

Method 2: Access Linux Files Directly from Windows

Alternatively, you can access your Linux distribution’s file system directly from Windows. Use the following path which access files with OneDrive on Windows File Explorer:`

Aceess linux Files Directly

  • Enter: “\\wsl$\<distro_name>\ “

This will give you direct access to the files within your Linux distribution.

Note: File access between Linux and Windows can be slower in WSL2 compared to WSL1, due to the virtualization layer.

How to Launch Linux Applications from WSL

WSL2 now supports graphical Linux applications, making it easy to run Linux GUI apps alongside your Windows applications.

Step 1: Install a Linux Application

First, install the Linux application you wish to run using your Linux distribution’s package manager (e.g., apt for Ubuntu). For example, to install the Gedit text editor:

install linux application

  • Enter: “sudo apt install gedit”

Step 2: Run the Application

After installation, run the application by typing its name in the Linux terminal:

Launch the application

  • Enter:  “gedit”

The app will open in a new window, just like any Windows software.

Key Differences Between WSL1 and WSL2

While every WSL1 and WSL2 let you run Linux on Windows, there are important variations a number of the 2:

  • Kernel: WSL1 translates Linux gadget calls to Windows, at the same time as WSL2 makes use of a actual Linux kernel.
  • Performance: WSL2 performs higher for obligations that require system calls or programs like Docker.
  • File Access: WSL1 offers faster file get right of entry to between Linux and Windows, at the same time as WSL2 excels in going for walks useful resource-heavy Linux applications.

Performance Differences: WSL1 vs WSL2

When it involves overall performance, here’s how WSL1 and WSL2 evaluate:

  • WSL1:
    • Faster for file-sharing obligations between Linux and Windows.
    • Suitable for light-weight applications that don’t require complex system calls.
  • WSL2:
    • Provides significantly better overall performance for aid-extensive programs.
    • Ideal for running complicated apps that require complete Linux kernel support.
    • Uses more machine assets, together with memory and CPU, due to the digital machine environment.

Limitations of WSL

While WSL is a powerful device, it has some limitations:

  • Limited Hardware Support: Certain peripherals, together with USB devices and GPUs, won’t work as expected. GPU aid for machine getting to know tasks remains constrained but improving.
  • No Full Linux Desktop: While you can run GUI applications, WSL isn’t a replacement for a full Linux computing device environment.
  • Resource Consumption: Since WSL2 runs in a digital device, it consumes greater memory and CPU than WSL1.

Best Practices for Using WSL

To maximize your experience with WSL, follow these best practices:

1. Use WSL2 for Resource-Intensive Applications

If you’re working with Docker, machine learning, or applications that rely heavily on system calls, use WSL2. Its performance is superior for such tasks due to its real Linux kernel.

2. Keep Windows and Linux Files Separate

For optimal performance, keep your Linux files in the Linux system and your Windows files in the Windows file system. This avoids slowdowns caused by cross-system file access.

3. Keep WSL Updated

Ensure you keep WSL up to date by checking for updates from Microsoft. Regular updates provide access to new features and performance improvements.

4. Optimize Resource Usage

If you’re using WSL2 and discover that it’s eating too much reminiscence or CPU, do not forget reducing the reminiscence allotted to the WSL2 virtual gadget

 You can customize Windows Subsystem for Linux (WSL) resource limits through configuration files.

Conclusion

Windows Subsystem for Linux (WSL) permits you to run Linux gear and programs seamlessly within your Windows environment. By putting in WSL2 and following the quality practices mentioned in this manual, you can harness the electricity of Linux with out leaving Windows. Whether you’re a developer, gadget administrator, or simply curious approximately Linux, WSL opens the door to countless possibilities.

 

Leave a Reply

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