Step-by-Step Guide to Installing Ubuntu 24.04 on Windows 10/11 Using WSL2

Step-by-Step Guide to Installing Ubuntu 24.04 on Windows 10/11 Using WSL2

WSL2 (Windows Subsystem for Linux version 2) allows you to run a real Ubuntu Linux distribution directly within Windows without dual-booting, rebooting, or wiping your Windows installation. It's integrated into Windows 10 (version 2004 or higher, Build 19041+) and Windows 11 Home/Pro editions. You'll need administrator access for some steps.


This guide uses the official Microsoft method. All commands should be run in PowerShell as an administrator (right-click Start > Windows PowerShell (Admin) or Terminal (Admin)). I'll use full executable names like wsl.exe where applicable for clarity, but wsl works if it's in your PATH (which it will be after installation).



Prerequisites


  • Windows 10 version 2004+ (Build 19041+) or Windows 11.
  • At least 4GB RAM recommended for smooth performance.
  • Ensure virtualization is enabled in BIOS/UEFI (usually under CPU settings; restart and enter BIOS with Del/F2/F10 depending on your machine).
  • If WSL is already partially installed, you may need to adjust steps—check with wsl.exe --list --verbose.

Step 1: Install WSL2 and Enable Required Features


Open PowerShell as administrator and run:

>wsl.exe --install

  • This enables WSL, the Virtual Machine Platform (for WSL2), and installs the default Ubuntu distribution.
  • If it hangs at 0%, try: wsl.exe --install --web-download -d Ubuntu.
  • Restart your computer when prompted.

After restart, WSL2 is set as the default for new distributions.


Step 2: Verify WSL2 Installation and Set Default Version


In admin PowerShell, check installed distributions and versions:


>wsl.exe --list --verbose



  • Look for "*" next to the default distro and "2" under VERSION.

If needed, set WSL2 as default (usually already done):


>wsl.exe --set-default-version 2



Step 3: Install Ubuntu 24.04 LTS Specifically


First, list available distributions:

>wsl.exe --list --online

  • Look for "Ubuntu-24.04" or similar (it should be listed as Ubuntu 24.04 LTS is officially supported).

Install it:

>wsl.exe --install -d Ubuntu-24.04



  • If the exact name differs (e.g., "Ubuntu2404"), use that instead.
  • This downloads and installs from the Microsoft Store backend.

If it's not listed or you need a custom import (rare), download the .appx package from Microsoft's GitHub or Store, but the above should work.


Set it as default if installing multiple:


>wsl.exe --set-default Ubuntu-24.04

Step 4: Launch Ubuntu and Complete Initial Setup


  • From Start Menu: Search for "Ubuntu 24.04" and launch it.
  • Or in PowerShell: Run ubuntu2404.exe (or the exact name from wsl.exe --list).
  • Or generally: wsl.exe -d Ubuntu-24.04.

The first launch will:


  • Decompress files (takes a few minutes).
  • Prompt for a UNIX username (e.g., your Windows username or something new).
  • Set a password (not tied to Windows; remember it for sudo).

Example prompts:


  • Enter new UNIX username: yourusername
  • Enter new UNIX password: (type securely)
  • Retype new password: (confirm)

You're now in the Ubuntu shell! Your home directory is /home/yourusername/, and Windows drives are mounted under /mnt/ (e.g., C: is /mnt/c/).


Step 5: Update Ubuntu and Basic Configuration


In the Ubuntu terminal:

>sudo apt update && sudo apt upgrade -y


  • Enter your password when prompted.

To access Windows files:

  • Navigate to /mnt/c/Users/YourWindowsUsername/ (replace with your actual Windows username).

For better integration:


  • Install Windows Terminal from Microsoft Store for tabbed sessions.
  • To run graphical apps (optional, requires additional setup): Install X server like VcXsrv, then in Ubuntu: sudo apt install ubuntu-desktop and set export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2}'):0.

Troubleshooting


  • If virtualization isn't enabled: Error will mention it—enable in BIOS.
  • Command not found: Ensure you're in admin PowerShell.
  • Older Windows: Manual steps involve enabling features via dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart and dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart, then restart and install kernel from https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi.
  • Paths: WSL executables are typically in C:\Windows\System32\wsl.exe, but you don't need to specify full path unless PATH issues.

This setup runs Ubuntu as a lightweight VM under Windows Hyper-V. You can shut it down with wsl.exe --shutdown or uninstall with wsl.exe --unregister Ubuntu-24.04. For more, check wsl.exe --help.
 
Navigate to your working folder... and update the commend for installing tools for Linux Ubuntu:

>sudo apt update && sudo apt install -y git curl nano vim build-essential python3 xclip

  • Explanation:
    • sudo apt update: Refreshes the package list to ensure you get the latest versions.
    • sudo apt install -y: Installs the listed packages without prompting for confirmation.
    • Enter your flynn password when prompted.
  • Tools Installed:
    • git: For cloning repositories (e.g., git clone <repo-url>).
    • curl: For fetching data (e.g., curl https://api.example.com).
    • nano: Edit files (e.g., nano /mnt/c/Users/openr/Linux/script.sh).
    • vim: Advanced editing (e.g., vim /mnt/c/Users/openr/Linux/script.sh).
    • build-essential: For compiling code (includes gcc, g++, make).
    • python3: For Python scripting (e.g., python3 script.py).
    • xclip: For clipboard operations (e.g., echo "text" | xclip -selection clipboard).
Verify Installation:Check that each tool is installed by running:
bash

git --version
curl --version
nano --version
vim --version
gcc --version
python3 --version
xclip --version
 
Back
Top