Table of contents
- Why WSL/WSL2 is a Game-Changer
- 1. Minimal System Requirements
- 2. Seamless Integration
- 3. Supports Popular DevOps Tools
- 4. Quick Setup and Easy Updates
- How to Install and Set Up WSL/WSL2
- Step 1: Check Your Windows Version
- Step 2: Enable WSL and Virtual Machine Platform
- Step 3: Update the WSL Kernel
- Step 4: Set WSL2 as the Default Version
- Step 5: Install a Linux Distribution
- Step 6: Verify the Installation
- Hands on part
In the world of software development and DevOps, the ability to work seamlessly between Linux and Windows environments is a game-changer. Traditionally, developers and DevOps enthusiasts would either set up dual-boot systems or use virtual machines to practice tools and technologies. However, these approaches often require high system resources like RAM and CPU, which may not be available to everyone.
To address this challenge, Microsoft has introduced Windows Subsystem for Linux (WSL) and its enhanced version, WSL2, allowing users to run Linux distributions directly on Windows without the need for dual-boot or heavy virtual machines. This technology has revolutionized the way developers and DevOps practitioners work, offering an efficient and resource-friendly solution to practice tools and workflows.
Why WSL/WSL2 is a Game-Changer
1. Minimal System Requirements
WSL/WSL2 eliminates the need for high system resources. Unlike virtual machines or dual-boot setups, it runs Linux directly within Windows, making it accessible even on systems with limited RAM and CPU.
2. Seamless Integration
With WSL, you can:
Run Linux commands alongside Windows commands.
Access Linux files from Windows and vice versa.
Use your favorite Windows IDEs while working on Linux-based projects.
3. Supports Popular DevOps Tools
WSL2 provides a full Linux kernel, enabling support for tools like Docker, Kubernetes, Ansible, Terraform, and more, which are essential for DevOps workflows.
4. Quick Setup and Easy Updates
Installing and updating WSL is straightforward, allowing users to focus on learning and development rather than setup complexities.
How to Install and Set Up WSL/WSL2
Follow these steps to install and configure WSL/WSL2 on your Windows system:
Step 1: Check Your Windows Version
Ensure your Windows version supports WSL/WSL2:
Press
Win + R
, typewinver
, and press Enter.Your system must be running Windows 10 version 1903 or later (Build 18362+) or Windows 11.
Step 2: Enable WSL and Virtual Machine Platform
Open PowerShell as Administrator and run:
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
Step 3: Update the WSL Kernel
Download and install the latest WSL2 kernel update from the Microsoft WSL2 Kernel Update page.
The Windows Subsystem for Linux kernel can be manually updated with 'wsl --update', but automatic updates cannot occur due to your system settings.
To receive automatic kernel updates, please enable the Windows Update setting: 'Receive updates for other Microsoft products when you update Windows'.
For more information please visit https://aka.ms/wsl2kernel.
The WSL 2 kernel file is not found. To update or restore the kernel please run 'wsl --update'.
--------------------------------------------
PS C:\Windows\system32> wsl --update
output:-
Installing: Windows Subsystem for Linux
Windows Subsystem for Linux has been installed.
Step 4: Set WSL2 as the Default Version
Run the following command in PowerShell:
wsl --set-default-version 2
Step 5: Install a Linux Distribution
Open the Microsoft Store.
Search for your preferred Linux distribution (e.g., Ubuntu, Debian, Kali Linux).
Click Install.
Launch the distribution and complete the setup by creating a Linux username and password.
For example, to install Ubuntu 22.04 LTS, you can use this command in PowerShell:
wsl --install -d Ubuntu-22.04
Step 6: Verify the Installation
To check the installed distributions and their WSL version, run:
wsl --list --verbose
You should see your installed Linux distribution with VERSION
set to 2
.
Hands on part
Step 1:
Press Win + R to open the Run dialog.
Type
winver
and press Enter to check your Windows version.
Step 2:
Press the Windows key, type "Turn Windows features on or off", and select the option.
In the list of features, enable:
Windows Subsystem for Linux (WSL)
Virtual Machine Platform
Click OK and restart your computer if prompted.
Step 3:
- Follow the above steps to ensure the features are enabled correctly.
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
Try the new cross-platform PowerShell https://aka.ms/pscore6
PS C:\Windows\system32>
PS C:\Windows\system32> wsl --status
Default Version: 2
The Windows Subsystem for Linux kernel can be manually updated with 'wsl --update', but automatic updates cannot occur due to your system settings.
To receive automatic kernel updates, please enable the Windows Update setting: 'Receive updates for other Microsoft products when you update Windows'.
For more information please visit https://aka.ms/wsl2kernel.
The WSL 2 kernel file is not found. To update or restore the kernel please run 'wsl --update'.
PS C:\Windows\system32> wsl --update
Installing: Windows Subsystem for Linux
Windows Subsystem for Linux has been installed.
PS C:\Windows\system32> wsl --status
WSL is finishing an upgrade...
Default Version: 2
PS C:\Windows\system32> wsl --set-default-version 2
For information on key differences with WSL 2 please visit https://aka.ms/wsl2
The operation completed successfully.
PS C:\Windows\system32> ^C
PS C:\Windows\system32> wsl --list --verbose
Windows Subsystem for Linux has no installed distributions.
Use 'wsl.exe --list --online' to list available distributions
and 'wsl.exe --install <Distro>' to install.
Distributions can also be installed by visiting the Microsoft Store:
https://aka.ms/wslstore
Error code: Wsl/WSL_E_DEFAULT_DISTRO_NOT_FOUND
PS C:\Windows\system32> wsl.exe --list --online
The following is a list of valid distributions that can be installed.
Install using 'wsl.exe --install <Distro>'.
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
Ubuntu-24.04 Ubuntu 24.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.6 openSUSE Leap 15.6
SUSE-Linux-Enterprise-15-SP5 SUSE Linux Enterprise 15 SP5
SUSE-Linux-Enterprise-15-SP6 SUSE Linux Enterprise 15 SP6
openSUSE-Tumbleweed openSUSE Tumbleweed
PS C:\Windows\system32> wsl --install -d Ubuntu-22.04
Installing: Ubuntu 22.04 LTS
Ubuntu 22.04 LTS has been installed.
Launching Ubuntu 22.04 LTS...
Installing, this may take a few minutes...
Please create a default UNIX user account. The username does not need to match your Windows username.
For more information visit: https://aka.ms/wslusers
Enter new UNIX username: tksahu
New password:
Retype new password:
passwd: password updated successfully
Installation successful!
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.
Welcome to Ubuntu 22.04.5 LTS (GNU/Linux 5.15.167.4-microsoft-standard-WSL2 x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/pro
System information as of Tue Jan 21 17:35:22 IST 2025
System load: 0.38 Processes: 51
Usage of /: 0.1% of 1006.85GB Users logged in: 0
Memory usage: 9% IPv4 address for eth0: 172.18.76.209
Swap usage: 0%
This message is shown once a day. To disable it please create the
/home/tksahu/.hushlogin file.
tksahu@DESKTOP-R12R5NH:~$ ls
tksahu@DESKTOP-R12R5NH:~$ pwd
/home/tksahu
tksahu@DESKTOP-R12R5NH:~$ sudo apt update && sudo apt upgrade
[sudo] password for tksahu:
Hit:1 http://archive.ubuntu.com/ubuntu jammy InRelease
Get:2 http://security.ubuntu.com/ubuntu jammy-security InRelease [129 kB]
Get:3 http://archive.ubuntu.com/ubuntu jammy-updates InRelease [128 kB]
Get:4 http://security.ubuntu.com/ubuntu jammy-security/main amd64 Packages [2041 kB]
Get:5 http://archive.ubuntu.com/ubuntu jammy-backports InRelease [127 kB]
Get:6 http://archive.ubuntu.com/ubuntu jammy/universe amd64 Packages [14.1 MB]
Get:7 http://security.ubuntu.com/ubuntu jammy-security/main Translation-en [321 kB]
Get:8 http://security.ubuntu.com/ubuntu jammy-security/restricted amd64 Packages [2772 kB]
Get:9 http://security.ubuntu.com/ubuntu jammy-security/restricted Translation-en [484 kB]
Get:10 http://security.ubuntu.com/ubuntu jammy-security/universe amd64 Packages [960 kB]
Get:11 http://security.ubuntu.com/ubuntu jammy-security/universe Translation-en [205 kB]
Get:12 http://security.ubuntu.com/ubuntu jammy-security/universe amd64 c-n-f Metadata [19.5 kB]
Get:13 http://security.ubuntu.com/ubuntu jammy-security/multiverse amd64 Packages [37.6 kB]
Get:14 http://security.ubuntu.com/ubuntu jammy-security/multiverse Translation-en [8260 B]
Get:15 http://security.ubuntu.com/ubuntu jammy-security/multiverse amd64 c-n-f Metadata [224 B]
Get:16 http://archive.ubuntu.com/ubuntu jammy/universe Translation-en [5652 kB]
Get:17 http://archive.ubuntu.com/ubuntu jammy/universe amd64 c-n-f Metadata [286 kB]
Get:18 http://archive.ubuntu.com/ubuntu jammy/multiverse amd64 Packages [217 kB]
Get:19 http://archive.ubuntu.com/ubuntu jammy/multiverse Translation-en [112 kB]
Get:20 http://archive.ubuntu.com/ubuntu jammy/multiverse amd64 c-n-f Metadata [8372 B]
Get:21 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages [2276 kB]
Get:22 http://archive.ubuntu.com/ubuntu jammy-updates/main Translation-en [382 kB]
Get:23 http://archive.ubuntu.com/ubuntu jammy-updates/restricted amd64 Packages [2877 kB]
Get:24 http://archive.ubuntu.com/ubuntu jammy-updates/restricted Translation-en [501 kB]
Get:25 http://archive.ubuntu.com/ubuntu jammy-updates/universe amd64 Packages [1182 kB]
Get:26 http://archive.ubuntu.com/ubuntu jammy-updates/universe Translation-en [289 kB]
Get:27 http://archive.ubuntu.com/ubuntu jammy-updates/universe amd64 c-n-f Metadata [26.4 kB]
Get:28 http://archive.ubuntu.com/ubuntu jammy-updates/multiverse amd64 Packages [44.5 kB]
Get:29 http://archive.ubuntu.com/ubuntu jammy-updates/multiverse Translation-en [11.5 kB]
Get:30 http://archive.ubuntu.com/ubuntu jammy-updates/multiverse amd64 c-n-f Metadata [440 B]
Get:31 http://archive.ubuntu.com/ubuntu jammy-backports/main amd64 Packages [67.7 kB]
Get:32 http://archive.ubuntu.com/ubuntu jammy-backports/main Translation-en [11.1 kB]
Get:33 http://archive.ubuntu.com/ubuntu jammy-backports/main amd64 c-n-f Metadata [388 B]
Get:34 http://archive.ubuntu.com/ubuntu jammy-backports/restricted amd64 c-n-f Metadata [116 B]
Get:35 http://archive.ubuntu.com/ubuntu jammy-backports/universe amd64 Packages [28.9 kB]
Get:36 http://archive.ubuntu.com/ubuntu jammy-backports/universe Translation-en [16.5 kB]
Get:37 http://archive.ubuntu.com/ubuntu jammy-backports/universe amd64 c-n-f Metadata [672 B]
Get:38 http://archive.ubuntu.com/ubuntu jammy-backports/multiverse amd64 c-n-f Metadata [116 B]
Fetched 35.3 MB in 17s (2076 kB/s)
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
11 packages can be upgraded. Run 'apt list --upgradable' to see them.
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
#
# Patches available for rsync vulnerabilities, including a potential RCE,
# tracked by CVE-2024-12084 through CVE-2024-12088 and CVE-2024-12747.
# For more see: https://ubuntu.com/blog/rsync-remote-code-execution
#
The following packages will be upgraded:
bind9-dnsutils bind9-host bind9-libs git git-man libpython3.10 libpython3.10-minimal libpython3.10-stdlib python3.10
python3.10-minimal rsync
11 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
8 standard LTS security updates
Need to get 13.4 MB of archives.
After this operation, 9216 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 libpython3.10 amd64 3.10.12-1~22.04.8 [1949 kB]
Get:2 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 python3.10 amd64 3.10.12-1~22.04.8 [508 kB]
Get:3 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 libpython3.10-stdlib amd64 3.10.12-1~22.04.8 [1850 kB]
Get:4 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 python3.10-minimal amd64 3.10.12-1~22.04.8 [2268 kB]
Get:5 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 libpython3.10-minimal amd64 3.10.12-1~22.04.8 [815 kB]
Get:6 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 rsync amd64 3.2.7-0ubuntu0.22.04.4 [437 kB]
Get:7 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 bind9-host amd64 1:9.18.30-0ubuntu0.22.04.1 [52.1 kB]
Get:8 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 bind9-dnsutils amd64 1:9.18.30-0ubuntu0.22.04.1 [158 kB]
Get:9 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 bind9-libs amd64 1:9.18.30-0ubuntu0.22.04.1 [1257 kB]
Get:10 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 git-man all 1:2.34.1-1ubuntu1.12 [955 kB]
Get:11 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 git amd64 1:2.34.1-1ubuntu1.12 [3165 kB]
Fetched 13.4 MB in 4s (2981 kB/s)
(Reading database ... 42578 files and directories currently installed.)
Preparing to unpack .../00-libpython3.10_3.10.12-1~22.04.8_amd64.deb ...
Unpacking libpython3.10:amd64 (3.10.12-1~22.04.8) over (3.10.12-1~22.04.7) ...
Preparing to unpack .../01-python3.10_3.10.12-1~22.04.8_amd64.deb ...
Unpacking python3.10 (3.10.12-1~22.04.8) over (3.10.12-1~22.04.7) ...
Preparing to unpack .../02-libpython3.10-stdlib_3.10.12-1~22.04.8_amd64.deb ...
Unpacking libpython3.10-stdlib:amd64 (3.10.12-1~22.04.8) over (3.10.12-1~22.04.7) ...
Preparing to unpack .../03-python3.10-minimal_3.10.12-1~22.04.8_amd64.deb ...
Unpacking python3.10-minimal (3.10.12-1~22.04.8) over (3.10.12-1~22.04.7) ...
Preparing to unpack .../04-libpython3.10-minimal_3.10.12-1~22.04.8_amd64.deb ...
Unpacking libpython3.10-minimal:amd64 (3.10.12-1~22.04.8) over (3.10.12-1~22.04.7) ...
Preparing to unpack .../05-rsync_3.2.7-0ubuntu0.22.04.4_amd64.deb ...
Unpacking rsync (3.2.7-0ubuntu0.22.04.4) over (3.2.7-0ubuntu0.22.04.2) ...
Preparing to unpack .../06-bind9-host_1%3a9.18.30-0ubuntu0.22.04.1_amd64.deb ...
Unpacking bind9-host (1:9.18.30-0ubuntu0.22.04.1) over (1:9.18.28-0ubuntu0.22.04.1) ...
Preparing to unpack .../07-bind9-dnsutils_1%3a9.18.30-0ubuntu0.22.04.1_amd64.deb ...
Unpacking bind9-dnsutils (1:9.18.30-0ubuntu0.22.04.1) over (1:9.18.28-0ubuntu0.22.04.1) ...
Preparing to unpack .../08-bind9-libs_1%3a9.18.30-0ubuntu0.22.04.1_amd64.deb ...
Unpacking bind9-libs:amd64 (1:9.18.30-0ubuntu0.22.04.1) over (1:9.18.28-0ubuntu0.22.04.1) ...
Preparing to unpack .../09-git-man_1%3a2.34.1-1ubuntu1.12_all.deb ...
Unpacking git-man (1:2.34.1-1ubuntu1.12) over (1:2.34.1-1ubuntu1.11) ...
Preparing to unpack .../10-git_1%3a2.34.1-1ubuntu1.12_amd64.deb ...
Unpacking git (1:2.34.1-1ubuntu1.12) over (1:2.34.1-1ubuntu1.11) ...
Setting up bind9-libs:amd64 (1:9.18.30-0ubuntu0.22.04.1) ...
Setting up libpython3.10-minimal:amd64 (3.10.12-1~22.04.8) ...
Setting up git-man (1:2.34.1-1ubuntu1.12) ...
Setting up bind9-host (1:9.18.30-0ubuntu0.22.04.1) ...
Setting up rsync (3.2.7-0ubuntu0.22.04.4) ...
rsync.service is a disabled or a static unit not running, not starting it.
Setting up python3.10-minimal (3.10.12-1~22.04.8) ...
Setting up libpython3.10-stdlib:amd64 (3.10.12-1~22.04.8) ...
Setting up git (1:2.34.1-1ubuntu1.12) ...
Setting up bind9-dnsutils (1:9.18.30-0ubuntu0.22.04.1) ...
Setting up libpython3.10:amd64 (3.10.12-1~22.04.8) ...
Setting up python3.10 (3.10.12-1~22.04.8) ...
Processing triggers for man-db (2.10.2-1) ...
Processing triggers for libc-bin (2.35-0ubuntu3.8) ...
tksahu@DESKTOP-R12R5NH:~$ exit
logout
Getting Started with WSL/WSL2
Once WSL/WSL2 is set up, you can:
Install DevOps Tools: Use package managers like
apt
to install tools such as Docker, Kubernetes, Ansible, and Terraform.Develop and Test: Write and test scripts or applications in a real Linux environment without leaving Windows.
Integrate with Windows Tools: Use Windows applications like Visual Studio Code alongside Linux utilities for a seamless development experience.
Conclusion
WSL/WSL2 is a revolutionary technology that bridges the gap between Linux and Windows, making it easier than ever for developers and DevOps enthusiasts to practice and learn. With minimal system requirements and powerful features, it enables you to run Linux tools and workflows directly on your Windows machine, saving time and resources.
Whether you're a beginner or an experienced professional, WSL/WSL2 is the perfect tool to enhance your productivity and skills. So, get started today and unlock the full potential of Linux on Windows!