Windows Subsystem Linux Setup Guide for Beginners
In this article
If you're looking to run Linux natively within Windows, the Windows Subsystem for Linux (WSL) offers a seamless way to do so. Whether you're a developer, sysadmin, or hobbyist, setting up WSL allows you to access Linux tools, scripts, and environments directly on your Windows machine without the need for dual-booting or virtual machines. This guide will walk you through the process step-by-step, ensuring you get your Linux environment up and running efficiently. Before starting, ensure your Windows version is compatible (Windows 10 version 1903 or later, or Windows 11) and that you have administrator privileges on your PC.
What You'll Need
- A Windows 10 (version 1903 or later) or Windows 11 PC
- Administrative access to your Windows account
- Internet connection for downloading updates and Linux distributions
- Optional: Windows Terminal for an improved command-line experience
Step-by-Step
- Check Your Windows Version – Ensure your system meets the minimum requirements. Press Win + R, type
winver, and hit Enter. If your version is earlier than 1903, update Windows via Settings > Update & Security > Windows Update. - Enable the Windows Subsystem for Linux – Open PowerShell as Administrator. You can do this by right-clicking the Start button and choosing Windows PowerShell (Admin). In the PowerShell window, enter:
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
Press Enter and wait for the command to execute. - Enable the Virtual Machine Platform (for WSL 2) – Still in PowerShell, run:
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
This step is necessary if you want to upgrade to WSL 2, which offers better performance and full Linux kernel support. - Restart Your Computer – After enabling the features, reboot your PC to apply changes.
- Download and Install WSL 2 Kernel Update – Visit the official Microsoft page and download the latest WSL 2 Linux kernel update package. Run the installer and follow prompts. This step is crucial for WSL 2 functionality.
- Set WSL 2 as Your Default Version – Open PowerShell again and run:
wsl --set-default-version 2This ensures new Linux distributions will use WSL 2 by default. - Install a Linux Distribution – Open the Microsoft Store, search for your preferred Linux distribution (e.g., Ubuntu, Debian, Kali Linux), and click Get or Install. Alternatively, in PowerShell, you can run:
wsl --install -d Ubuntufor an automated installation (Windows 11 supports this command directly). - Launch Your Linux Environment – Once installed, click the Start menu, find your Linux distribution, and click to launch. The first time, it will take a few minutes to set up. You will be prompted to create a username and password for your Linux environment.
- Configure Your WSL Environment (Optional) – Customize your Linux setup by installing necessary packages, setting up SSH keys, or configuring your preferred shell (like Zsh or Fish). Use standard Linux commands such as
apt updateandapt install.
Common Mistakes
- Not enabling both the WSL and Virtual Machine Platform features before installation.
- Skipping the WSL 2 kernel update, which can cause errors or limited functionality.
- Installing an incompatible Windows version or outdated system.
- Using an older Linux distribution that does not support WSL 2 features properly.
- Failing to restart the system after enabling features, which prevents proper setup.
Tips
- Use Windows Terminal for a better command-line interface that supports multiple tabs and profiles.
- Set up shared drives by accessing
/mnt/cfor your Windows C: drive within Linux. - Update your Linux distribution regularly with
sudo apt update && sudo apt upgrade. - Use
wsl --list --verboseto check the status and version of installed distributions. - For advanced users, consider customizing your Linux environment with dotfiles, aliases, and scripts.
Troubleshooting
If WSL does not install or run correctly, try the following steps:
- Ensure your Windows is fully updated. Check Settings > Update & Security > Windows Update.
- Verify that the required features are enabled by running
dism.exe /online /get-featuresin PowerShell. - Reinstall the Linux distribution from the Microsoft Store or via command line.
- If you encounter kernel errors, rerun the WSL 2 kernel update installer.
- Use the command
wsl --shutdownto reset all running distributions, then restart WSL withwsl. - Check for hardware virtualization support in your BIOS/UEFI settings. Enable Intel VT-x or AMD-V if disabled.
Frequently Asked Questions
- Can I run graphical Linux applications with WSL?
- Yes, with WSLg (Windows Subsystem for Linux GUI), supported in Windows 11, you can run Linux GUI apps seamlessly.
- Is WSL 2 faster than WSL 1?
- Generally, yes. WSL 2 offers better performance, full Linux kernel support, and improved compatibility.
- Do I need to disable Windows Defender or antivirus software?
- Usually not. However, some security tools may interfere; if you encounter issues, temporarily disable them during setup.
- Can I upgrade an existing WSL 1 installation to WSL 2?
- Yes. Use the command
wsl --set-version <distribution> 2to upgrade individual distributions. - How do I uninstall a Linux distribution?
- Open Settings > Apps > Apps & Features, select the distribution, and click Uninstall. Or use PowerShell commands.
- Is WSL available on Windows 10 Home?
- Yes, WSL is available on Windows 10 Home, but WSL 2 requires Windows 10 version 2004 or later and the Virtual Machine Platform feature.