Enable Windows Subsystem for Linux (WSL)

1. Prerequisites

  • WSL requires Windows 10, Version 1903 or higher, with Build 18362 or higher, for x64 systems, and Version 2004 or higher,
    with Build 19041 or higher, for ARM64 systems

  • To find your machine's architecture and Windows version/build number go to:

    • Settings > System > About

alt text 

2. Enable the Windows Subsystem for Linux feature

  • The easiest way to enable the feature is using the GUI

    • go to Start Menu, and search “Turn Windows feature on or off”

    • select Windows Subsystem for Linux and click OK

alt text 


3. After enabling Windows Subsystem for Linux, restart your computer when prompted

4. Install your Linux distribution of choice

  • Open the Microsoft Store and select the latest LTS Ubuntu Linux distribution available

5. Create a UNIX user

  • the first time you launch a Linux distribution in Windows, you will be prompted to create a UNIX username and password.

  • this UNIX username and password has no relationship to your Windows username and password, so to avoid any confusion use a different username
    (example: utalarico)

6. Update the Linux distribution

sudo apt-get update && sudo apt-get upgrade -y && sudo apt-get dist-upgrade -y && sudo apt-get autoremove -y

The -y flag signifies automatic yes to any prompts that may come up in the command line

7. Accessing the Windows filesystem from WSL

  • To make it easier to access your Windows user directory, consider adding a symbolic link, such as:

ln -s /mnt/c/Users/<windowsusername> ~/winhome

(example of windowsusername: claudio)

8. Starting up WSL

  • in general, to start using WSL, open up a PowerShell terminal and type wsl. If you’ve set up WSL correctly, you’ll enter a bash terminal running on
    the WSL distro of choice. From here, you can run any Linux commands you wish.

  • in our specific case, since we have installed mobaXterm we can also start the WSL terminal through MobaXterm

alt text 

9. WSL and Graphical Applications

  • To run Linux GUI applications using WSL, you must:

    • install an X server for Windows

    • configure bash to tell the GUIs applications to use the local X server

  • Method 1:

    • Don't do anything: take advantage of the Xserver provided by mobaXterm.

    • the configuration of the Xserver is directly handled by mobaxterm.

  • Method 2:

    • since to run graphical Linux applications, you need an X server, install VcXsrv.

    • VcXsrv is the only fully open source and up-do-date native X server for Windows.

    • download and run the latest installer, then locate the XLaunch shortcut in the Start Menu, and click it.

    • configure the bash shell to use the local X server:

in bash run:

echo "export DISPLAY=localhost:0.0" >> ~/.bashrc

and then to have the configuration changes take effect, restart the bash or run:

. ~/.bashrc