If you are a developer working on Windows but need to use Linux tools, the WSL (Windows Subsystem for Linux) is the easiest way to run Linux applications directly on your operating system without needing virtual machines or dual booting.
In this guide, I will show you how to install WSL from PowerShell, step by step, so you can take advantage of the best of both operating systems. Additionally, I’ll provide a video tutorial at the end if you prefer to follow along visually.
What is WSL?
WSL is a compatibility layer that allows Linux binaries to run natively on Windows 10 and Windows 11. With WSL, you can use Linux tools without leaving your Windows environment. The recommended version is WSL 2, as it uses a real Linux kernel, improving performance compared to WSL 1.
What Can You Do with WSL?
WSL allows you to run a wide range of Linux applications on Windows, from command-line tools like Git, Node.js, and Python to development applications like Docker, Ansible, and Kubernetes.
WSL Versions
There are two versions of WSL:
WSL 1: It is a compatibility layer that translates Linux system calls to Windows calls without using virtualization. It uses fewer resources but has limitations with the file system and some networking features.
WSL 2: It uses a real Linux kernel inside a lightweight virtual machine, offering full compatibility with Linux applications and improved performance.
We recommend WSL 2 for most cases due to its better performance and compatibility.
Windows Versions Compatible with WSL
WSL is compatible with:
- Windows 10 version 2004 or later (build 19041 or higher).
- Windows 11.
To check your version of Windows:
- Press
Win + R
, typewinver
, and press Enter. - A window with your system information will appear.
Note: Make sure you have the latest Windows update to avoid any compatibility issues with WSL.
1. Installing WSL
Installing WSL is easy. Follow these steps:
- Open PowerShell as Administrator. This is necessary to ensure you have the proper permissions to install WSL.
- Run the following command in PowerShell:
wsl --install
This command installs WSL 2 and the default Ubuntu distribution.
- Restart your PC when prompted. Once restarted, WSL will be installed.
2. Configuring Linux on WSL
Open the Linux application you installed (for example, Ubuntu) and follow the on-screen instructions to set up your username and password. This is required to run commands in your Linux environment.
3. Installing Applications
Now that you have WSL and Linux set up, you can install Linux applications on Windows. For example, if you want to install Git, just run these commands:
sudo apt update
sudo apt install git
Other useful applications include:
- Node.js for JavaScript development:
sudo apt install nodejs npm
- Python for scripts and automation:
sudo apt install python3 python3-pip
- Docker for containers:
I will soon be sharing a more detailed guide on how to install some of these applications through a version manager.
Common Troubleshooting
If you encounter issues during installation or use of WSL, here are some solutions:
Error Enabling Windows Features
If you receive an error indicating that the necessary features are not enabled:
- Open PowerShell as Administrator.
- Run the following commands:
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
- Restart your computer.
WSL 2 Requires a Kernel Component Update
If you are prompted to update the WSL 2 kernel component:
- Download the update package from Microsoft's official website:
- Run the installer and follow the instructions.
Network or Connectivity Issues
If you experience network problems within WSL:
- Restart the network service from the Linux terminal by running:
sudo service networking restart
- Make sure your firewall is not blocking connectivity.
Also Available in Spanish
If you prefer to read this article in Spanish, you can find the full version on my website: Cómo instalar WSL desde PowerShell en Windows 10 y 11.
Additionally, I invite you to watch the explanation in Spanish through this video:
With WSL, you can enjoy the best of both Linux and Windows in a single environment. Installing WSL from PowerShell is quick and easy, allowing you to optimize your workflow as a developer without the need for virtual machines. Start today and take advantage of having Linux on Windows!
Top comments (0)