How to Install a Linux Distribution on Windows 10/11 with WSL & WSL2
Guide Installation Linux Windows WSL WSL2Hi all, welcome to MusaBase! In this step-by-step guide, we will learn how to install and configure a Linux Distribution on Windows 10/11 using WSL or WSL2. In this comprehensive guide, we'll learn how we can:
- Turn on Windows Features for WSL Dependencies
- Install WSL
- Configure WSL
- Run Linux Apps on Windows
- Installing Xserver
- Run Linux Desktop Environment on Windows
By the end of this walkthrough we can enjoy Linux Services, Linux Terminal and the ability to run our favorite Linux tools side-by-side on our Windows desktop.
What is WSL/WSL2?
The WSL shorts for Windows Subsystem for Linux allows us to run a Linux distribution alongside Windows without a resource-heavy VM WSL1 uses a compatibility layer to translate Linux system calls to Windows. While WSL 2 boosts performance and compatibility by using a real Linux Kernel inside a lightweight VM. WSL2 is available on Windows 10 (version 2004, build 19041 or later) and Windows 11. Installing Windows 11 is nearly identical and benefits from tighter OS integration.
Prerequisites
- Processor: Intel or AMD 64-bit compatiable and must support virtualizaiton and also the Hardware-Assisted Virutalization or Intel VT-x or AMD-V should be enabled in your BIOS/UEFI.
- RAM: 8GB to 32GB (the more ram the better).
- Storage: WSL2 itself need around 5GB, though each Linux distro will need additional space.
- Windows Version:
- Windows 10: Version 2004 (build 19041 or later) for WSL2 (older versions can run only WSL 1 or require manual installation).
- Windows 11: Any edition.
Step 1: Enable Windows Features for WSL & WSL2
WSL requires two Windows features on Windows 10/11:
- Windows Subsystem for Linux
- Virtual Machine Platform
We can enable these two features either through:
- GUI (Graphical)
- PowerShell (Admin)
1.1. Enable via GUI
- Press the Windows key or open start-menu and type "Turn Windows features on or off" and open it.
- In the Windows Features dialog, check:
- Virtual Machine Platform
- Windows Subsystem for Linux
1.2. Enable via PowerShell (Admin)
- Press Windows key or open start menu and type in the search box PowerShell, then right-click and select Run as Administrator.
- In the elevated console, run:
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
Once the features are enabled (via GUI or PowerShell), restart the PC to complete the installtion.
Step 2: Install WSL & WSL2 on Windows 10/11
If you're running a supported Windows 10 build (2004, Build 19041 or later) or Windows 11, Microsoft provides a single command to install WSL end-to-end.
- Open PowerShell as an administrator.
- Run the command:
wsl --install
- After the installation finishes, restart PC to apply all changes.
Step 3: Launch Linux Shell with WSL
With the minimal Ubuntu installation complete, let's launch our new Linux environment.
- Open PowerShell as an administrator
- Run the command:
wsl
After running the command WSL system will ask you to set a Username and Password enter these and it will log you into your Ubuntu Linux System.
Now, we can launch any Linux application in Windows via WSL terminal or from the Start menu. Any application we install in Ubuntu will appear there, ready to launch with a single click.
A simple demonstration:
I'm going to run Krita, a powerful digital painting application originally designed for Linux.
Keep in mind this is a bare-minimal Linux System, which initially provides only command-line interface (CLI).
Step 4: Implementing GUI for WSL
Now, even though WSL (and WSL2) lets us run Linux and its apps on Windows, it's fundamentally designed as command-line interface. That means we can only interact via commands. However, we can still install and run a full Linux desktop environment ( for this guide, "Ubuntu") using one of two methods.
- X Server method
- Remote Desktop Protocol (RDP) method
4.1: X Server Method
X Server (Xorg) is the display server that provides a graphical interface for Linux applications. It bridges hardware and graphics software, letting GUI apps render on our Windows screen and accpet keyboard/mouse input.
4.1.1. Download X Server
- Download VcXsrv (X Server for Windows) from SourceForge link.
- Install it.
- URL of VcXsrv:
https://sourceforge.net/projects/vcxsrv/
Now that Ubuntu is installed under WSL, open the Ubuntu terminal from the start menu by typing "Terminal" in the search box.
- By default we'll get PowerShell, we can switch to Ubuntu by selecting it from the dropdown menu in the terminal's top left corner.
4.1.2. Update, Hold & Upgrade Packages
- In the Ubuntu terminal, run these commands consecutively:
sudo apt update
sudo apt-mark hold acpid
sudo apt upgrade
4.1.3. Install Ubuntu-Desktop & Gnome
- In the terminal, run:
sudo apt install ubuntu-desktop gnome
Note: If you already have systemd enabled (systemd=true) in your /etc/wsl.conf file then skip next two (4.1.4 and 4.1.5) step.
4.1.4. Enable Systemd
Ensure systemd is enabled (systemd=true) in wsl.conf file.
- In Ubuntu terminal run:
sudo nano /etc/wsl.conf
- If systemd=true isn't present, add the line under [boot], then press Ctrl + O to save and Ctrl + X to exit.
- Please, see the images for better clearification:
4.1.5. Update WSL
- In the Ubuntu terminal, type exit to close WSL session.
- In Window's PowerShell run these two commands consecutively:
wsl --shutdown
wsl --update
4.1.6. Define Environment Variables
- Reopen Ubuntu terminal.
- Next, run:
sudo nano ~/.bashrc
- In the bashrc file navigate to the bottom with down () arrow keys and add the environment variables, then press Ctrl + O to save and Ctrl + X to exit:
export DISPLAY="$(ip route | awk '{print $3; exit}')":0;
export XDG_CONFIG_HOME=$HOME/.config
export XDG_CONFIG_DIRS=/etc/xdg/xdg-ubuntu:/etc/xdg
export XDG_SESSION_DESKTOP=ubuntu
export XDG_SESSION_TYPE=x11
export XDG_CURRENT_DESKTOP=ubuntu:GNOME
export XDG_DATA_DIRS=/usr/share/ubuntu:/usr/local/share/:/var/lib/snapd/desktop
export GNOME_SHELL_SESSION_MODE=ubuntu
export XDG_RUNTIME_DIR="/run/user/1000"
- Next, in the terminal run these commands consecutively:
sudo mkdir -p /run/user/1000
sudo chmod 700 /run/user/1000
sudo chmod $(whoami): /run/user/1000
4.1.7. Launch X Server
Now laiunch VcXsrv (X Server) that we installed earlier.
- Open the Start menu, type xlaunch, and run the application.
- On "Select display settings" screen, choose "One large window" or "Fullscreen" based on your needs and click .
- On "Select how to start clients" screen, choose "Start no client" and Click .
- On "Extra settings" screen, tick all check boxes and add one parameter in Additional parameters for VcXsrv at the bottom and click :
-dpms
- On the final screen, click . VcXsrv will start, but we might see a black window until we launch our desktop session.
4.1.8. Launch Desktop Session
- Switch back to Ubuntu terminal in WSL.
- Run the following command:
dbus-launch --exit-with-session gnome-session
4.2: Remote Desktop Protocol (RDP) Method
This method is simpler to implement. With RDP, we can use any supported desktop environment without extra configuration.
4.2.1 Install Tasksel & XRDP
Tasksel is a tools that installs related group of packages in one go, similar to APT metapackages. It offers a simple interface for tasks like setting up a desktop environment or web server stack. While xrdp is an open-source implementation of the Microsoft Remote Desktop Protocol server. It allows user to connect to a Linux system from another Linux machine or a Windows device using RDP clients like the Microsof Remote Desktop Client.
- First update distro, by running sudo apt update && sudo apt upgrade.
- Then install tasksel and xdrp:
sudo apt install tasksel xrdp
4.2.2. Install an Desktop Enviornment
- In the Ubuntu terminal, run the following command to launch Tasksel interface:
sudo tasksel
- This command will open the following interface, from there we can install any Desktop Environment or Web Server stack
- Use keyboard's Up () and down () arrow keys to navigate thorugh several options.
- Press Space key to select the Desktop Environment you want.
- Press Tab to go to bottom's option section and choose OK to confirm the download and press Enter to continue.
4.2.3. Launch Ubuntu desktop session with RDP
- In the terminal run the following command to get the IP for RDP:
ip a
- This command will list network interfaces and their IP addresses.
- Note the eth0: interface's IPV4 address and copy it.
- Open Start menu and search for RDP or Remote Destkop Protocol in the search box and open it.
- In the RDP window we need to paste the ip address that we just copied and press on connect.
- If all goes well, we'll see a login prompt. Where we can enter the username and password that we created for Ubuntu under WSL.
Afterwards
WSL is designed primarily for command-line user and development, and while we can run a full desktop evnironment via X Server or RDP, GUI performance can be sluggish and unresponisve. I recommend using a dedicated virtual machine like Oracle Virtual Box or Mircosoft's Hyper-V, or setting up a traditional dual-boot for full native performance. With that said,
If you hit any error or encounter bugs, please let me know in the comments. I am more than happy to help.
1O1 out! i'll see you around.