Trying Out Linux When You Are on a Windows Machine
Have you ever wanted to try Linux but felt intimidated by the idea of replacing your Windows installation? Thanks to the Windows Subsystem for Linux (WSL), you can run Linux alongside Windows without the need for dual-booting or using a virtual machine. This blog post will guide you through setting up WSL on Windows 10 and 11, explain the differences between WSL and a full Linux installation, show you how to obtain different Linux distributions, and even how to run graphical applications from WSL.
Installing WSL on Windows 10 and 11
Installing WSL is straightforward. Here are the steps for both Windows 10 and 11:
Windows 10
1. Open PowerShell as Administrator.
2. Run the following command to enable WSL:
sudo dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
3. Enable the Virtual Machine Platform feature:
sudo dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
4. Restart your computer.
5. Install the WSL kernel update package from the Microsoft website.
6. Set WSL 2 as the default version:
sudo wsl --set-default-version 2
Windows 11
1. Open PowerShell as Administrator.
2. Run the following command to install WSL and set WSL 2 as the default version:
sudo wsl --install
3. Restart your computer if prompted.
That’s it! Windows 11 makes the process even simpler with a single command.
Differences Between WSL and Full Linux Distributions
While WSL brings a full Linux kernel to Windows, there are some differences compared to running a full Linux installation:
1. **Hardware Access**: WSL has limited access to hardware resources compared to a native Linux installation. For example, direct access to USB devices is not straightforward.
2. **Performance**: While WSL 2 provides near-native performance, certain workloads may still perform better on a native Linux system due to the overhead of running on top of Windows.
3. **Graphical Applications**: Running graphical applications on WSL requires additional configuration, whereas they run natively on a full Linux installation.
4. **System Services**: Some system services and daemons may not run correctly on WSL, limiting certain advanced use cases.
Obtaining Different Linux Distributions
One of the great features of WSL is the ability to choose from a variety of Linux distributions. To install a different distribution:
1. Open the Microsoft Store.
2. Search for “Linux” to see a list of available distributions, including Debian, Ubuntu, and others.
3. Select the distribution you want to install and click “Get” to download and install it.
4. After installation, open the distribution from the Start menu and complete the initial setup.
Running Graphical Applications from WSL
Running graphical applications on WSL requires a bit of extra setup. Here’s how you can do it:
1. Install an X server on your Windows machine. A popular choice is VcXsrv.
2. Configure WSL to use the X server. Open your WSL terminal and add the following lines to your .bashrc
or .profile
file:
export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2}'):0
export LIBGL_ALWAYS_INDIRECT=1
3. Restart your WSL terminal or source the modified file:
source ~/.bashrc
4. Install a graphical application in your WSL environment. For example, to install and run Firefox:
sudo apt update
sudo apt install firefox
firefox
You should see Firefox launch on your Windows desktop. This setup allows you to run various graphical applications directly from WSL.
Conclusion
WSL is a fantastic tool for anyone wanting to try Linux without leaving the comfort of their Windows environment. It provides a seamless way to run Linux distributions, manage applications, and even run graphical applications. Whether you’re a developer, sysadmin, or just curious about Linux, WSL offers a convenient and powerful solution to explore the Linux ecosystem.