Using Linux on Windows: A Beginner's Guide to Installing Ubuntu via WSL

Sanjoy SahaSanjoy Saha
5 min read

Introduction:

Windows Subsystem for Linux (WSL) lets you run a full Linux distribution, such as Ubuntu, directly on your Windows machine without the need for a virtual machine. If you're a developer, student, or Linux enthusiast, this guide will help you install and run Ubuntu on Windows, allowing seamless use of Linux-based tools and commands.

In this beginner-friendly guide, we'll walk you through setting up WSL, installing Ubuntu, and getting started with Linux commands.


Why Choose Ubuntu?

Ubuntu is one of the most popular and beginner-friendly Linux distributions, making it ideal for both newcomers and experienced users. Key reasons to choose Ubuntu include:

  • Ease of use: A straightforward interface and smooth learning curve.

  • Great support: A large community with plenty of resources.

  • Developer-friendly: Access to a wide range of development tools, libraries, and frameworks.


Steps to Install Ubuntu on Windows Using WSL

Step 1: Enable WSL and Hyper-V / Windows Hypervisor Platform

Before you can install Ubuntu, you need to enable Windows Subsystem for Linux (WSL) and Hyper-V, the virtualization technology needed for WSL 2. If Hyper-V isn't available, you can enable Windows Hypervisor Platform as an alternative.

  1. Open "Turn Windows Features On or Off":

    • Press Win + R, type optionalfeatures, and hit Enter.

  2. Enable WSL:

    • Scroll down and check the option for Windows Subsystem for Linux.
  3. Enable Hyper-V / Windows Hypervisor Platform:

    • Scroll further and tick the option.

    • If Hyper-V isn't available on your system, instead enable Windows Hypervisor Platform.

  4. Restart Your System:

    • After enabling these features, restart your computer to apply the changes.

Step 2: Install Ubuntu via WSL

Once WSL and Hyper-V (or Windows Hypervisor Platform) are enabled, you can proceed to install Ubuntu.

  1. Open Command Prompt (or PowerShell):

    • Press Win + X and select Command Prompt (Admin) or Windows PowerShell (Admin).
  2. Run the WSL Installation Command:

     wsl --install
    

    This command installs WSL along with the default Linux distribution (which is typically Ubuntu). If you prefer to choose a different version or distribution, you can visit the Microsoft Store.

  3. Choose Ubuntu:

    • If multiple Linux distributions are available, choose Ubuntu for its simplicity and broad community support.

  4. Wait for Installation to Complete:

    • Once the installation finishes, restart your computer.

      OR

      Install Ubuntu from the Microsoft store

      Once WSL is enabled, you can easily install Ubuntu directly from the Microsoft Store:

      1. Open Microsoft Store: Search for "Microsoft Store" in the Start menu and open it.

      2. Search for Ubuntu: In the Store, search for "Ubuntu."

      3. Select the Version: Choose your preferred version of Ubuntu (e.g., Ubuntu 20.04 LTS) and click "Install."

      4. Launch Ubuntu: After installation, launch Ubuntu from the Start menu.

Step 3: Initial Setup of Ubuntu

  1. When you first launch Ubuntu, it will take a moment to set up.

  2. You'll be prompted to create a new user account and password. Follow the on-screen instructions.

Step 4: Update Ubuntu

To ensure you're running the latest packages and security updates, it’s essential to update your Ubuntu installation.

Update Ubuntu Packages:

  1. Open the Ubuntu terminal (if not already open).

Run the following commands to update the package list and upgrade any existing packages:

sudo apt update
sudo apt upgrade
  • The sudo apt update command fetches the list of available updates and their versions.

  • The sudo apt upgrade command installs the latest versions of all installed packages.

    1. Install Essential Tools: You might want to install some common tools, such as:
    sudo apt install build-essential git curl
  1. Set Up Your Development Environment: Depending on your needs, you can install programming languages (like Python, Node.js, etc.), databases, or any other software relevant to your projects.

  2. Accessing Files: You can access your Windows files from /mnt/c/, which is where your C: drive is mounted.

  3. Explore the File System: Familiarize yourself with the Linux file system and commands.

  4. Install Additional Software: Use apt to install any additional software you may need, such as:

    sudo apt install <package-name>
  1. Learn Commands: If you're new to Linux, consider learning basic terminal commands to navigate and manage your system.

  2. Consider Installing a GUI: If you need a graphical interface, you can install a desktop environment or use an X server on Windows.


Basic Linux Commands for Beginners

Now that your Ubuntu environment is ready, here are some essential commands to help you navigate and use Linux:

Navigating the File System

  • pwd – Displays the current directory you're in.

  • ls – Lists the files in the current directory.

  • cd [directory] – Changes the current directory.

Working with Files

  • touch [filename] – Creates a new, empty file.

  • cp [source] [destination] – Copies a file.

  • rm [filename] – Deletes a file.

To get started with beginner commands, follow my blog on : https://sanjoysblog.hashnode.dev/introduction-to-linux-command-line-20-commands-every-beginner-should-know


Why Use WSL for Ubuntu?

Running Ubuntu through WSL provides flexibility to use Linux's command-line tools on your Windows system. Here are some real-world applications:

  • Development Environment: Use Linux tools, web servers (Node.js, Python, PHP), and databases (MySQL, PostgreSQL).

  • Version Control: Manage your code with Git using a Linux-native Git CLI.

  • Scripting: Automate tasks using Linux shell scripts.

  • Containerization: Develop using Docker, which integrates well with WSL 2.


References and Further Reading


Call to Action

Now that you've set up Ubuntu on Windows via WSL, you're ready to explore the powerful world of Linux tools on a familiar platform. Whether you're a developer or someone eager to learn Linux, give it a try! Let me know how it works for you in the comments.

0
Subscribe to my newsletter

Read articles from Sanjoy Saha directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Sanjoy Saha
Sanjoy Saha

👋 I'm a B.Tech graduate in Computer Science and Engineering from Netaji Subhash Engineering College, Kolkata. 💻 During my studies, I gained a strong foundation in programming, data structures, and algorithms, along with advanced knowledge in Operating Systems, Database Management, and Computer Networks. 🤝 Outside the classroom, I participated in coding competitions and hackathons, which enhanced my problem-solving skills and fostered teamwork. 💪 Skills: Programming: C++, JavaScript Frontend Development: HTML5, CSS3, JavaScript, Bootstrap, React JS Developer Tools: VS Code, Git, GitHub, MySQL 🔍 I'm passionate about learning and excited to start my career in computer science, aiming to use my skills to create innovative solutions that make a positive difference. 💬 Reach out at: sanjoysaha0524@gmail.com Thank you!