(9条消息) WSL2安装Ubuntu
WSL2安装Ubuntu
目录
- 一、更新 Windows 10 到 2004
- 二、启用Windows功能
- 三、安装Linux内核更新包
- 四、下载/安装Linux发行版
- 五、设置WSL版本
- 六、换源
- 七、更新组件
- 八、终端优化
- 九、安装zsh
- ~ 其它
- ~ 参考资料
一、更新 Windows 10 到 2004
- Windows设置➫更新和安全➫检查更新
- 微软官网➫立即更新
二、启用Windows功能
A、控制面板➫程序➫程序和功能➫启用或关闭Windows功能
- ☑ 适用于Linux的Windows子系统
- ☑ Windows虚拟机平台
B、PowerShell命令方式
- win + R运行:powershell
- win + X菜单选择:powershell
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart #适用于Linux的Windows子系统
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart #启用虚拟机平台
三、安装Linux内核更新包
四、下载/安装Linux发行版
- Microsoft Store搜索Ubuntu,下载需要的版本
- 点击Ubuntu完成安装
- 执行命令
sudo apt-get update #执行更新
sudo apt-get install ca-certificates #安装ca-certificates组件
五、设置WSL版本
- 设置WSL版本
wsl --set-default-version 2 #PowerShell命令
- 检查WSL版本
wsl -l -v
#显示
NAME STATE VERSION
- Ubuntu-20.04 Running 2
六、换源
- 备份配置文件
sudo cp -a /etc/apt/sources.list /etc/apt/sources.list.bak
- 修改sources.list文件
- 将http://archive.ubuntu.com和http://security.ubuntu.com替换成http://mirrors.huaweicloud.com,可以参考如下命令:
sudo sed -i "s@http://.*archive.ubuntu.com@http://mirrors.huaweicloud.com@g" /etc/apt/sources.list
sudo sed -i "s@http://.*security.ubuntu.com@http://mirrors.huaweicloud.com@g" /etc/apt/sources.list
- 执行apt-get update更新索引
七、更新组件
sudo apt upgrade
- 如出现:
The following packages have been kept back:
- 参考:
因为有部分packages的安装版比release版新,而出现“The following packages have been kept back”这个问题,解决方法是使用apt-get -u dist-upgrade统一更新到发布的版本。这条命令会强制更新软件包到最新版本,并自动解决缺少的依赖包。
- 解决方法:
sudo apt-get -u dist-upgrade #统一更新到发布的版本
八、终端优化
- 安装Fluent Terminal
- 下载:FluentTerminal.Package_0.7.2.0_Test.zip
- 解压:Install.ps1 -> 右键 -> 使用PowerShell运行
- 修改字体
- 下载字体
curl -L "https://github.com/powerline/fonts/raw/master/SourceCodePro/Sauce%20Code%20Powerline%20Regular.otf" -o "Source Code Pro for Powerline.otf"
- 安装字体
mkdir -p ~/.fonts
cp Source\ Code\ Pro\ for\ Powerline.otf ~/.fonts/
mkdir -p ~/.fonts/PowerlineFonts
cp Source\ Code\ Pro\ for\ Powerline.otf ~/.fonts/PowerlineFonts
fc-cache -f -v ~/.fonts/
#异常:
command not found: fc-cache
#解决:
sudo apt-get install fontconfig
九、安装zsh
cat /etc/shells #查看安装了几种Shell
sudo apt-get install zsh
chsh -s /bin/zsh #修改默认Shell
- 安装on-my-zsh
#自动安装
wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh
#手动安装
git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
- 修改主题
vim ~/.zshrc
ZSH_THEME="powerlevel9k/powerlevel9k" //主题目录:~/.oh-my-zsh/themes
~ 其它
~ 参考资料
适用于 Linux 的 Windows 子系统安装指南 (Windows 10)
WSL2安装Debian(Ubuntu)并配置国内apt源
WSL安装及升级WSL2
终极 Shell——ZSH
The following packages have been kept back:
华为开源镜像站
赞 (0)