Step by Step Guide: Easily Try Linux on Windows With WSL 2

User Author

Achilles.H

March 15, 2024

Step by Step Guide: Easily Try Linux on Windows With WSL 2

I want to use Linux on Windows. Is there another way to achieve this without using virtualization software or setting up dual boot? Windows Subsystem for Linux 2(WSL 2), provided by Windows, can facilitate it. You can get more information in a detailed guide to easily try Linux on Windows with WSL 2.

Requirements

Requirements for using WSL 2:

Your Windows Version must be Windows 10, Version 1903, Build 18362 or later.

Requirements for running Linux GUI Applications:

The Windows 10 Build 19044+ or Windows 11 will be needed to use this feature.

Tips: You can check your Windows system information by running winver command in the Run dialog box.

Install WSL and a Specific Linux Distribution

The first thing we should do is to install WSL 2 and a specific Linux distribution on our computer. You can follow the steps below to achieve this.

Step 1: Open Command Prompt as administrator.

Step 2: Type wsl --install command and hit Enter to install WSL and enable virtual machine platform.

Step 3: Use wsl --list --online to check the available Linux distribution.

Step 4: Input wsl --install -d distro to install specific Linux distribution.

Note: Replace distro with the specific Linux distribution name.

WSL install specific Linux distribution

Step 5: Restart your computer to apply these changes after the process is complete.

Step 6: The Linux terminal will pop-up automatically after your computer restart.

Step 7: Set username and password for your Linux distribution following the prompt.

Tip 1: After you type your username and press Enter, there will be a delay before it completes. You need to wait patiently, but don't worry, it will only take a few seconds.

Tip 2: When you type the password, you may notice that there is no change in the interface, which is known as blind typing. This is normal, just enter your password as usual.

set name and password

Step 8: The WSL and Linux distribution has been installed on your computer now. Next we will display how to install GUI apps on Linux in detail.

Tips: You will find its icon appearing in the "Recently added" section of the Start menu. Alternatively, you can open it by typing the name of the Linux distribution in the Command Prompt.

Note: If you have installed WSL before, you can use wsl --update to update it.

WSL update

Use Linux Applications on Windows With WSL

The environment has been set up, and we can now proceed to install some applications on it. If you didn't install the display card driver before, you will need to install the corresponding vGPU driver program. You can find the appropriate driver in the Drivers for vGPU.

I will take Ubuntu as an example next.

Step 1: Use sudo apt update to update your apt(Advanced Packaging Tool) cache.

sudo apt update

Step 2: Install some commonly used softwares.

2.1: Install text editor through sudo apt install gnome-text-editor or sudo apt install gedit.

Tips: If you are asked "Do you want to continue? [Y/n]", type "y" to confirm.

2.2: Install file manager by sudo apt install nautilus -y

2.3: Install Google Chrome through .deb file.

a. Change into the temporary directory through cd /tmp/ command.

Note: Files in the tmp folder will be deleted after the system reboots.

b. Download the installation package through wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb command.

c. Install it on Linux by sudo apt install --fix-missing ./google-chrome-stable_current_amd64.deb command.

Step 3: Ways to launch applications.

3.1: Use the app name to launch it.

For example, running sudo nautilus will open the file manager. Make sure to use sudo or dbus-launch to prevent the application from failing to open.

3.2: Click the appeared icon to open it.

After you install the application, its icon will be displayed in the "Recently added" section of the "Start" menu.

3.3: Open multiple applications at once.

Use "&" to connect multiple commands, such as sudo gnome-text-editor & sudo nautilus.

Tips: If you want to continue with other commands, you can add "&" at the end of each command. This allows the programs to run in the background, enabling you to input other commands sequentially.

Note: You can learn more Linux command line in the Linux command line for beginners. If you're interested in learning about other Linux distributions, you can visit their official websites to study them.

Conclusion

After seeing the above demonstration, I believe you have noticed that compared to using a virtual machine or setting up dual boot, trying Linux with WSL is easier and more lightweight. Now, why not give it a try yourself?

Notice

1. Files are by default stored in the system drive. If you want to change its location, you can refer to how to install Windows Subsystem for Linux on a non-C drive.

2. Although WSL supports some Linux GUI applications, it does not currently support the graphical desktop.

3. If you have more than one Linux distribution installed, you can change which Linux distribution is turned on by default.

a. Use wslconfig /l to see all the installed Linux distributions.

b. Use wslconfig /setdefault name to set default Linux distribution. Replace name with your desired distribution name.

c. The distribution you specified will be open when you run wsl command later.