鉴于学生党大部分都是Windwos用户,怎么在Windows上搭载高效的前端开发环境,能影响到更多的人。

官方文档
官方中文文档

常用命令

查看已安装的子系统

  1. wsl --list --verbose

image.png

导出已安装子系统镜像

  1. wsl --export <Distro> <FileName>
  2. wsl --export Ubuntu-20.04 E:\wsl\custom.tar

安装已导出的系统镜像

这样安装的优势是能安装在非C盘, 对于C盘内存紧张的用户来说非常友好

  1. wsl --import <Distro> <InstallLocation> <FileName>
  2. wsl --import custom E:\wsl\ubuntu_custom E:\wsl\custom.tar

子系统对于的文件
image.png

image.png

设置wsl默认子系统

  1. wsl --set-default custom

wsl 完整使用命令

  1. Arguments for running Linux binaries:
  2. If no command line is provided, wsl.exe launches the default shell.
  3. --exec, -e <CommandLine>
  4. Execute the specified command without using the default Linux shell.
  5. --
  6. Pass the remaining command line as is.
  7. Options:
  8. --distribution, -d <Distro>
  9. Run the specified distribution.
  10. --user, -u <UserName>
  11. Run as the specified user.
  12. Arguments for managing Windows Subsystem for Linux:
  13. --export <Distro> <FileName>
  14. Exports the distribution to a tar file.
  15. The filename can be - for standard output.
  16. --import <Distro> <InstallLocation> <FileName> [Options]
  17. Imports the specified tar file as a new distribution.
  18. The filename can be - for standard input.
  19. Options:
  20. --version <Version>
  21. Specifies the version to use for the new distribution.
  22. --list, -l [Options]
  23. Lists distributions.
  24. Options:
  25. --all
  26. List all distributions, including distributions that are currently
  27. being installed or uninstalled.
  28. --running
  29. List only distributions that are currently running.
  30. --quiet, -q
  31. Only show distribution names.
  32. --verbose, -v
  33. Show detailed information about all distributions.
  34. --set-default, -s <Distro>
  35. Sets the distribution as the default.
  36. --set-default-version <Version>
  37. Changes the default install version for new distributions.
  38. --set-version <Distro> <Version>
  39. Changes the version of the specified distribution.
  40. --shutdown
  41. Immediately terminates all running distributions and the WSL 2 lightweight utility virtual machine.
  42. --terminate, -t <Distro>
  43. Terminates the specified distribution.
  44. --unregister <Distro>
  45. Unregisters the distribution.
  46. --help
  47. Display usage information.

网络问题

wsl2的一些网络问题
查看主机ip

  1. ip route | grep default | awk '{print $3}'