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则降级
wsl --set-default-version 2 #设置默认版本
wsl -l -v #显示已安装的列表
  • 文件读写权限配置
sudo vim /etc/wsl.conf

添加以下内容git

[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上也配置了这个选项,则不建议关闭。
相关文章
相关标签/搜索