Do you know that you can set up an Ubuntu environment within your Windows machine without having to set up a dual boot option?
WSL 2 is the latest version of the Windows Subsystem for Linux architecture which is the foundation for the Windows Subsystem for Linux to run ELF64 Linux binaries on Windows. Its primary goals are to enhance the file system’s performance and ensure complete compatibility between cross-OS system calls.
The new architecture changes how these Linux binaries work with Windows and your PC’s hardware. However, it still provides an identical user interface, so you can easily use WSL 2 without a steep learning curve.
In this article, we see how we can use WSL2 to create an Ubuntu terminal environment using your Windows machine in minutes and create applications that run on multiple platforms without leaving Windows.
Table Of Content
- Use WSL2 to Set Up An Ubuntu Environment
The process of using WSL2 for the Ubuntu environment requires a personal computer with Windows 10 or a virtual machine running a version of Windows 10 OS.
Use WSL2 to Set Up An Ubuntu Environment
Now that you’ve fulfilled the requirements, let’s dive into the details of the process.
Step # 1: Install WSL2
The first thing you must do is enable specific Windows services to ensure you can run the WSL. These services are included with Windows but are disabled by default until you require them.
For this, launch PowerShell or command prompt (CMD) from the Windows Start menu. You’ll have to right-click to open PowerShell and click Run as Administrator.
Now, in the PowerShell window, run the following command to install WSL, and then reboot the system.
> wsl --install
This command will activate the necessary features to run WSL and set up the standard Ubuntu distro (accessible through the Microsoft Store).
We strongly recommend restarting your system after the initial installation to finish the installation.
Installation of WSL Through the Microsoft Store
Users can download the WSL application directly from the Microsoft Store like other applications.
To download the WSL application, go to the Microsoft Store and search for the Windows Subsystem.
Click Windows Subsystems on Linux to go to the application’s page.
Now, find the Get button to download, and then install WSL.
Step # 2: Install Ubuntu on WSL2
Now that WSL2 has been installed and ready, proceed to the next step, where you will carry out several tasks to install Ubuntu on WSL2.
1. Download Ubuntu From Windows Store
WSL is compatible with various Linux distros, including the latest Ubuntu versions, Ubuntu 20.04 LTS and Ubuntu 18.04 LTS.
You can locate the exact distro through the Microsoft Store app. In this instance, search for Ubuntu.
In the search result, you can find the following three Ubuntu releases:
Ubuntu with a version number: The old Ubuntu versions have numbers in the pattern: Ubuntu 20.04.x.
Ubuntu with no version number: This is Ubuntu’s most current LTS version. At the moment, the latest version is Ubuntu 22.04.x
Ubuntu Preview: It is a daily build of the most current version of Ubuntu. In most cases, developers use this version to test the compatibility of their products with Ubuntu. It is important to note that this version is NOT suitable for production environments.
After installation, you can start the application from the store or look up Ubuntu on the Windows Google search box.
2. Install Ubuntu From the Command Prompt
If you wish, you can install Ubuntu versions available at the Windows Store directly from the command line as well
For this, launch the Powershell terminal, and run the following command:
> wsl --list –online
This will display a list of available Linux distros. You can install any distro easily using the NAME.
For the purpose of this tutorial, run the following command:
> wsl --install -d Ubuntu-20.04
After the command finishes, use the command wsl -l -v to check the currently installed WSL distros:
Congratulations! You now have Ubuntu installed on the Windows machine!
Step # 3: Configure Ubuntu
After it has completed the initial configuration, you will be required to create your username and password for Ubuntu. (It is not necessary to use your Windows username and password).
We recommend you update your Ubuntu installation to the most recent updates with the following command. Remember to enter your Ubuntu password when you are asked.
$ sudo apt update
WSL2 offers a robust and reliable method of running Linux apps in Windows 10. For instance, you can install and run Ubuntu by installing it through WSL2. It provides complete integration to the Windows network, file system, and other features. You can use it to access a wide range of Linux utilities and tools from PowerShell or the Windows commands prompt or PowerShell.
Updates for Ubuntu on WSL2 can be installed with the same commands as on a standard Ubuntu system. In the end, WSL2 and Ubuntu on WSL2 offer a fantastic alternative for developers looking to use Linux apps on a Windows 10 machine without using a dual-boot or virtual machine.
Q What are the advantages of WSL2?
Answer: WSL2 is a lightweight, quick, efficient, and fast method of running Linux apps within Windows 10. It lets you use the full potential of Linux tools and utilities via PowerShell or the Windows commands prompt. WSL2 offers seamless integration with the Windows file system, network, and other functions.
Q: Can I connect to the Windows file system via Ubuntu WSL2?
A: You can connect to the Windows file system through Ubuntu with WSL2 by going to the “/mnt” directory inside Ubuntu’s terminal. The “/mnt” directory is home to all mounted Windows drives you can access and modify like every other Linux file system.
Q Can I run graphic applications using WSL2?
A: Yes, you can run graphical programs using WSL2 using the X server in Windows and configuring it to permit connections via WSL2. A popular X server that works with Windows can be Xming.
Q Can I use WSL2 to develop website pages?
A: You can use WSL2 to develop websites using web development frameworks and tools installed on Ubuntu. WSL2 gives you the Linux system ideal for web development and provides access to the most popular programming languages, databases, web servers, and other tools.