This issue occurs when Windows cannot locate the Windows Subsystem for Linux executable or the WSL 2 integration driver. The most reliable fix is to use the wsl --install command to download and register the necessary components from the Microsoft Store, which will automatically configure the environment variables required to run commands like wsl, ubuntu, or ls from PowerShell or Command Prompt.
What You'll Need
- A computer running Windows 11 with an active internet connection.
- Administrator access to the computer to install system components.
- A Microsoft account (optional but recommended for the Store).
- Approximately 1 GB of free disk space for the WSL Linux kernel and distribution.
Step-by-Step
- Open the Command Prompt as Administrator: Right-click the "Start" button or press the Windows Key, type "cmd" or "Command Prompt", right-click the app in the list, and select "Run as administrator". A UAC prompt will appear; click "Yes".
- Verify the Command: In the elevated Command Prompt window, type
wsl --installand press Enter. Do not press Enter immediately after typing the command; wait for the prompt to return before pressing Enter. This ensures the command is fully recognized. - Allow Installation: The system will detect that WSL components are missing and prompt you to install them. Press any key to continue. The system will then prompt you to restart the computer to finish the installation. Click "Restart now" or "Yes".
- Complete the Initial Setup: After the computer restarts, the Windows Subsystem for Linux component will be installed. A window will appear indicating that "Some Windows optional features are not installed". Click "View optional features".
- Enable Additional Features: In the "Add an optional feature" window, click the link that says View features at the top right. This will open the list of available features. Search for "Windows Subsystem for Linux" and check the box next to it. You will also see "Virtual Machine Platform". Check the box for "Virtual Machine Platform" as well. Click "Next" and then "Install". Allow the installation to complete, which may take a few minutes, and then restart the computer one final time.
- Set Your Default Linux Distro: After the second restart, open Command Prompt again (as administrator if possible) and run
wsl --install -d Ubuntu. This command installs the Ubuntu distribution and sets it as the default. If you choose a different name in the prompt, remember it, as you will need to type it to launch your Linux environment. - Finish the Ubuntu First-Run Setup: Launch Ubuntu by typing
ubuntuin your terminal. The first time you run it, it will install additional files. When prompted, create a UNIX username and a password. The password will not appear on screen as you type it; this is a security feature. Type the password twice and press Enter. - Update Your System: Once inside the Ubuntu shell, it is good practice to update your package lists. Type
sudo apt updateand press Enter. You will be asked for your password again. If the command works, your WSL environment is fully functional, and thewslcommand will be recognized.
Common Mistakes
One of the most common reasons for the error persists is attempting to run WSL on a machine that does not support virtualization or has it disabled in the BIOS. The Windows Subsystem for Linux 2 requires a virtual machine platform, which relies on hardware virtualization extensions. If these are turned off, wsl --install may fail silently or report an error.
Another frequent error occurs when users try to launch a specific distribution before it has actually been installed. If you see 'ubuntu' is not recognized as an internal or external command, it means the wsl --install step was not executed successfully, or the installation was interrupted. You must return to the Command Prompt and ensure the base WSL components are downloaded and the computer is restarted before trying to launch a specific Linux shell.
Tips
For the best performance, ensure your Windows 11 system is fully up to date. Microsoft frequently releases updates that improve the WSL kernel and fix compatibility issues. You can check for updates by going to Settings > Windows Update.
When you are finished working in your Linux environment, you can exit the shell by typing exit. The next time you type wsl, your session will start where you left off, preserving your file changes and open programs.
Troubleshooting
If you have followed the steps above and the wsl command is still not found, or if the installation fails, try the following checks in order of simplicity.
Check for Virtualization Support
You can use the System Information tool to verify that virtualization is enabled in your BIOS or UEFI firmware. Open the Start menu, type "System Information", and launch the app. Navigate to "System Summary" > "Processor". Look for a value labeled "Virtualization Enabled In Firmware". If it says "No", you must enter your BIOS/UEFI settings and enable the virtualization feature (often labeled VT-x, SVM, or AMD-V) before Windows can run WSL.
Run the Command Prompt as Administrator
Ensure you are using an elevated Command Prompt. Standard Command Prompt windows do not have the permissions required to modify system features or install the WSL Linux kernel. Right-click the Start button, select "Terminal (Admin)" or "Command Prompt (Admin)", and try the wsl --install command again.
Check Windows Feature Status
Navigate to Settings > Apps > Optional features. Search for "Windows Subsystem for Linux". If it is not listed, click "View features” and ensure it is checked. If it is listed but shows a status of "Not installed", click on it and select "Uninstall", wait for it to finish, and then try installing it again. Alternatively, you can enable it by running Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux in an elevated PowerShell session.
Use PowerShell instead of Command Prompt
Although the standard Command Prompt works for most WSL commands, some users report that PowerShell provides a more robust environment for running the installation script. Open PowerShell as Administrator and run wsl --install. The behavior is generally the same, but the environment variables are handled slightly differently depending on the shell.
Frequently Asked Questions
Does the WSL command work on Windows 10?
Yes, the wsl command and the wsl --install feature are supported on Windows 10 version 2004 and later. If you are on an older version of Windows 10, you may need to update via Windows Update or manually download the WSL 2 Linux kernel update package from the Microsoft Store.
How do I uninstall WSL completely?
To remove WSL and all installed Linux distributions, you can run wsl --unregister for each distribution you wish to remove. To remove the WSL feature itself, open an elevated PowerShell or Command Prompt and run wsl --uninstall. Note that this will remove the Linux kernel and the Windows Subsystem for Linux optional feature, effectively resetting the environment.
Why is the command not found in PowerShell but works in CMD?
This is usually a result of environment variable caching or a corrupted shell profile. If the command works in Command Prompt but not PowerShell, try closing and reopening both terminals. If the issue persists, you may need to manually add the WSL installation path to your system's PATH environment variable, though this is rarely necessary if the wsl --install command was run successfully.
Can I run graphical applications inside WSL?
Yes, starting with recent versions of Windows 11 and updated WSL components, you can run GUI Linux applications directly on your Windows desktop. This works by forwarding the display over the virtualization network. You generally do not need to install any extra software; simply launch the application from the terminal, and it will open in a window on your Windows desktop.
What if I get an error code 0x8007019E?
Error code 0x8007019E usually indicates that the Windows Subsystem for Linux feature is disabled or missing. You can fix this by opening the Control Panel, going to "Turn Windows features on or off", and checking the box for "Windows Subsystem for Linux". Alternatively, use the PowerShell command mentioned in the Troubleshooting section to enable it.