Windows10下WSLLinux子系统随Windows自动启动方法

xingyun86 2019-5-26 2074

Windows10下WSLLinux子系统随Windows自动启动方法

1. 创建启动脚本
sudo vi /etc/init.wsl
#!/bin/sh
/etc/init.d/ssh %1
2. 添加执行权限
sudo chmod +x /etc/init.wsl
3. 编辑sudoers,避免输入密码
sudo visudo
或者
sudo nano /etc/sudoers
添加一行(注意=左侧之间是tab,=右侧之间是空格,Alt+X保存退出)
%sudo ALL=(ALL) NOPASSWD: /etc/init.wsl
4. 注册表添加自启动命令
%windir%\system32\bash.exe -c "sudo /etc/init.wsl start"
5. 保存一下文本到WSLSSH.reg文件,然后双击运行,即可。
============================================================================
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]
"WSLSSH"=hex(2):25,00,77,00,69,00,6e,00,64,00,69,00,72,00,25,00,5c,00,73,00,79,\
  00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,62,00,61,00,73,00,68,00,2e,00,\
  65,00,78,00,65,00,20,00,2d,00,63,00,20,00,22,00,73,00,75,00,64,00,6f,00,20,\
  00,2f,00,65,00,74,00,63,00,2f,00,69,00,6e,00,69,00,74,00,2e,00,77,00,73,00,\
  6c,00,20,00,73,00,74,00,61,00,72,00,74,00,22,00,00,00
============================================================================
6. 重启Windows,一切OK。


×
打赏作者
最新回复 (0)
查看全部
全部楼主
返回