TechBuzzPro

How to Use WSL in Windows 11

· 6 min read · Windows & PC

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

To use WSL (Windows Subsystem for Linux) in Windows 11, open PowerShell or Command Prompt as Administrator, run wsl --install, restart your PC, and then launch a Linux distribution from the Start menu or terminal. This installs a full Linux environment (by default Ubuntu) that runs alongside Windows without a virtual machine. You need a 64-bit PC running Windows 11 (version 21H2 or later) and, for the default setup, internet access to download the distribution.

What You'll Need

  • A Windows 11 PC (64-bit) with at least 4 GB of RAM (8 GB recommended).
  • Administrator access to install WSL.
  • Internet connection to download the Linux distribution.
  • Optional: A Microsoft account to sign in to the Microsoft Store if you install distributions from there.

Step-by-Step

  1. Open PowerShell or Command Prompt as Administrator: Right-click the Start button and select "Terminal (Admin)" or "Windows PowerShell (Admin)". If prompted by User Account Control, click "Yes".
  2. Install WSL: In the terminal, type wsl --install and press Enter. This command enables the required Windows features, downloads the latest WSL kernel, and installs the default Ubuntu distribution. The process may take a few minutes.
  3. Restart your PC: After the installation finishes, you'll see a message asking to restart. Save your work and restart Windows.
  4. Launch the Linux distribution: After restarting, the Ubuntu window should open automatically. If not, search for "Ubuntu" in the Start menu and click it. The first launch will ask you to create a UNIX username and password (this is separate from your Windows login).
  5. Update your Linux packages: In the Ubuntu terminal, run sudo apt update and then sudo apt upgrade to ensure your system is up to date. Enter your UNIX password when prompted.
  6. Access your Windows files: Your Windows drives are mounted under /mnt/c/ (for C:), /mnt/d/ (for D:), etc. You can navigate there with cd /mnt/c/Users/YourName to reach your Windows user folder.
  7. Run Linux commands: You can now use any Linux command, install software with apt, or run development tools like Python, Node.js, or Git. For example, sudo apt install python3 installs Python.
  8. Set WSL version (optional): To check your WSL version, run wsl --status in PowerShell. To set a specific distribution to WSL 2, use wsl --set-version <distro> 2 (replace <distro> with the name, e.g., Ubuntu).
  9. Install additional distributions (optional): If you want more than Ubuntu, open the Microsoft Store, search for "Linux", and choose from distributions like Debian, Kali, or openSUSE. Click "Install" and then launch it from the Start menu.

Common Mistakes

  • Not running the terminal as Administrator: The wsl --install command requires admin rights. If you get an error about privileges, right-click and run as admin.
  • Skipping the restart: Some features aren't fully enabled until you restart. If WSL doesn't work after install, restart and try again.
  • Using the wrong command for older versions: If you previously had WSL 1 enabled, you might need to run wsl --update to get the latest kernel. The simple wsl --install usually handles this, but if not, run the update.
  • Forgetting the UNIX password: The password you set for Linux is not your Windows password. If you forget it, you can reset it from Windows by running wsl --user root and then using passwd <username>.
  • Accessing Windows files incorrectly: Don't try to open Windows files from Linux using Windows paths like C:\. Use /mnt/c/ instead.

Tips

  • Use WSL 2: It offers better performance and full system call compatibility. Check with wsl --status; if you're on WSL 1, convert with wsl --set-version <distro> 2.
  • Run Linux commands from Windows: You can type wsl <command> in PowerShell to run a Linux command without opening the Linux terminal. For example, wsl ls -la lists files in the current Windows directory.
  • Set your default distribution: If you have multiple distros, use wsl --set-default <distro> to choose which one opens when you type wsl.
  • Use Windows Terminal: It provides a tabbed interface for both PowerShell and WSL. Download it from the Microsoft Store for a better experience.
  • Share files easily: Keep project files in your Windows file system (e.g., C:\Users\You\projects) and access them from Linux via /mnt/c/Users/You/projects to avoid permission issues.

Troubleshooting

If WSL doesn't work after installation, try these steps in order:

  1. Check if virtualization is enabled: Open Task Manager (Ctrl+Shift+Esc), go to the Performance tab, and look for "Virtualization". If it's disabled, you need to enable it in your BIOS/UEFI settings. Restart, press the key to enter BIOS (often Del or F2), find the virtualization option (often called Intel VT-x or AMD-V), enable it, and save.
  2. Update WSL: Run wsl --update in an elevated PowerShell to get the latest kernel and components.
  3. Check the Windows features: Ensure "Windows Subsystem for Linux" and "Virtual Machine Platform" are enabled. Go to Settings > Apps > Optional features > More Windows features, or run dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all and dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all in an admin terminal, then restart.
  4. Reset the distribution: If your Linux distro is corrupted, go to Settings > Apps > Installed apps, find your distribution, click the three-dot menu, and choose "Advanced options", then "Reset". This will delete your Linux files, so back up anything important.
  5. Reinstall WSL: As a last resort, uninstall WSL with wsl --uninstall (this removes all distributions and data), then reinstall with wsl --install.

Frequently Asked Questions

Can I run graphical Linux apps with WSL?

Yes, WSL 2 supports GUI apps. Install a GUI app in Linux (e.g., sudo apt install gedit) and launch it from the Linux terminal; it will appear in a Windows window. You may need to install an X server like VcXsrv for some apps, but many work out of the box.

How do I access my Windows files from WSL?

Your Windows drives are mounted under /mnt/. For example, your C: drive is at /mnt/c/. Navigate there with cd /mnt/c/Users/YourName.

Can I use WSL without a Microsoft account?

Yes, WSL itself doesn't require a Microsoft account. You only need an account if you install distributions from the Microsoft Store, but you can also install them via command line without a store account.

How do I uninstall a Linux distribution?

Open PowerShell and run wsl --unregister <distro> (e.g., wsl --unregister Ubuntu). This removes the distribution and all its files. To uninstall WSL entirely, run wsl --uninstall.

Why is my WSL terminal slow?

If you're accessing files on the Windows filesystem (like /mnt/c/), it can be slow. Keep your project files inside the Linux filesystem (e.g., ~/projects) for better performance. Also, ensure you're using WSL 2.

Can I run Docker inside WSL?

Yes, you can install Docker inside your WSL distribution, or use Docker Desktop with WSL 2 integration. Docker Desktop is the easiest way, and it integrates seamlessly with WSL.