Installing WSL - Setting up Linux Environment on Windows 10/11
☰ In this chapter, you will learn
- What is WSL and how is it used to set up Linux environments on Windows 10/11?
- How to Install WSL on Windows 10/11?
- How to Install Linux Distros on WSL?
- Launching Linux Distros for executing commands.
- How to remove WSL and Linux Distros from Windows 10/11?
- Basic WSL commands for configuration.
In Windows 10/11, there are several ways to execute Linux commands without installing Linux parallel with dual boots. In this section, we will teach you how can you use your existing Windows OS for executing Linux commands for educational purposes.
Understanding WSL
WSL stands for Windows Subsystem for Linux. This tool provides Linux kernel on the top of Windows kernel and allows you to run Linux Environment directly on a Windows system. You don't need to install bulky virtual machines and not need to setup dual-boot.
This tool is especially beneficial for developers working in a mixed environment, utilizing both Windows and Linux tools. It provides the flexibility to use a Linux terminal and execute Linux commands and applications seamlessly alongside their Windows counterparts.
How to Download, Install, and Setup WSL on Windows 10/11
Installing WSL on Windows 10/11 is as easy as navigating to the "Turn Windows features on or off" menu, checking the box for "Windows Subsystem for Linux," and then following the prompts to download and install the desired Linux distribution from the Microsoft Store.
Installing WSL
There are several ways to installing WSL on your Windows 10/11.
- Using the Command prompt or Powershell
- Using the Windows Features.
- Using the Microsoft Store.
Method 1: Installing WSL Using the Command prompt.
Step 1: Open Command Prompt or Powershell as Administrator.
Step 2: Type the following command. This command will install WSL with Ubuntu (default) operating system. If you don't want to install Ubuntu by default you can change Linux distros also using the provided command.
Option 1: Install WSL with Ubuntu.
>C:\Windows\System32> wsl -install
Installing: Ubuntu [ 30.23% ]
Option 2: Install WSL with another Distros.
Type following command for seeing the available Linux Distros. It will list all the available Linux Distros that can be used with WSL.
>C:\Windows\System32> wsl --list --online
The following is a list of valid distributions that can be installed. Install using 'wsl.exe --install'. NAME FRIENDLY NAME Ubuntu Ubuntu Debian Debian GNU/Linux kali-linux Kali Linux Rolling Ubuntu-18.04 Ubuntu 18.04 LTS Ubuntu-20.04 Ubuntu 20.04 LTS Ubuntu-22.04 Ubuntu 22.04 LTS OracleLinux_7_9 Oracle Linux 7.9 OracleLinux_8_7 Oracle Linux 8.7 OracleLinux_9_1 Oracle Linux 9.1 openSUSE-Leap-15.5 openSUSE Leap 15.5 SUSE-Linux-Enterprise-Server-15-SP4 SUSE Linux Enterprise Server 15 SP4 SUSE-Linux-Enterprise-15-SP5 SUSE Linux Enterprise 15 SP5 openSUSE-Tumbleweed openSUSE Tumbleweed To install your desired distros, type the following command.
>C:\Windows\System32> wsl --install -d Debian
Debian GNU/Linux is already installed. Launching Debian GNU/Linux... Installing, this may take a few minutes...
Step 3: Wait for the process to finish and then reboot your computer.
Step 4: If you wan to add more Linux distros, Open Microsoft Store, find Linux distros and Install them.
Step 5: To start writing command on Linux terminal, Open Elevated Command prompt or Powershell with administrator and type the distros name.
For example, if you want to open Ubuntu
terminal in the command prompt, just type Ubuntu and press Enter.
>C:\Windows\System32> Ubuntu
Welcome to Ubuntu 20.04.6 LTS (GNU/Linux 5.15.133.1-microsoft-standard-WSL2 x86_64) * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/pro prashant@easycodelab:~$
Method 2: Using the Windows Features
You can also install WSL using the Windows Features. Just follow the instructions and install WSL on your Windows 10/11 machine.
Step 1: Go to Start menu and Search for 'Windows features' and open 'Turn Windows features on or off'.
Step 2: Scroll down and locate 'Windows Sybsystem for Linux' and enable it by ticking the check box. Click 'Ok' to save settings.
Step 3: After the operation is complete, please restart your computer.
Step 4: Open Command Prompt as an administrator and type the following command to verify the WSL installation.
Check WSL version:Check installed Linux Distros:>C:\Windows\System32> wsl -v
WSL version: 2.0.9.0 Kernel version: 5.15.133.1-1 WSLg version: 1.0.59 MSRDC version: 1.2.4677 Direct3D version: 1.611.1-81528511 DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp Windows version: 10.0.22631.2861
>C:\Windows\System32> wsl -l -v
NAME STATE VERSION * Ubuntu Stopped 2 Ubuntu-20.04 Stopped 2 kali-linux Stopped 2 CentOS8 Stopped 2
Method 3: Using the Microsoft Store
You can also install WSL through the Microsoft Store, just like you would install any other Windows apps.
Step 1: Open Microsoft Store and Search for 'WSL'.
Step 2: Click on the 'Get' button to Install it.
Opening Linux Terminal
After installing WSL and your desired Distros, Launch terminal as follows:
Option 1: Click on the Start menu and search for distros and open it.
Option 2: Open Command Prompt as an administrator, type the name of the Linux distribution, and press Enter.
C:\Windows\System32> Ubuntu
prashant@easycodelab:~$
Option 3: Using Powershell
Step 1: Open Powershell as Administrator.
Step 2: Click on the Down arrow and select your distros.
How to Uninstall WSL and Linux Distros
If you wish to remove the entire WSL or specific Linux distributions, you can accomplish this by following these steps:
Option 1: Open 'Turn Windows features on or off,' then uncheck the 'Windows Subsystem for Linux' option. This action will remove WSL from your Windows machine.
Option 2: Click on the Start menu and search for 'WSL'. Right-click on 'WSL' and select 'Uninstall'.
Remove Distros
Option 1: Open the Start menu, locate your distribution, right-click on it, and select 'Uninstall.'
Option 2: Open Command Prompt as an Administrator and execute the following command to remove distros.
To see the Distros list:
C:\Windows\System32> wsl -l
Windows Subsystem for Linux Distributions:
Ubuntu (Default)
Ubuntu-20.04
kali-linux
CentOS8
To remove the Distros:
>C:\Windows\System32> wsl --unregister <DistroName>
Some basic WSL Commands
#
Description
Command
1
Installing WSL
wsl -install
2
Available Linux Distros online
wsl --list –online
3
Install Linux Distros
wsl --install -d <Distros name>
4
Update WSL
wsl --update
5
Check WSL status
wsl --status
6
Check WSL version
wsl --version
7
Shutdown wsl
wsl –shutdown
8
Check install distribution
wsl -l -v
9
Uninstall Distros
wsl --unregister <DistributionName>
Summary
C:\Windows\System32> wsl -l
>C:\Windows\System32> wsl --unregister <DistroName>
# | Description | Command |
---|---|---|
1 | Installing WSL | wsl -install |
2 | Available Linux Distros online | wsl --list –online |
3 | Install Linux Distros | wsl --install -d <Distros name> |
4 | Update WSL | wsl --update |
5 | Check WSL status | wsl --status |
6 | Check WSL version | wsl --version |
7 | Shutdown wsl | wsl –shutdown |
8 | Check install distribution | wsl -l -v |
9 | Uninstall Distros | wsl --unregister <DistributionName> |
In this tutorial, you learned how to configure your Windows 10/11 to install a Linux system. WSL enables you to run Linux distributions seamlessly alongside your Windows system, offering a convenient option for practicing Linux commands within your Windows environment.