Linux on Windows (WSL)
The Windows Subsystem for Linux (WSL) runs a real Linux distribution such as Ubuntu on your Windows machine, with a Bash shell and Linux tools, without a separate virtual machine to manage.
Getting started
From an administrator PowerShell, run wsl --install and restart. This installs WSL and the Ubuntu distribution. You then create a Linux user name and password on first launch. Open it from Windows Terminal, the Start menu, or by typing wsl in any PowerShell window.
wsl --list --online # distributions you can install
wsl --list --verbose # installed distributions and their WSL version
wsl --shutdown # stop all running distributions
New installs use WSL 2, where Linux runs in a lightweight virtual machine with a real Linux kernel.
Two file systems
- Windows files are visible from Linux under
/mnt/c/.... - Linux files are visible from Windows under
\\wsl$\<distro>(or\\wsl.localhost\<distro>), andexplorer.exe .opens the current Linux folder in File Explorer. - Work on the side that matches your tools. Linux tools (Git, Node, Python, builds) are much faster and more reliable on files stored in the Linux home directory (
~) than on/mnt/c. Keep Windows-tool projects on the Windows side. - Remember Linux is case-sensitive even when the same file is also visible from Windows.
Mixing the two
You can call across the boundary: wsl ls -la runs a Linux command from PowerShell, and notepad.exe file.txt runs a Windows program from Bash. VS Code can open a WSL folder and run its extensions inside Linux.
Repositories and localhost
- Keep a repository on one side only. Do not clone the same repository in both Windows and WSL and expect them to stay in sync, because each is a separate clone with its own Git configuration (including SSH keys).
- Docker, databases and servers started in WSL are usually reachable from Windows at
localhost.
Try it
Install WSL, create a folder in your Linux home directory, open it in File Explorer with explorer.exe ., and clone a small repository there. Compare how long git status takes there and on a clone under /mnt/c.
Common mistakes
- Running Linux tools on files under `/mnt/c`, which is slow and less reliable.
- Cloning the same repository in Windows and WSL and expecting them to stay in sync.
- Forgetting that Linux is case-sensitive even for files also visible from Windows.
Check yourself
- Where do your Windows files appear inside WSL?
- Why should a Linux-tool project live in `~` rather than `/mnt/c`?
- Why do two clones of one repository in Windows and WSL not stay in sync?