本文简单介绍了 Windows 与 WSL(Windows Subsystem for Linux)之间的互操作。

Run WSL from Windows

  1. Run Windows Command Prompt(CMD or PowerShell).
  2. Simply add wsl before Windows command.

    1
    
       wsl sudo apt update
  3. Mix WSL and Windows commands.

    1
    2
    
       wsl ls -la | findstr "foo"
       dir | wsl grep foo

Run Windows Tools from WSL

  1. Run Linux Shell(Bash or others).
  2. Simply run windows application with extension .exe.

    1
    
       notepad.exe
  3. Mix WSL and Windows commands.

    1
    2
    
       $ ls -la | findstr.exe "foo"
       $ cmd.exe /c dir | grep foo