The Windows Subsystem for Linux (WSL) is a powerful feature in Windows 10 and Windows 11 that allows you to run a Linux distribution directly on your Windows operating system. With WSL, you can access a Linux command-line environment and run Linux applications alongside your regular Windows programs. This guide will walk you through the steps to install WSL on your Windows 11 computer.
Prerequisites
Before you begin, make sure that your Windows 11 system meets the following requirements:
- Your Windows 11 version is build 22000 or later. You can check your build number by going to Settings > System > About.
- Your system supports virtualization and has virtualization enabled in the BIOS/UEFI settings. Most modern computers support this feature.
- You have enabled the “Virtual Machine Platform” optional component in Windows. You can do this by going to Settings > Apps > Optional features > More Windows features, and then selecting “Virtual Machine Platform” and clicking “Install.”
Step 1: Enable WSL in Windows 11
- Open the Start menu and search for “Turn Windows features on or off.”
- In the “Windows Features” window, scroll down and check the box next to “Windows Subsystem for Linux.”
- Click “OK” to apply the changes and restart your computer if prompted.
Step 2: Install Your Preferred Linux Distribution
After enabling WSL, you can install your preferred Linux distribution from the Microsoft Store. Here’s how:
- Open the Microsoft Store app.
- Search for the Linux distribution you want to install. Some popular options include Ubuntu, Debian, Kali Linux, and openSUSE.
- Select the distribution you want and click “Install.”
- After the installation is complete, launch the distribution by searching for it in the Start menu.
The following links will open the Microsoft store page for each distribution:
- Ubuntu 18.04 LTS
- Ubuntu 20.04 LTS
- Ubuntu 22.04 LTS
- openSUSE Leap 15.1
- SUSE Linux Enterprise Server 12 SP5
- SUSE Linux Enterprise Server 15 SP1
- Kali Linux
- Debian GNU/Linux
- Fedora Remix for WSL
- Pengwin
- Pengwin Enterprise
- Alpine WSL
- Raft(Free Trial)
- Alma Linux
Alternatively, you can install Linux distributions using the wsl --install
command in PowerShell or Command Prompt. This command will install the latest version of Ubuntu by default, but you can also specify a different distribution using the --distribution
flag.
Step 3: Set Up Your Linux Distribution
When you launch your Linux distribution for the first time, you’ll be prompted to create a new user account and password. Follow the on-screen instructions to complete the setup process.
Once you’re in the Linux environment, you can start using the command line and installing software just like you would on a regular Linux system.
Step 4: Configure WSL (Optional)
While WSL works well out of the box, you may want to customize some settings or enable additional features. Here are a few optional configuration steps you can take:
1. Enable GUI Applications
By default, WSL runs in a command-line environment, but you can install a graphical user interface (GUI) and run Linux desktop applications on your Windows 11 system. To do this, you’ll need to install an X server for Windows, such as VcXsrv or X410.
Starting up WSL
To start using WSL, open up a PowerShell terminal and type wsl
. If you’ve set up WSL correctly, you’ll enter a bash terminal running on the WSL distro of choice. From here, you can run any Linux commands you wish.
Below you will find a reference to all of the options the wsl.exe provides when starting up.
COMMAND | EXPLANATION | EXAMPLE |
---|---|---|
exec, -e | Will run command using without using default shell | wsl -e curl google.com |
— | Passes anything after this parameter to default shell. Leaving the operator out will also work. | wsl — curl google.com, wsl curl google.com |
distribution, -d | Opens a terminal in the specified distribution’s shell | wsl -d Ubuntu-18.04 |
user, -u | Runs WSL command as the specified user as long as user exists on that distro | wsl -d Ubuntu-18.04 -u tux_user |
export | Exports the specified distribution to a tar file on your local system. | wsl –export Ubuntu ./Test-Ubuntu.tar |
import [–version] | Imports a tar file as a new WSL distribution. Can specify WSL version with the –version option | wsl –import Test-Ubuntu C:\data\Test-Ubuntu .\Test-Ubuntu.tar |
list, -l [Options] | wsl –list | |
all | List all installed WSL distributions | wsl -l –all |
running | List only WSL distributions that are currently running | wsl -l –running |
quiet, -q | Only show WSL distribution names | wsl -l -q |
verbose, -v | Show detailed information about all WSL distributions | wsl -l -v |
set-default, -s | Sets the specified WSL distribution as the default distribution for WSL commands. | wsl -s Test-Ubuntu |
set-default-version | Changes the default WSL version for all new distributions installed to that system | wsl –set-default-version 2 |
set-version | Changes the WSL version of the specified distribution | wsl –set-version Test-Ubuntu 2 |
shutdown | Immediately terminates all running WSL distributions | wsl –shutdown |
terminate, -t | Terminates the specified WSL distribution | wsl -t Test-Ubuntu |
unregister | Unregisters the specified WSL distribution | wsl –unregister Test-Ubuntu |
help | Display information about using WSL | wsl –help |
Once you get comfortable using these switches, you’ll find that running and managing applications through WSL is much easier than managing Linux virtual machines on your own.
2. Manage WSL Instances
If you have multiple Linux distributions installed, you can manage them using the wsl
command in PowerShell or Command Prompt. Some useful commands include:
wsl --list --verbose
: List all installed Linux distributions and their details.wsl --set-default <DistributionName>
: Set the default Linux distribution to use when running thewsl
command.wsl --export <DistributionName> <FileName.tar>
: Export a Linux distribution to a.tar
file.wsl --import <DistributionName> <InstallLocation> <FileName.tar>
: Import a Linux distribution from a.tar
file.
3. Customize WSL Settings
You can customize various settings for WSL by editing the /etc/wsl.conf
file within your Linux distribution. Some common settings you can modify include:
kernel
: Set the Linux kernel version to use.systemRoot
: Set the location of the Windows system root directory.swapFile
: Configure a swap file for improved memory management.networkingMode
: Set the networking mode for your Linux distribution.
4. Access Windows Files from WSL
One of the great features of WSL is the ability to access your Windows file system from within the Linux environment. By default, your Windows drives are mounted under the /mnt/
directory in WSL. For example, your C:\
drive would be accessible at /mnt/c/
.
5. Install Windows Terminal (Optional)
If you prefer a more modern and customizable command-line experience, you can install the Windows Terminal app. It supports multiple tabs, panes, and profiles, making it easier to work with WSL and other command-line tools.
References
- Windows Subsystem for Linux Documentation
- Install Windows Subsystem for Linux
- Manage WSL Instances
- Configure WSL
- Access Windows Files from WSL
- Install Windows Terminal
Conclusion
The Windows Subsystem for Linux provides a powerful way to run Linux distributions directly on your Windows 11 system. By following the steps outlined in this guide, you can install and configure WSL to suit your needs, whether you’re a developer, system administrator, or just someone who wants to explore the world of Linux. With WSL, you can take advantage of the best of both worlds – the familiarity of Windows and the power of Linux.
Did you like this article? Do not hesitate to share it on social networks and subscribe to Tech To Geek on Google News to not miss any articles!"Because of the Google update, I, like many other blogs, lost a lot of traffic."
Join the Newsletter
Please, subscribe to get our latest content by email.