Skip to content

Ubuntu wsl的一些坑

wsl中由于权限问题,之前修改了usr目录的权限,导致sudo不能用了,解决方案如下

在 windows power shell中

1
2
3
4
5
6
7
ubuntu1804.exe config --default-user root

chown root:root /usr/bin/sudo
chmod 4755 /usr/bin/sudo
chown root /usr/lib/sudo/sudoers.so

ubuntu1804.exe config --default-user hanshuo

windows安装wsl2的教程

https://zhuanlan.zhihu.com/p/356397851

如何在windows 11中安装WSLG(WSL2) - guojikun - 博客园 (cnblogs.com)

wsl2可视化

1
export DISPLAY=$(awk '/nameserver / {print $2; exit}' /etc/resolv.conf 2>/dev/null):0

wsl2访问外网:

1.首先保证wsl能访问本机ip https://blog.csdn.net/nick_young_qu/article/details/113709768 2.调整socket代理

1
2
3
4
host_ip=$(cat /etc/resolv.conf |grep "nameserver" |cut -f 2 -d " ")
#export ALL_PROXY="http://$host_ip:10810"
export http_proxy=socks5://$host_ip:10810
export https_proxy=socks5://$host_ip:10810
如果遇到了socket报错,可以暂时先取消代理
1
2
unset http_proxy
unset https_proxy

终极大法

取消全部代理: unset http_proxy unset HTTP_PROXY unset https_proxy unset HTTPS_PROXY git config --global --unset http.proxy git config --global --unset https.proxy

在windows中C:\Users\hanshuo.wslconfig中覆盖以下内容

[experimental] autoMemoryReclaim=gradual # gradual | dropcache | disabled networkingMode=mirrored dnsTunneling=true firewall=false autoProxy=true

cmake升级:

https://blog.csdn.net/qingkong8978/article/details/106432949