Windows Subsystem for Linux (WSL)
ref:
- Microsoft | Docs,
- Microsoft | Community,
- Appuals,
- Microsoft | Docs | Manual installation WSL,
- Microsoft | Docs | WSL VS Code,
- Microsoft | Docs | set up WSL development environment
The Windows Subsystem for Linux lets developers run a GNU/Linux environment -- including most command-line tools, utilities, and applications -- directly on Windows, unmodified, without the overhead of a traditional virtual machine or dualboot setup.
Step-by-step to install WSL2 on Win 10 machine:
- Enable Developer Mode in Windows 10
- Enable
Windows Subsystem for Linux
andVirtual Machine Platform
If it doesn't work, enable them through PowerShell (with administrative privileges)
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
- Set WSL 2 as my default version
wsl --set-default-version 2
- Open up the
Microsoft Store
and search forWSL
to install a Linux Distribution.I chose
Ubunto 20.04 LTS
- Check result
wsl -l -v
The version shows
2
. And distro name showsUbuntu-20.04
is OK. - Install VS Code and the Remote WSL extension
- Install Visual Studio Code on Windows (not in your WSL file system)
- When prompted to Select Additional Tasks during installation, be sure to check the Add to PATH option so you can easily open a folder in WSL using the code command
- Install the Remote-WSL extension
Working across Windows and Linux file systems
ref: Microsoft | Docs
We recommend against working across operating systems with your files, unless you have a specific reason for doing so. For the fastest performance speed, store your files in the WSL file system if you are working in a Linux command line (Ubuntu, OpenSUSE, etc). If you're working in a Windows command line (PowerShell, Command Prompt), store your files in the Windows file system.
For example, when storing your WSL project files:
- Use the Linux file system root directory:
\\wsl$\Ubuntu-18.04\home\<user name>\Project
- Not the Windows file system root directory:
/mnt/c/Users/<user name>/Project$ or C:\Users\<user name>\Project
You can view the directory where your files are stored by opening the Windows File Explorer from the command line, using:
explorer.exe .
Notice the dot (
.
) at the end of command, to mark the current folder to be opened.
To view all of your available Linux distributions and their root file systems in Windows File explorer, in the address bar enter: \\wsl$
Backlinks