安装wsl

控制面板->程序->程序和功能->左侧->启用或关闭Windows功能->适用于Linux的Windows子系统
windows应用商店输入ubuntu 下载安装 然后输入账户密码

换源

sudo vim /etc/apt/sources.list

deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse

sudo apt update
sudo apt upgrade

配置远程ssh连接

sudo apt remove openssh-server
sudo apt install openssh-server
sudo vim /etc/ssh/sshd_config

Port 2222                      # 设置ssh的端口号, 由于22在windows中有别的用处, 尽量不修改系统的端口号
PermitRootLogin yes            # 可以root远程登录
PasswordAuthentication yes     # 密码验证登录

:wq
sudo /etc/init.d/ssh restart

原文链接:https://blog.csdn.net/lcuwb/article/details/82885920

root执行权限

sudo nano /etc/sudoers
%sudo ALL=NOPASSWD: /etc/init.d/ssh start

Windows一键运行WSL脚本

Set ws = WScript.CreateObject("WScript.Shell")
ws.run "wsl sudo /etc/init.d/ssh start", vbhide

创建一个StartLinux.bat

net stop LxssManager
start StartWSL.vbs

访问windows磁盘

默认windows磁盘会挂载到 /mnt 可以进行对windows磁盘的操作