Sunday, February 16, 2025

How to Run Linux on Windows with WSL (Update 2025)


Have you ever wished you could harness the power of Linux directly on your Windows machine without the complexities of dual-booting or virtual machines? The Windows Subsystem for Linux (WSL) makes this a reality! Now, you can effortlessly install and run a complete Linux environment right within Windows, enjoying seamless integration, top-notch performance, and the flexibility to switch between operating systems instantly.

This guide will walk you through installing Ubuntu 24.04 LTS (Noble Numbat), the latest Long Term Support release, on Windows using WSL. Get ready to unlock a world of Linux tools and capabilities without leaving the comfort of your Windows desktop.

Why Choose WSL for Linux on Windows?

Before we dive into the installation, let's understand why WSL is a game-changer for running Linux on Windows. Compared to traditional dual-booting or virtual machines, WSL offers compelling advantages:

  • No Rebooting Required: Say goodbye to the cumbersome process of rebooting to switch between operating systems. With WSL, you can move between Windows and your Linux environment in a flash.
  • Efficient Resource Utilization: Unlike resource-heavy virtual machines, WSL is designed for minimal overhead. It consumes significantly less RAM and CPU, allowing for a smoother and faster experience.
  • Seamless Integration: WSL bridges the gap between Windows and Linux like never before. Access Linux commands directly from your Windows terminal, share files effortlessly, and even run Linux GUI applications (with WSLg).
  • Developer-Friendly Environment: Developers will rejoice! WSL provides a genuine Linux environment perfect for running Linux-native development tools, package managers like apt, and scripts without complex configurations. It's ideal for web development, scripting, and working with open-source technologies.
  • Run Multiple Linux Distributions: Want to explore different flavors of Linux? WSL makes it easy to install and run multiple distributions side-by-side on the same Windows machine. Experiment with Ubuntu, Debian, Kali, and more!

Step-by-Step Guide: Installing Ubuntu 24.04 LTS on Windows with WSL

Ready to get started? Follow these simple steps to install Ubuntu 24.04 LTS on your Windows system using WSL:

Step 1: Enable the Windows Subsystem for Linux Feature

First, you need to activate the WSL feature in Windows.

  1. Open the Start Menu: Click on the Windows icon in your taskbar.
  2. Search for "Turn Windows features on or off": Type this phrase directly into the Start Menu search bar and click on the matching result.
  3. Locate "Windows Subsystem for Linux": In the "Windows Features" window, scroll down and find the option labeled "Windows Subsystem for Linux."
  4. Check the Box: Tick the checkbox next to "Windows Subsystem for Linux" to enable the feature.
    • (Consider adding a screenshot here showing the "Windows Features" window with "Windows Subsystem for Linux" checked)

Step 2: Install WSL and Ubuntu 24.04 LTS

The easiest way to install WSL and Ubuntu is using the command line.

  1. Open Command Prompt as Administrator: Right-click on the Start Menu icon and choose "Command Prompt (Admin)" or "Windows Terminal (Admin)". Click "Yes" to allow administrative privileges.

  2. Run the WSL Install Command: In the Command Prompt, type the following command and press Enter:

    Bash
    wsl --install
    

    This command performs several actions:

    • Enables the necessary WSL components.
    • Installs the WSL kernel.
    • Downloads and installs Ubuntu by default. For Ubuntu 24.04 LTS, this command will install the latest LTS version, which is currently 24.04.
    • (Consider adding a screenshot here showing the command being executed in Command Prompt)
  3. Set WSL 2 as Default (Recommended): WSL 2 offers significant performance improvements over WSL 1. To ensure you're using WSL 2, run this command:

    Bash
    wsl --set-default-version 2
    
  4. List Available Linux Distributions (Optional): If you're curious about other distributions you can install, use this command to see a list:

    Bash
    wsl --list --online
    

    You can install other distributions from this list using the command wsl --install -d <Distribution Name>. For example, to install Debian, you would use wsl --install -d Debian.

Step 3: Restart Your Windows Machine

After the installation is complete, you'll be prompted to restart your Windows machine. It's crucial to restart to finalize the WSL installation.

Step 4: Set Up Your Ubuntu User Account

Once your machine restarts, Ubuntu 24.04 LTS will automatically launch and complete the installation process. You'll be asked to create a username and password for your new Linux environment.

  1. Create a Username: Enter your desired username when prompted and press Enter. This username will be specific to your Ubuntu WSL environment.

  2. Set a Password: You'll be asked to create a password for your username. Enter your password and press Enter. You'll be asked to re-enter it for confirmation. Remember this password!

    (Consider adding a screenshot here showing the Ubuntu setup process in the terminal, prompting for username and password)

Final Step: Welcome to Ubuntu 24.04 LTS on WSL!

Congratulations! You've successfully installed Ubuntu 24.04 LTS using WSL. You can now launch your Ubuntu environment anytime by:

  1. Searching for "Ubuntu" in the Start Menu: Type "Ubuntu" in the Windows Start Menu search bar and click on the "Ubuntu" application to launch the terminal.

    (Consider adding a screenshot here showing the Ubuntu app in the Start Menu and the Ubuntu terminal window)

You'll be greeted by the Ubuntu terminal prompt, ready for you to explore the Linux command line!

Getting Started with Your Ubuntu WSL Environment

Here are a few essential first steps to take after installing Ubuntu on WSL:

  • Update and Upgrade Packages: It's always a good practice to update the package lists and upgrade installed packages to their latest versions. Run these commands in your Ubuntu terminal:

    Bash
    sudo apt update && sudo apt upgrade -y
    
  • Install Visual Studio Code (Optional but Recommended for Developers): VS Code works seamlessly with WSL. You can install it within your Ubuntu environment and enjoy coding with Linux tools while leveraging VS Code's powerful features.

    Bash
    sudo apt install code -y
    

    To launch VS Code from your Ubuntu terminal, simply type:

    Bash
    code .
    
  • File Sharing Between Windows and Linux: One of the great features of WSL is the easy file sharing between Windows and Linux.

    • Your Windows files are accessible within WSL under the /mnt/c/ directory (where c corresponds to your C: drive). You can navigate to your Windows files using commands like cd /mnt/c/Users/<YourWindowsUsername>/Documents.
    • Conversely, files in your WSL home directory (/home/<YourUbuntuUsername>) are accessible from Windows through the network path \\wsl$\Ubuntu-24.04\home\<YourUbuntuUsername>\ in File Explorer. (Note: The distribution name 'Ubuntu-24.04' might vary slightly depending on your installation).

    (Consider adding a screenshot or description of accessing WSL files from Windows File Explorer)

Conclusion

With Windows Subsystem for Linux and Ubuntu 24.04 LTS, you now have the best of both Windows and Linux at your fingertips. Whether you're a developer needing a Linux environment for your projects, a student learning Linux, or simply a tech enthusiast eager to explore, WSL makes running Linux on Windows incredibly easy and efficient.

0 comments:

Post a Comment