A quick note about the installation of windows subsystem for Linux because it simply rocks!

What is WSL

First and foremost what is this Windows Linux Subsystem? Let me simply quote Microsoft documentation here:

"The Windows Subsystem for Linux lets developers run a GNU/Linux environment -- including most command-line tools, utilities, and applications -- directly on Windows, unmodified, without the overhead of a traditional virtual machine or dual-boot setup"


WSL Installation on Windows 10

  1. Check your windows build ID

    Window+R, type winver, Build should 19041 or higher.

    Either you will have to upgrade or you can proceed directly.

    • Follow the steps from Microsoft installation notes; they are very clear and quick
    • running a few (to be copy / pasted) Powershell commands in admin mode
    • install Linux kernel update package
  2. List the available distribution wsl --list -o


  3. Install a distribution
     wsl --install -d <distrib_name>
    
  4. Checks
    • wsl --list -v should show the linux is running in WSL2


    • you can check WSL is on via “Turn Windows features on or off”

Installation on a Non-System Drive

If you want to ensure your Windows system or user profile can be reinitialised without impacting your Linux you may want to deploy this latter on a non system drive (e.g.: D:\wsl\Ubuntu_2204.0.10.0_x64 in my case)

wsl --set-default-version 2
Invoke-WebRequest -Uri https://aka.ms/wslubuntu2204 -OutFile Ubuntu.appx -UseBasicParsing
move .\Ubuntu_2204.0.10.0_x64.appx Ubuntu_2204.0.10.0_x64.zip
Expand-Archive .\Ubuntu2204-220620.zip
cd .\Ubuntu2204-220620\
Expand-Archive .\Ubuntu_2204.0.10.0_x64.zip
ubuntu2204.exe --ui=none

Known Issues

You can find your DNS running nslookup under Windows command and then update etc/resolv.conf with on WSL e.g.: for google DNS

sudo bash -c 'echo "nameserver 8.8.8.8" >> /etc/resolv.conf'`

to keep the change you can follow the solution here otherwise it has been noted the file is reset periodically. cat /etc/wsl.conf and enter the following option

[network]
generateResolvConf = false

Then simply follow the below recipie

cd /etc/
sudo rm resolv.conf
cd /run
sudo rm resolvconf/resolv.conf
sudo vi /etc/resolv.conf + insert your config

You can validate it works fine

  • running from Powershell to restart WSL and check it works wsl --shutdown
  • connecting againg to your WSL and ping google.com

Developer Tools

You can pamper yourself installing Windows Terminal

Last but not least if you are a developer you may consider the plugin for VSCode plugin; you can then start VSCode simply with code . from any directory under linux.


Network

You can access your filesystem in the explorer via \\wsl$


You are all set!