shlu's note

简介

wsl为window子系统工具

安装WSL2

安装WSL2

使用ubuntu子系统

wsl常用命令1

remoteWSL工具(vscode插件)

linux访问window目录

开启子系统全局代理

wsl1

WSL修改子系统目录

wsl -l -v
wsl --export Ubuntu-20.04 d:\ubuntu20.04.tar
wsl --unregister Ubuntu-20.04
wsl --import Ubuntu-20.04 d:\ubuntu d:\ubuntu20.04.tar --version 2
del d:\ubuntu20.04.tar

切换账户

WSL2设置全局代理

#!/bin/bash
host_ip=$(cat /etc/resolv.conf |grep "nameserver" |cut -f 2 -d " ")
export ALL_PROXY="http://$host_ip:10809"
export HTTP_PROXY="http://$host_ip:10809"
export HTTPS_PROXY="https://$host_ip:10809"
export https_proxy="https://$host_ip:10809"
export http_proxy="http://$host_ip:10809"
export all_proxy="http://$host_ip:10809"
echo "proxy ip:$ALL_PROXY"

执行时需用source执行,否则无法生效

使目录大小写敏感

问题

q1.The system can not find the file specified.

If you have downloaded the Appx file then extract it with any unzipping tool (for example 7zip) in a folder and run the ubuntu.exe in it.

q2.linux系统默认没有导入window path问题,导致一些window下的命令在子系统里找不到

在/etc/wsl.conf文件(没有则touch一个)里加入如下代码:

[interop]
enabled = true
appendWindowPath = true

q3.vscode 的remoteWSL 不能编辑root权限的文件3

ubuntu.exe config --default-user root

q4.参考的对象类型不支持尝试的操作(WSL2)

q4. error: chmod on /aosp/.repo/repo/.git/config.lock failed: Operation not permitted

参考https://github.com/docker/for-win/issues/6284
参考https://devblogs.microsoft.com/commandline/chmod-chown-wsl-improvements/

q5.请启用虚拟机平台 Windows 功能并确保在 BIOS 中启用虚拟化。

执行bcdedit /set hypervisorlaunchtype auto然后重启系统即可

参考

声明:转载请注明出处,原文地址:shlu's note