What is WSL ? How to install WSL in Windows 11 ?
Tags: wsl, wsl2, windows11, linux
Published: 2023-04-29 10:19:31

## What is WSL?

WSL stands for Windows Subsystem for Linux. It is a feature in Windows 10 and windows 11 that allows developers to run Linux distributions natively on their Windows machines, without the need for a virtual machine or a dual-boot setup. This means that developers can use Linux tools and applications on a Windows machine, without having to switch between operating systems or set up complex virtualization environments.

There are two versions of WSL currently available: WSL 1 and WSL 2. WSL 1 is based on a translation layer that converts Linux system calls into Windows system calls, while WSL 2 runs a full Linux kernel in a lightweight virtual machine. WSL 2 offers better performance and compatibility with Linux applications.


## Advantages:

**1. Easy installation:** 
WSL can be easily installed through the Windows Store or PowerShell command line.

**2. Integration with Windows:** 
WSL integrates well with Windows, allowing for easy sharing of files between Linux and Windows environments.

**3. Familiarity with Windows tools:** 
Developers can use Windows tools like Visual Studio Code, while still being able to use Linux command-line tools.

**4. No need for a separate machine or virtualization:** 
WSL allows you to run Linux commands and tools natively on Windows without having to set up a separate machine or virtualization environment.

**5. Supports GUI:** 
In WSL2 you can use GUI applications using drivers which is supported by your laptop.


## Steps to install WSL2

If you're interested in installing and using WSL2, there are several important commands that you should know. In this article, we'll go over the commands to install the WSL2 in your windows.

Before getting started, it's important to note that you need to run all of these commands from an elevated Command Prompt or PowerShell terminal. To do this, simply right-click on the Command Prompt or PowerShell icon and select "`Run as Administrator`."

### 1. Install WSL
To install WSL, use the following command:

```
wsl --install
```
This will download and install the latest version of WSL on your system. It will by default install Ubuntu along with wsl2.

### 2. Install WSL with a Specific Distro
If you want to install WSL with a specific Linux distribution, you can use the following command:

```
wsl --install -d DISTRO-NAME
```
Replace "DISTRO-NAME" with the name of the Linux distribution you want to install. For example, to install Debian, you would use:

```
wsl --install -d Debian
```
After installing wsl reboot your system and launch the WSL by clicking on icon of Linux Distro in you system or simply type `wsl` in cmd or powershell. It will start linux environment in your windows and it will ask you to create username and password for wsl.
### 3. List of Available Linux Distributions
To see a list of available Linux distributions that you can install, use the following command:

```
wsl --list --online
```
### 4. List of Installed Linux Distributions
To see a list of installed Linux distributions in you system, use the following command:
```
wsl --list --verbose
```
You can also use the following command to get a list of installed distributions:

```
wsl -l -v
```
The first name in the list is the default distribution that WSL will use if you don't specify a distribution name.

### 5. Change Default
To change the default Linux distribution, use the following command:

```
wsl --set-default DISTRO-NAME
```
Replace "DISTRO-NAME" with the name of the Linux distribution you want to set as the default.

### 6. Update WSL
To update your WSL installation, use the following command:
```
wsl --update
```
### 7. Unregister WSL
If you want to uninstall any Distro of WSL first unregister it from your system. To unregister a Linux distribution, use the following command:
```
wsl --unregister DISTRO-NAME
```
In conclusion, knowing these basic WSL commands can help you get started with installing and managing WSL on your Windows machine. With WSL, you can enjoy the benefits of both the Windows and Linux ecosystems, making it a powerful tool for developers.