Written by
Yuri ZhangSummary: This post presents the extensive purposes and guidance of Windows Subsystem for Linux, helping choose the agreeable version of the WSL. Its GUI capabilities are attached, too.
Windows Subsystem for Linux (WSL) is a full Linux environment that runs on Windows, we need to use PowerShell commands to install, manage, and configure throughout this post.
Note: WSL is also a powerful tool that allows Windows users to run a Linux environment natively on our machine without needing a separate virtual machine or dual-boot setup.
Now let's explore what WSL is, how to enable, use, and uninstall it, its GUI capabilities, and how to choose the best WSL version.
What is WSL and how does it work?
WSL is not a Linux emulator, instead, it provides a compatibility layer that allows Linux binaries to run directly on Windows. WSL 2, the latest iteration, uses a lightweight virtual machine (VM) to provide full Linux kernel compatibility and improved performance over WSL 1.
Uses and benefits of WSL
WSL is useful for developers, system administrators, and researchers who need Linux tools and environments while working on a Windows machine. It enables:
- Running Linux command-line tools such as Bash, Git, and Python.
- Developing and testing cross-platform applications.
- Using Linux-based utilities and scripts seamlessly within Windows.
Choosing the best WSL version
WSL 2 has seen several updates, including versions 2.3.26 and 2.4.11. The latest version, 2.4.11, includes enhancements such as improved enterprise security and better compatibility with Linux distributions.
To check your current WSL version:
- Press Windows + S, type "PowerShell," and click Windows PowerShell.
- Copy the following cmdlet and press Enter.wsl --version
To update to the latest version, run the cmdlet:
wsl --update
Share this information and gain a superior experience using WSL.
How to enable Windows Subsystem for Linux
Enabling WSL is straightforward:
1. Open PowerShell as Administrator and run:wsl --install
This command installs the latest version of WSL, along with a default Linux distribution (Ubuntu). You can also install WSL from the Microsoft Store on Windows 10 (Build 19044+) and Windows 11.
2. If you already have WSL installed but need to enable WSL 2, run:wsl --set-default-version 2
3. Restart your computer to complete the installation.
How to use Windows Subsystem for Linux
Once WSL is installed, you can start using it with the following steps:
- To launch a Linux distribution, open PowerShell and type:wsl
- Alternatively, you can launch a specific distro:wsl -d <DistroName>
- Use standard Linux commands like ls, cd, pwd, mkdir, nano, etc.
- To access Windows Files from Linux, run the commands:cd /mnt/c/Users/<YourUsername>/Documents
- To run Windows applications from within WSL, run (use the full path of the .exe file):/mnt/c/Program\ Files/Google/Chrome/Application/chrome.exe
- To install and use Linux software (for Ubuntu/Debian-based distributions), copy this and press Enter:sudo apt update && sudo apt install -y htop
htop
How to uninstall Windows Subsystem for Linux
To remove WSL from your system, follow these steps:
- Run wsl --list --verbose in PowerShell to see installed distros.
- Remove a distro using wsl --unregister <DistroName> in PowerShell.
- Run these commands in PowerShell:dism.exe /online /disable-feature /featurename:Microsoft-Windows-Subsystem-Linux /norestart
dism.exe /online /disable-feature /featurename:VirtualMachinePlatform /norestart - Restart your PC.
- (Optional) To delete leftover files, remove WSL files from the file path: C:\Users <YourUsername>\AppData\Local\Packages\CanonicalGroupLimited*
WSL GUI (WSLg) – Running Linux GUI applications
WSL 2 introduces WSLg, which enables running Linux GUI applications on Windows without needing third-party X servers.
How to run GUI applications:
- Ensure you have the latest WSL version, run the following command:wsl --update
wsl --shutdown - Install a GUI application in your Linux distribution (This will open the Gedit text editor with a native Linux GUI):sudo apt update && sudo apt install -y gedit
gedit
Other GUI applications like Firefox, GIMP, and VS Code can be installed similarly.
Final thought
Windows Subsystem for Linux is a game-changer for developers and Linux enthusiasts who work within Windows. With its latest updates, WSL 2 provides a near-native Linux experience, including full GUI support. WSL offers flexibility and power without the need for traditional virtualization methods.
People can make errors from time to time, since we may not be familiar with this program enough, if we lose important data while using it for the first time, utilize iBoysoft Data Recovery to fix logic errors and recover precious data in Windows.
Related articles
Key Points of Virtualization-Based Security (VBS) in Windows
Windows Defender Application Guard
Features, Uses of Microsoft Power Automate
What is Task Scheduler in Windows?
Spread this post to help those who have no idea of WSL.