Windows Subsystem for Linux (WSL)

ref:

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:

  1. Enable Developer Mode in Windows 10 dev-mode
  2. Enable Windows Subsystem for Linux and Virtual Machine Platform windows-features-on 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
    
  3. Set WSL 2 as my default version
    wsl --set-default-version 2
    
  4. Open up the Microsoft Store and search for WSL to install a Linux Distribution. wsl-microsoft-store I chose Ubunto 20.04 LTS
  5. Check result
    wsl -l -v
    
    result-example The version shows 2. And distro name shows Ubuntu-20.04 is OK.
  6. 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$ linux-file-explorer


Backlinks