Linux

Unleash Ubuntu in Windows: WSL 2 Simplified

Windows Subsystem for Linux 2 (WSL 2) is a feature of Windows 10 that allows you to run Linux distributions directly on Windows without the need for a virtual machine. This makes it a great option for developers who need to work with Linux tools and applications, as well as for anyone who wants to try out Linux without having to switch to a different operating system.

Prerequisites

Before you can install WSL 2, you need to make sure that your system meets the following prerequisites:

  • WSL : Requires Windows 10 64-bit build 1607 or later
    WSL 2 : Requires Windows 10 64-bit build version 1903 or later
  • Virtualization support enabled in BIOS (usually found in the security settings)
  • At least 4 GB of RAM
  • 64 GB of available storage space
  • Administrator privileges on your Windows machine.

WSL 2 Installation

To install WSL 2, follow these steps:

  1. Open the Start menu and search for Turn Windows features on or off.
  2. In the Turn Windows features on or off window, scroll down and check the box next to Windows Subsystem for Linux.
  3. Click OK.
  4. Restart your computer.
wsl enable

Once you have restarted your computer, you can install an Ubuntu distribution from the Microsoft Store. Here are the steps:

  1. Open the Microsoft Store.
  2. Search for Ubuntu.
  3. Click the Get button next to the Ubuntu distribution that you want to install.
  4. Follow the on-screen instructions to complete the installation.

Enabling Virtualization through Windows Features:

In some cases, you can enable virtualization directly from Windows:

  • Open the Start menu and search for Turn Windows features on or off.
  • In the Turn Windows features on or off window, scroll down and check the box next to Virtual Machine Platform
  • Click OK.
  • Restart your computer.
Virtualization enable

Setting up Ubuntu in WSL 2

Once you have installed Ubuntu, you will need to set it up before you can use it. Here are the steps:

  1. Once Ubuntu is installed, you can launch it from the Start menu. Click on the Start menu and then search for Ubuntu. Click on the Ubuntu app to launch it..
  2. The first time you launch Ubuntu, you will be prompted to create a new user account. Enter a username and password for your new account.
  3. Once you have logged in to Ubuntu, you should update it to the latest version. To do this, open a terminal window and type the following command:
    sudo apt update && sudo apt upgrade

Useful Commands for WSL 2

  1. wsl --set-default-version <Version> : To set all new distributions to use WSL 2.
  2. wsl --set-version <distributionName> <version> : Setting the version for a specific distribution.
  3. wsl --list : View installed Linux distributions and their statuses (running/stopped).
  4. wsl --status <distributionName> : Check the status of a specific distribution.
  5. wsl --update : Update all installed Linux distributions.
  6. wsl --unregister <distributionName> : Unregister a distribution before deleting it.
  7. wsl --terminate <distributionName> : Force-terminate a running distribution.

Note : To Run Commands Open PowerShell or Command Prompt with administrator privileges. From above commands replacing <distributionName> with the name of your Linux distribution and <version> with either 1 or 2 for your desired version.

Additional Tips

  • You can install other Linux distributions from the Microsoft Store, such as Fedora and Debian.
  • You can use the wsl command-line tool to manage your WSL distributions.
  • To see a list of WSL commands, enter wsl --help in PowerShell.
  • You can find more information about WSL at the Microsoft website https://learn.microsoft.com/en-us/windows/wsl/

Conclusion

WSL 2 is a great way to run Linux applications and tools on Windows. It is easy to install and use, and it is a powerful and versatile tool. If you are looking for a way to use Linux on your Windows computer, I highly recommend WSL 2.

I hope this blog post has been helpful. If you have any questions, please feel free to leave a comment below.

Leave a Reply

Your email address will not be published. Required fields are marked *