wsl相关总结

  • 启用WSL
    VirtualMachinePlatform是WSL2依赖功能,需要系统支持(build 18917+),硬件支持VM功能并开启,安装完成后要重启计算机。
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform
  • 升级WSL到WSL2
wsl --set-version ubuntu 2 #设置为1则降级
  • 文件读写权限配置
sudo vim /etc/wsl.conf

添加如下内容

[automount]
enabled=true
root="/mnt/"
options="metadata,uid=1000,gid=1000,umask=22,fmask=111"
mountFsTab=true
[network]
generateHosts=true
generateResolvConf=true
  • 修改源为阿里云镜像
sudo vim /etc/apt/sources.list
#替换成阿里云镜像
:%s/security.ubuntu/mirrors.aliyun/g
:%s/archive.ubuntu/mirrors.aliyun/g

sudo apt update && sudo apt upgrade -y
  • 关闭git文件模式,解决wsl与windows上一边操作后,另一边git提示有文件修改问题。
git config core.filemode false
git config core.autocrlf true #如果windows上也配置了这个选项,则不建议关闭。

猜你喜欢

转载自www.cnblogs.com/flying_bat/p/11089167.html
wsl