百度百科描述WSL:Windows Subsystem for Linux(簡稱WSL)是一個在Windows 10上能夠運行原生Linux二進制可執行文件(ELF格式)的兼容層。它是由微軟與Canonical公司合作開發,其目標是使純正的Ubuntu 14.04 "Trusty Tahr"映像能下載和解壓到用戶的本地計算機,並且映像內的工具和實用工具能在此子系統上原生運行。
1、啓用或關閉Windows功能
2、安裝WSL
在微軟應用商店(https://www.microsoft.com/zh-cn/store/)搜索 Linux,選用 Ubuntu ,下載完成後安裝,然後重啓電腦,打開Ubuntu應用,發現出現下面錯誤。
The WSL optional component is not enabled. Please enable it and try again
錯誤解決辦法:
1)在Windows“開始”處右鍵打開,選擇Windows PowerShell管理員打開;
輸入下面命令後回車執行:
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
2)在設置–>更新和安全–>開發者選項處,將開發人員模式打開;
完成後,重啓電腦;
打開Ubuntu應用,
創建用戶名跟密碼:
3、配置 WSL
1)更改源
備份原來的源:sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
編輯文件:sudo vim /etc/apt/sources.list
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
2)更新和升級
sudo apt-get update
sudo apt-get upgrade
3)安裝zsh
sudo apt-get install zsh
設置默認 shell 爲 zsh
chsn –s $(which zsh)
設置完成後使用下列命令檢查是否設置成功
echo $SHELL
4)設置 ys 主題
sudo vim ~/.zshrc
ZSH_THEME="ys"
source ~/.zshrc