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上也配置了這個選項,則不建議關閉。
相關文章
相關標籤/搜索