The Windows Subsystem for Linux (WSL) allows you to run Linux environments and applications directly on Windows. With WSL, you can have the best of both worlds – the familiar Windows interface combined with the power of Linux.
Installing WSL on Windows 11 is easy and only takes a few steps. In this comprehensive guide, we’ll walk you through the entire process of setting up WSL step-by-step. We’ll also provide tips and tricks for optimizing WSL for the best performance.
Before installing WSL, you need to ensure your Windows 11 system meets the following requirements:
- You must be running Windows 11 version 22000.0 or higher. To check your version, go to Settings > System > About.
- Your Windows installation must be 64-bit. WSL is not supported on 32-bit versions of Windows.
- Virtual Machine Platform must be enabled. Open Turn Windows Features on or off and ensure ‘Virtual Machine Platform’ is checked.
- Hardware virtualization capabilities must be enabled in BIOS. Check with your system manufacturer for details.
- You must have admin privileges to install WSL. Standard user accounts cannot install WSL.
- Your system should have at least 4GB of RAM for optimal WSL performance. 8GB or more is recommended.
Once your system meets the requirements, you’re ready to install WSL!
Install the Linux Kernel Update Package
The first step is to install the latest Linux kernel update package from Microsoft. This provides the Linux kernel within Windows that will allow Linux distributions to run.
To install the update package:
- Open Settings and go to Windows Update.
- Click on Check for Updates. Install any available updates.
- Once updates are installed, search for “Linux kernel update package” and install it.
- Restart your system after the kernel update is installed.
The kernel update package is crucial for running WSL and Linux distros fast and smoothly on Windows 11.
Enable the Virtual Machine Platform (Optional)
The Virtual Machine Platform feature is required for WSL. It should be enabled automatically when installing the Linux kernel update, but you can verify by following these steps:
- Open Turn Windows features on or off.
- Check that ‘Virtual Machine Platform’ is enabled. If not, enable it.
- Click OK and restart if prompted.
With the Virtual Machine Platform enabled, your system is now ready for installing Linux distros using WSL.
Install Your Linux Distribution of Choice
Now comes the fun part – picking your preferred Linux distribution to install via the Microsoft Store! The main options include:
- Ubuntu – The most popular Linux distro overall. Ubuntu offers a great starting point for Linux beginners.
- Debian – Debian is the base for many other Linux distros, including Ubuntu. It’s stable and lightweight.
- Kali Linux – A distro focused on security, penetration testing, and ethical hacking.
- Fedora Remix – A version of Fedora optimized for WSL usage. It’s powerful but easy to use.
- Pengwin – A WSL-focused distro based on Debian that claims faster I/O speeds.
- Alpine WSL – Very compact distro good for smaller footprint deployments in WSL.
I recommend Ubuntu or Debian for beginners. But feel free to install multiple distros and test them out!
To install your chosen Linux distro:
- Open the Microsoft Store app on your Windows 11 system.
- Search for the name of the Linux distro you want to install.
- Select your distro from the search results and click Get to install it.
The Linux distro will download and install automatically, like any other app. Easy!
Set Up a Linux User Account
Once the Linux distro finishes installing from the Microsoft Store, you must create a user account within the Linux environment.
The first time you launch the distro, it will prompt you to create a new user account and password. This account is separate from your Windows user account.
Make sure to pick a memorable username and a strong password. This account will be used to log in and operate within the Linux environment.
The account you set up will be an administrator account within the Linux distro with sudo privileges.
Install a Linux Terminal Emulator
Now that you have WSL installed and configured, you need an interface to interact with it. The main options for accessing WSL include:
- Windows Terminal – Install from the Microsoft Store. The recommended terminal for WSL as it’s designed for it.
- Command Prompt – The traditional Windows command line tool. It works with WSL but has limited functionality.
- PowerShell – Includes some WSL integration but not as feature-rich as Windows Terminal.
I suggest installing the Windows Terminal from the Microsoft Store for the best experience. Once installed, you can launch it and access your Linux distros from the dropdown menu.
Windows Terminal provides useful features like multiple tabs, themes, customization, split panes, and more that optimize the WSL experience.
Initialize the Linux Environment
When you launch your Linux distro, it will need to initialize, which sets up your Linux filesystem and performs some first-time setup operations.
Initialization only happens on the first launch. Click the ‘Initialize now’ button when prompted to initialize your Linux environment.
The initialization performs the following:
- Set up your Linux user account and password
- Generates SSH keys for your Linux user
- Installs your default shell environment
- Populates the filesystem from your distro’s root image
- Sets up the environment based on your distro’s package manager
Be patient, as the initialization can take a couple of minutes. The time varies based on the distro’s root filesystem image size.
Once finished, you’ll be logged into your Linux environment in the terminal!
Explore Linux Basics
Now that you’re up and running with WSL, I recommend exploring Linux basics within your distro environment:
- Try common commands like
touchTo navigate directories and create files.
- Install packages using your distro’s package manager, like
- Change directories using full paths like
cd /usr/local/binor relative paths like
- Use text editors like
emacsto create and edit files.
lessfiles to output their contents to the terminal.
unsetenvironment variables and use
echo $VARto print values.
sudoto run commands with superuser privileges.
Take time to practice Linux CLI basics before moving on to more advanced WSL functionality.
Install Windows Terminal Themes and Settings
While the defaults are functional, I recommend customizing Windows Terminal to suit your preferences. Here are some quick ways to improve the aesthetics and usability:
- Themes – Open settings and change the default profile’s color scheme with many options available.
- Font – Change the font face and size like Consolas at 14pt for better readability.
- Acrylic Effect – Toggles background acrylic effect to make the terminal translucent.
- Tabs – Set your preferred tab-switching shortcuts like Ctrl+Shift+T.
- Scrollback – Increase scrollback lines to review more terminal output history.
Take time to play with various customizations – settings like padding, cursor shape, quake mode, and more. You can also create multiple profiles for different themes or Linux distros.
These customizations will help you be more productive within Windows Terminal.
In some cases, you may run into issues installing or running WSL. Here are solutions to common problems:
- Installation failures – Ensure Virtualization is enabled in BIOS. Some systems require you to enable Intel VT-x or AMD-V virtualization extensions.
- Permissions errors – Try reinstalling or resetting your Linux distro. Make sure to initialize as a non-root user after installation.
- Program not found – If commands like
gitreturn errors, and install them properly within your Linux distro. Do not try to invoke Linux programs from Windows.
- Network or internet access issues – Check that the Windows firewall is not blocking access to WSL. You can add an exception for WSL access if needed.
- High CPU or RAM usage – Close background Windows apps and processes to free up system resources for WSL VM. Upgrade RAM if needed.
- Slow disk performance – Use an SSD rather than an HDD. WSL relies heavily on fast disk speeds.
Hopefully, these tips will help troubleshoot any issues that arise with using WSL on Windows 11!
Tips for Improving WSL Performance
To get the best possible performance out of WSL, I recommend these tips:
- Place your Linux distro root file system directory on an SSD drive for faster read/write speeds.
- Use a lightweight window manager within your Linux distro like Xfce or LXDE rather than resource-heavy ones like Gnome or KDE.
- Disable GUI animations and visual effects in your Linux desktop environment.
- Don’t install bloated IDEs; stick to lightweight editors like Vim, Nano, or VS Code.
- Shut down background processes and services not being used in your Linux environment.
- Set CPU and memory limits on the WSL 2 VM via the wsl.conf file.
- Enable the ptrace setting and increase the vCPU count for the WSL 2 VM.
- Use Windows Terminal for interacting with WSL rather than GUI apps or other terminals.
- Run intensive Linux apps that don’t require GUI within WSL rather than using the Linux GUI desktop.
These tips will help you optimize Windows and WSL for maximum speed and performance.
Advanced Guide for Optimizing WSL
Beyond the basics, you can take several advanced steps to optimize and customize your WSL setup. Here’s an advanced guide on things you can tweak:
Utilize the .wslconfig file
The .wslconfig file gives granular control over WSL settings and parameters. With it you can configure:
- Custom Linux distro root directory path
- Initial distro to load on start
- Resources limits like memory and CPU
- ptrace settings for Docker compatibility
- Windows to Linux interop settings
See Microsoft’s documentation for details on the wide array of .wslconfig options.
Adjust Virtual Machine Configuration
You can modify settings for the underlying Hyper-V VM used by WSL 2 for improved performance:
- Increase number of vCPUs
- Raise memory allocation
- Enable nested virtualization
- Adjust swap file size on Linux drive
- Disable dynamic memory for static allocation
Use Hyper-V Manager or bcdedit command to tweak advanced VM parameters.
Move Pagefile and Swap to Fast Drive
Place the Windows pagefile and Linux swap file on fast SSD storage rather than the OS drive:
- Pagefile on Windows should be on fastest NVMe or SSD drive
- Linux swap should reside on WSL root filesystem (often a separate drive)
- Ensure swap size is 2x RAM for best performance
This provides maximum speed for memory paging and swapping.
Install a Custom Linux Kernel
The default Linux kernel used in WSL 2 can be replaced with a custom optimized kernel:
- Benefits include latest kernel features, security updates and optimizations
- Can enable additional functionality like systemd integration
- Distro maintainers offer special WSL kernels
Downside is losing automatic kernel updates from Microsoft.
Consider Third Party Tools
Utilities like WSL2 Docker Desktop Integration and WSL Reverse Integration simplify using Docker and running Windows apps in WSL.
Third-party tools can further enhance WSL usability, compatibility, and features.
By applying these advanced steps, you can truly maximize the utility and performance of the Windows Subsystem for Linux. WSL is an incredibly powerful tool when configured properly.
Graphical Program Options for WSL
Working directly in the Linux terminal is fine for many tasks. But sometimes, you’ll want to run GUI desktop apps or editors. Here are your options:
- X Server – Install an X server like XMing or VcXsrv on Windows. Sets up an X11 server to display Linux GUI apps.
- Desktop Environment – Install a Linux desktop environment like KDE, Gnome, or Xfce within WSL to get a full Linux GUI.
- Remote Desktop – Use XRDP or VNC to remotely connect to your WSL desktop GUI from Windows.
- Individual Apps – Some Linux GUI apps like GIMP can install Windows versions that integrate better than using X-Forwarding.
For native Linux GUI apps, an X server is easiest. For a full desktop environment, install it within WSL and use remote desktop. Individual apps it depends on your use case.
Test different methods to find which graphical program workflow is right for you.
Using the Linux Filesystem from Windows
Windows and Linux have separate but interconnected filesystems when using WSL. By default, Windows can access the Linux root filesystem under:
Likewise, Linux can access the Windows C drive and other drives mounted under:
This makes it easy to:
- Open Linux files in Windows apps
- Build Windows/Linux hybrid projects
- Share files across OSes
/usr/localrather than Program Files for cross-OS packages
- Store Linux config files under
/etc/rather than Windows
- Prefix Windows paths with
/mnt/cwhen accessing from Linux
The interop between Windows and Linux filesystems is a major WSL advantage.
WSL System Administration and Management
Managing Windows Subsystem for Linux involves many of the usual Linux admin tasks:
- User accounts – Manage users and groups using
usermod, etc. Set password policies.
- Software updates – Regularly update packages via
pacman, etc. Enable auto-updates for security.
- Resource monitoring – Check CPU, memory, disk usage with
duand other tools.
- Background services – Control which daemons and services run at startup with
- Log files – Monitor log files in
/var/log/and configure logging with
- Network and firewall – Configure network settings using
netplan. Adjust firewall with
- Remote access – Set up SSH keys for passwordless remote login. Consider two-factor authentication.
Apply standard Linux best practices for hardening, automation, and configuration management.
Development Environment Options
One of the most popular uses of WSL is setting up a Linux development environment on Windows. WSL works great for these languages and frameworks:
- Node.js – Install Node via nvm and leverage npm for modules. Develop/test apps locally before deploying.
- Python – Take advantage of Python on Linux for frameworks like Django and Flask.
- Ruby on Rails – Install Ruby Version Manager and Rails for full-stack development.
- Go – Use Go tooling like golangci-lint for building Windows/Linux Go programs.
- Rust – Compile Rust into native Windows executables right from WSL.
- PHP – Run LAMP or LEMP stack natively within WSL.
- Docker – Manage Docker containers seamlessly within WSL using Docker Desktop integration.
WSL unlocks the Linux ecosystem for developers on Windows. You get native-speed tooling and ecosystem for many languages/frameworks.
GUI Application Options
Earlier we covered accessing GUI apps from Windows using X Server or Remote Desktop. But you can also run GUI apps entirely within WSL using a Linux desktop environment.
Some options include:
A lightweight desktop environment. Install with:
sudo apt install xfce4
startxfce4 and access via remote desktop.
A fully featured desktop with customization options:
sudo apt install kde-plasma-desktop
Leaner version of Gnome that uses less resources:
sudo apt install gnome-flashback
Very lightweight Qt-based environment:
sudo apt install lxqt
I recommend Xfce or LXQt for getting started with GUI apps in WSL. Heavier desktops like Gnome and KDE may impact performance.
Sharing Network Resources Between Windows and WSL
Windows and WSL can share networking resources like:
- Proxy settings
This enables transparent communication between Windows and Linux apps running via WSL.
To enable resource sharing:
- Open Windows Settings
- Select Network & Internet -> Properties
- Under Remote Port Type, choose Allow connections from any version of Windows
Now Windows firewall rules will apply to WSL processes and apps.
You can also access Windows hostnames from Linux using
.exe suffix, like
And Windows can access Linux hostnames using
Configuration is automatic in most cases but these tips can resolve issues accessing networking resources across OSes.
Tips for Running Linux GUI Apps
Linux GUI apps can be run from within WSL using a couple different methods:
- X Server – Install XMing or VcXsrv on Windows to display Linux app GUIs. Set
- Remote Desktop – Install a Linux desktop environment in WSL and remote connect from Windows.
- Wayland – Experimental support for running Wayland apps natively under WSL
Here is the continuation of the article:
Some tips when running Linux GUI apps:
- With X Server, allow connections from “Any Address” in your X Server config to permit WSL access.
- For Remote Desktop, secure connections using SSH rather than VNC for security.
- Wayland support is still early but shows promise for better integrated Linux GUIs.
- Don’t expect GPU acceleration for Linux apps under WSL – the VM architecture doesn’t provide direct GPU access.
- You may need to tweak your Linux user’s .Xauthority file for display access when using X Server.
- For max performance, use GUI apps sparingly and only when necessary within WSL.
- Individual Linux apps like GIMP can run faster by installing Windows native versions.
With some configuration, you can get GUI apps working smoothly. But overall, sticking to CLI apps within WSL will provide the best experience.
WSL Filesystem Performance Tips
The WSL filesystem resides within a VHDX virtual disk giving Linux its own partitions and devices.
For best filesystem performance within WSL:
- Place the VHDX disk on fast SSD storage, preferably an NVMe drive.
- At install time, pick ext4 rather than ext3 for support for modern features.
- Keep the WSL VHDX disk lean and remove unneeded files/packages.
- Perform periodic maintenance like
fsckon Linux drives.
- Add a
/homepartition if storing lots of user files to avoid filling
- Benchmark read/write speeds with
hdparmto verify performance.
- Enable write caching on the VHDX with
Enable-WindowsOptionalFeature -FeatureName Microsoft-Windows-Subsystem-Linux -Online -NoRestart
- Compress rarely accessed WSL files using
gzipto optimize disk usage.
You can achieve excellent filesystem performance by following these steps. The key is running WSL on an SSD.
Supporting Systemd for Improved Compatibility
By default, WSL 2 uses a simplified init system rather than the full systemd. But you can enable full systemd support by:
- Installing a custom Linux kernel containing the systemd patches
- Configuring the
- Rebuilding systemd within your WSL distro if necessary
- Better application and distro compatibility
- Additional systemd services for logging, power management, etc.
- Consistent experience with real Linux environment
The main downside is added complexity and resources needed to run full systemd.
But for advanced users, upgrading to systemd can improve interoperability and compatibility when running complex apps within WSL.
Leveraging WSL 2’s VM Architecture
WSL 2 runs Linux distros within lightweight virtual machines based on Hyper-V.
This VM architecture provides advantages:
- Better isolation between host and guest compared to WSL 1
- Runs actual Linux kernel rather than emulating kernel calls
- Decoupled lifecycles between Windows host and Linux guest OSes
- Flexibility to operate WSL machines independently of host
- Ability to leverage hypervisor features like VM snapshots
You can interact with the underlying VM using commands like:
wsl.exe -l -v
wsl --list --verbose
And tools like Hyper-V Manager for advanced configuration not exposed within WSL itself.
For example, adjusting VM resources or sharing folders outside the normal \\wsl$ paths.
The VM model makes WSL 2 incredibly flexible and performant.
Integrating Windows and Linux Workflows
A key benefit of WSL is combining Windows and Linux tools into unified workflows:
- Filesystems exposed via \wsl$\ paths make sharing data seamless
- Editors like VSCode work on Windows/Linux projects interchangeably
- Hybrid languages like Typescript can compile across platforms
- Docker Desktop with WSL integration manages containers in Linux VM
- Windows Terminal provides tabbed access to traditional CMD/PS and Linux shells
- Visual Studio solutions can include .NET code executing in WSL
To integrate workflows:
- Configure Windows Terminal as the default terminal for WSL rather than distro defaults.
- Share source code across Windows/Linux filesystems rather than duplicating.
- Use cross-platform tools like Visual Studio Code as the IDE for unified dev experience.
- Don’t mix platform-specific tools like Windows grep and Linux grep – stick to one.
- Abstract filesystem paths in scripts using variables like $PROJECTS_DIR to allow portable code.
With some care, you can blend the best Windows and Linux worlds using WSL.
WSL 2 Tips and Tricks
Here are some additional tips for working with WSL 2:
- Shut down WSL 2 distros cleanly with
wsl --shutdownto avoid corruption.
- Access Windows drives from /mnt/ paths. Like
/mnt/cmaps to C: drive.
- Launch Windows apps from Linux with
- Import Linux shell scripts into Windows Powershell with
- Windows path translation with
- Distro management with
- Change default distro with
- Faster boot by removing swapfile after install with
sudo swapoff -a
- Install additional DEs like KDE Plasma without impacting main distro.
Take advantage of these tips to simplify working across environments with WSL 2.
This comprehensive guide covered the full process of installing and configuring WSL 2 on Windows 11. Here are some key takeaways:
- Enable required features like Virtual Machine Platform and install the Linux kernel update package.
- Choose a Linux distro from the Microsoft Store and set up your user account when initializing.
- For terminal access, use Windows Terminal for the best experience.
- Customize WSL and Windows Terminal to suit your workflow and productivity.
- Optimize performance through .wslconfig tweaks, resource allocation, and disk optimizations.
- Access Linux files from Windows and vice versa for unified dev workflows.
- Manage WSL through Windows admin center integration and Hyper-V Manager.
- Take advantage of WSL 2’s lightweight VM architecture for Linux flexibility on Windows.
With WSL, you truly get the best of Windows and Linux blended into one seamless experience. I hope this guide helps you maximize the capabilities of the Windows Subsystem for Linux!
- Install Windows Subsystem for Linux (WSL) on Windows 11. Microsoft. https://docs.microsoft.com/en-us/windows/wsl/install
- Windows Subsystem for Linux Guidance for WSL Users. Microsoft. https://docs.microsoft.com/en-us/windows/wsl/basic-commands
- Windows 10 tip: The best way to use WSL 2. Ed Bott. ZDNet. https://www.zdnet.com/article/windows-10-tip-the-best-way-to-use-wsl-2/
- The non-beginner’s guide to optimizing WSL2 for peak performance. Nick Janetakis. https://nickjanetakis.com/blog/the-non-beginner-guide-to-optimizing-wsl-2-for-peak-performance
- WSL 2 Best Practices. Samuel Karp. https://devblogs.microsoft.com/commandline/wsl-2-best-practices/
- How to Install and Use Linux GUI Apps on Windows Subsystem for Linux. Beebom. https://beebom.com/how-install-linux-gui-apps-windows-subsystem-linux/