Using Windows Subsystem for Linux (WSL)
Learn how to install and use Windows Subsystem for Linux (WSL) to run a full Linux environment on your Windows machine. This guide covers installation, basic usage, file system integration, and essential commands for getting started with Linux development on Windows.
If you're a Windows user wanting to learn Linux without giving up your familiar desktop environment, Windows Subsystem for Linux (WSL) is your perfect starting point. WSL lets you run a full Linux environment directly inside Windows, giving you access to the Linux command line, tools, and workflows without the complexity of dual-booting or virtual machines.
What is WSL?
Windows Subsystem for Linux is a compatibility layer developed by Microsoft that allows you to run Linux binary executables natively on Windows 10 and 11. Think of it as having Linux living peacefully inside your Windows system, with seamless integration between both environments.
There are two versions available: WSL 1 and WSL 2. WSL 2 is the current standard and uses actual Linux kernel virtualization, providing better performance and full system call compatibility. However, WSL 1 might still be preferable in certain scenarios, such as when you need faster startup times or are using older hardware that doesn't support virtualization features required by WSL 2. For most users, WSL 2 is the recommended choice.
Installing WSL
Installing WSL has become remarkably simple on modern versions of Windows. Open PowerShell or Command Prompt as Administrator and run:
wsl --installThis single command installs WSL 2, sets it as the default version, and installs Ubuntu as your Linux distribution. Note that this automatic installation requires Windows 10 version 2004 or later (or Windows 11). On earlier versions of Windows, you may need to follow manual installation steps or install specific updates first.
After installation, restart your computer, and you'll be prompted to create a Linux username and password.
To check your WSL version and see installed distributions:
wsl --list --verboseIf you want a different Linux distribution, you can browse available options:
wsl --list --onlineThen install your preferred distribution:
wsl --install -d DebianGetting Started with Your Linux Environment
Once installed, you can launch your Linux environment in several ways:
- Type
wslin any Windows terminal - Search for your distribution name (like "Ubuntu") in the Start menu
- Open Windows Terminal and select your Linux distribution from the dropdown
When you first launch WSL, you'll find yourself in your Linux home directory. You can navigate your Windows files from within Linux by accessing the /mnt/c/ directory, which represents your C: drive:
cd /mnt/c/Users/YourUsername/DocumentsConversely, you can access your Linux files from Windows Explorer by navigating to \\wsl$\Ubuntu\home\yourusername or simply typing \\wsl$ in the address bar.
Essential Commands and Usage
Your WSL environment comes with a full Linux system. Update your package manager first:
sudo apt update && sudo apt upgradeInstall common development tools:
sudo apt install git curl wget python3 python3-pipTo manage your WSL instances from Windows, useful commands include:
wsl --shutdown- Stops all running WSL instanceswsl --terminate Ubuntu- Stops a specific distributionwsl --set-default Ubuntu- Sets your default distributionwsl --unregister Ubuntu- Removes a distribution (careful with this one!)
Integration Benefits
WSL's real power comes from its integration capabilities. You can run Windows applications from Linux and vice versa. For example, open a Windows file from your Linux terminal:
explorer.exeOr edit a Linux file with a Windows application:
code myfile.txtThis assumes you have Visual Studio Code installed with the WSL extension, which provides excellent integration between your Windows editor and Linux environment.
Performance Considerations
For best performance, keep your project files within the Linux file system rather than accessing Windows files through /mnt/c/. The Linux file system in WSL 2 provides much faster I/O operations, especially important for development workflows involving many small files.
What's Next
Now that you have WSL running, you're ready to dive into Linux fundamentals. In our next post, we'll explore the Linux file system structure and learn how to navigate directories efficiently using essential commands like ls, cd, and pwd. You'll use these skills constantly in your WSL environment, so mastering navigation is your logical next step.