Bilal Shafiq
@mrbilalshafiq

Follow

@mrbilalshafiq

Follow

Linux on Windows Made Easy

A Step-by-Step Guide to Running Linux Applications on Windows 10 with WSL2

Bilal Shafiq's photo
Bilal Shafiq
·Dec 27, 2022·

4 min read

Linux on Windows Made Easy

Table of contents

  • Step 1: Enable WSL on your Windows 10 machine
  • Step 2: Install WSL2
  • Step 3: Install a Linux distribution
  • Step 4: Launch the Linux distribution and set up a user account
  • Step 5: Start using the Linux distribution
  • Conclusion

Welcome to this tutorial on downloading and installing Windows Subsystem for Linux 2 (WSL2) on Windows!

WSL2 is a Windows feature that enables you to run Linux natively on your Windows 10 machine. It allows you to run Linux applications directly on your Windows system, without the need for a virtual machine or dual-booting.

In this tutorial, we will walk you through the steps to download and install WSL2 on your Windows 10 machine. We will also show you how to set up a Linux distribution and start using it to run Linux commands and download Linux packages.

Let's get started!

Step 1: Enable WSL on your Windows 10 machine

Before you can install WSL2, you need to make sure that the WSL feature is enabled on your Windows 10 machine. Here's how to do it:

  1. Press the Windows key + R to open the Run dialog box.

  2. Type "powershell" into the Run dialog box and press Enter. This will open the PowerShell command prompt.

  3. Type the following command into the PowerShell prompt and press Enter:

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

This command will enable the WSL feature on your Windows 10 machine.

Step 2: Install WSL2

Now that the WSL feature is enabled, you can proceed to install WSL2 on your Windows 10 machine. Here's how to do it:

  1. Press the Windows key + R to open the Run dialog box.

  2. Type "powershell" into the Run dialog box and press Enter. This will open the PowerShell command prompt.

  3. Type the following command into the PowerShell prompt and press Enter:

wsl --set-default-version 2

This command will set WSL2 as the default version for WSL on your machine.

Step 3: Install a Linux distribution

Now that WSL2 is installed on your machine, you can proceed to install a Linux distribution. WSL2 supports several Linux distributions, including Ubuntu, Debian, and Fedora.

To install a Linux distribution, follow these steps:

  1. Open the Microsoft Store on your Windows 10 machine.

  2. Search for the Linux distribution that you want to install (e.g., "Ubuntu").

  3. Click on the Linux distribution that you want to install and click "Get".

  4. Wait for the Linux distribution to download and install. This may take a few minutes.

Step 4: Launch the Linux distribution and set up a user account

Once the Linux distribution is installed, you can launch it and set up a user account. To do this, follow these steps:

  1. Press the Windows key + R to open the Run dialog box.

  2. Type the name of the Linux distribution that you installed (e.g., "Ubuntu") into the Run dialog box and press Enter. This will launch the Linux distribution.

  3. Follow the prompts to set up a user account and password for the Linux distribution.

Step 5: Start using the Linux distribution

Once you have set up a user account for the Linux distribution, you can start using it to run Linux commands and download Linux packages. To do this, follow these steps:

  1. Press the Windows key + R to open the Run dialog box. 2. Type the name of the Linux distribution that you installed (e.g., "Ubuntu") into the Run dialog box and press Enter. This will open a terminal window for the Linux distribution.

  2. From the terminal window, you can enter Linux commands to perform various tasks, such as navigating the file system, managing files and directories, and installing Linux packages.

To install a Linux package, you can use the apt-get command. As an example, for installing the nano text editor, you can type the following command into the terminal:

sudo apt-get install nano

This will download and install the nano text editor on your Linux distribution.

You can also use the apt-get command to update the package list and upgrade the installed packages on your system. To do this, type the following commands into the terminal:

sudo apt-get update
sudo apt-get upgrade

These commands will update the package list and upgrade all the installed packages to the latest versions.

Conclusion

In this tutorial, we have shown you how to download and install WSL2 on your Windows 10 machine, and how to set up a Linux distribution and start using it to run Linux commands and download Linux packages. WSL2 is a powerful tool that allows you to run Linux natively on your Windows machine, and it can be a valuable addition to your toolkit as a DevOps engineer.


Follow me on twitter at @mrbilalshafiq

Did you find this article valuable?

Support Bilal Shafiq by becoming a sponsor. Any amount is appreciated!

See recent sponsors Learn more about Hashnode Sponsors
 
Share this