The WSL (Windows Subsystem for Linux) feature allows a user to install a Linux distro and execute Linux commands in Windows. WSL 2 is the current version of WSL which uses the latest and greatest virtualization technology. It has faster file system performance, is more compatible, and uses a real Linux kernel. In this article, I will show how to install Ubuntu in WSL2. Furthermore, follow this article if you want to know how to install Ubuntu in WSL 1. In addition, you can see this article to know how to install Ubuntu in WSL using GUI.
Key Takeaways
- Enabling the WSL feature in Windows.
- Making WSL 2 the default WSL version.
- Installing Ubuntu in WSL 2.
Requirements
- Windows Operating System.
- Command Prompt.
- Stable Internet Connection.
Process Flow Chart
[OS Used Throughout the Tutorial: Windows 11]
3 Steps to Install Ubuntu in WSL 2
This is the core part of this article where I will show how to install Ubuntu in WSL2 in three simple steps.
Step 01: Enable WSL in Windows
In the beginning, I will enable the WSL feature in my Windows by the following steps.
Steps to Follow >
➊ Search Command Prompt, left-click on the mouse and select “Run as administrator” to open it as administrator.❷ To enable WSL, insert the following command and hit ENTER:
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
- exe: Services Windows images, such as updating, adding or removing features.
- /online: Specifies that the command should be applied to the running operating system.
- /enable-feature: Enables a specific Windows feature.
- /featurename:Microsoft-Windows-Subsystem-Linux: Name of the feature being enabled.
- /all: Enables all the parent features of the specified feature.
- /norestart: Prevents the computer from automatically restarting after the feature is installed.
❸ Again, to enable Virtual Machine Platform, insert the following command and hit ENTER:
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
- exe: Services Windows images, such as updating, adding or removing features.
- /online: Specifies that the command should be applied to the running operating system.
- /enable-feature: Enables a specific Windows feature.
- /featurename:VirtualMachinePlatform: Name of the feature being enabled.
- /all: Enables all the parent features of the specified feature.
- /norestart: Prevents the computer from automatically restarting after the feature is installed.
❹ Then restart the computer.
Step 02: Make WSL 2 Default
Now I will make WSL 2 the default WSL version, which means Linux distros will be installed on WSL 2 by default.
Steps to Follow >
➊ To make WSL 2 default, write the following command in the Command Prompt:
wsl --set-default-version 2
- wsl: Manages WSL.
- –set-default-version: Sets default WSL version.
- 2: The WSL version number.
➋ Press ENTER from the keyboard.You should see an output like the above.
Step 03: Install Ubuntu in WSL 2
Finally, I will install Ubuntu in WSL. You can do the same by following the steps below:
Steps to Follow >
❶ At first, use the following command to list all the available Linux distros:
wsl --list --online
- wsl: Manages WSL.
- –list: Lists installed or available distros.
- –online: Lists only those distros which can be downloaded online.
❷ To install Ubuntu, copy the following command:
wsl --install Ubuntu-22.04
- wsl: Manages WSL.
- –install: Installs a new Linux distro.
- Ubuntu-22.04: Name of the distro which is being installed.
❸ Give a username for the Ubuntu.
❹ Finally, set a password.You should remember that this whole process can take some time. In the end, you should see an Ubuntu shell where you can execute Linux commands.
❺ (Optional) Now execute the following command to print installed Linux distros and their corresponding version:
wsl --list --verbose
OR,
wsl -l -v
- wsl: Manages WSL.
- -l,–list: LIsts distros that are currently installed.
- -v,–verbose: Shows additional information.
❻ Now you should find Ubuntu in your Windows like below.
Conclusion
In this article, I have shown how to install Ubuntu in WSL2 in three steps. However, remember, step 2 might not be necessary as WSL 2 is the default WSL version in Windows mostly. Finally, I hope this article was helpful to you.
People Also Ask
What is the best Linux desktop for WSL2?
Does WSL2 use a lot of RAM?
Can WSL2 use GPU?
Can I run VirtualBox in WSL2?
Related Articles