WSL 2 的安装过程(以及介绍)(下)

简介: WSL 2 的安装过程(以及介绍)

3 更新一下镜像源


#进入linux终端执行
sudo vim /etc/apt/sources.list

将官方的源都注释掉,换成下面两个之一即可(我的是Ubuntu20.04,别的版本或者源可以自行网上搜)

deb https://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse

清华源

deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse

如果遇到问题:

Certificate verification failed: The certificate is NOT trusted——更新Ubuntu20.04、Debian11的过程中遇到的证书验证失败问题。

解决办法:

更改源文件,将所有的https改成http

sudo vim /etc/apt/sources.list

重新更新源

sudo apt update

安装/更新证书ca-certificates

sudo apt install --reinstall ca-certificates

参照步骤一将镜像源文件改回https

再次更新源

sudo apt update && sudo apt upgrade

大功告成

4 安装Windows Terminal


Windows Terminal能帮助我们管理命令行工具、PowerShell和WSL等Shell用户的工具,能为我们提供最佳的 WSL 体验。

下载方式

https://www.microsoft.com/store/productId/9N0DX20HK701

MicroSoft Store (微软商店)找关键字 Windows Terminal

打开微软应用商店,搜索“Terminal”,安装,打开后的界面是这样的:

640.png

默认打开的是 PownerShell 终端,我们可以设置为默认打开 Ubuntu 终端。点击标签右边的下拉三角,选择设置:

640.png

会在左下角看到一个打开 JSON 文件按钮,然后选择用记事本打开,在 profiles->list 中找到 Ubuntu 的 guid 并复制。

640.png

640.png

将它粘贴为文件开头的 defaultProfile 的值:

640.png

4.1 安装 oh-my-zsh

在 ubuntu 下终端执行

  • 安装 zsh:
sudo apt update 
sudo apt install git zsh -y

然后查看

640.png

可以看到 zsh 已经安装上去,再执行

chsh -s /bin/zsh
  • 安装oh my zsh所需的字体
git clone https://github.com/powerline/fonts.git
cd fonts
./install.sh
  • 安装oh my zsh

国内下载地址:wget https://gitee.com/mirrors/oh-my-zsh/raw/master/tools/install.sh

给 install.sh 添加执行权限

chmod +x install.sh

修改 install.sh 的镜像

vi install.sh

将以下

REPO=${REPO:-ohmyzsh/ohmyzsh}

REMOTE=${REMOTE:-https://github.com/${REPO}.git}

更改为

REPO=${REPO:-mirrors/oh-my-zsh}

REMOTE=${REMOTE:-https://gitee.com/${REPO}.git}

保存退出,执行 install.sh 就将 oh-my-zsh 安装上。

4.2 安装皮肤

安装完 oh-my-zsh 后,编辑 ~/.zshrc 文件,将主题设置为 agnoster robbyrussell:

640.png

再做一点点美化:把命令行的机器名称去掉,并调整用户名的背景色。编辑 agnoster 主题文件:

vi ~/.oh-my-zsh/themes/agnoster.zsh-theme

把 92 行修改为:

prompt_segment green black "%(!.%{%F{yellow}%}.)%n"

修改后如下:

640.png

关闭 Terminal 再重新打开,效果如下:

640.png

4.3 安装历史命令自动补全

git clone git://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions

4.4 安装高亮显示

git clone git://github.com/zsh-users/zsh-syntax-highlighting $ZSH_CUSTOM/plugins/zsh-syntax-highlighting

安装完改一下配置文件

vim ~/.zshrc

把plugins中两个刚刚下载好的插件名字加进去,然后保存退出

plugins=(   git   zsh-autosuggestions   zsh-syntax-highlighting )

最后更新一下配置文件

source .zshrc

执行之后注销重新登陆即可

5 卸载wsl子系统


首先查看本机安装了哪些子系统:

wsl --list --all

其次:

wsl --unregister <System_name>

到其路径下将全部文件删除即可

如若你在安装配置过程中遇到问题,请留言。


相关文章
|
8月前
|
Ubuntu Linux 数据安全/隐私保护
win11安装ubuntu 子系统安装过程及注意事项
win11安装ubuntu 子系统安装过程及注意事项
305 1
|
9月前
|
Ubuntu Linux 数据安全/隐私保护
WIN11系统安装Linux子系统的方法
使用windows11自带的虚拟机安装Linux子系统(WSL),首先需要电脑在BIOS中打开电脑的虚拟技术支持,可以自己搜索一下,网上有很多。 这里只说明一下剩下安装LINUX子系统的操作。使用的是ubuntu无桌面精简发行版。
1852 0
|
9月前
|
Ubuntu 数据安全/隐私保护 虚拟化
win11使用WSL2配置Ubuntu 环境
打开cmd 输入wsl,提示我们系统不支持wsl。
244 0
|
10月前
|
Ubuntu Linux Android开发
Termux安装完整版Linux(Ubuntu)详细步骤
Termux是一款在Android系统上运行的终端模拟器,可以让用户在手机上运行Linux命令行工具和应用程序。本文将介绍如何在Termux中安装完整版Linux(Ubuntu)。
1504 0
Ubuntu 18.04 安装显卡驱动连接错误解决方案
Ubuntu 18.04 安装显卡驱动连接错误解决方案
|
存储 Ubuntu 数据可视化
WSL 2 的安装过程(以及介绍)(上)
WSL 2 的安装过程(以及介绍)
WSL 2 的安装过程(以及介绍)(上)
|
Linux Windows
linux实用技巧:ubuntu18.04安装配置ibus中文输入法
linux实用技巧:ubuntu18.04安装配置ibus中文输入法
linux实用技巧:ubuntu18.04安装配置ibus中文输入法
|
Ubuntu 安全 Linux
Win:Win系统下安装Linux的Ubuntu系统的简介、安装之详细攻略
Win:Win系统下安装Linux的Ubuntu系统的简介、安装之详细攻略
Win:Win系统下安装Linux的Ubuntu系统的简介、安装之详细攻略
|
Ubuntu Unix 开发工具
Windows10内置ubuntu子系统安装后中文环境设置
原文:Windows10内置ubuntu子系统安装后中文环境设置 第一开启相关设置,使用小娜(Win键+c)直接查找关键字打开更快。
3467 0
|
Ubuntu Linux Windows
Windows安装Linux子系统--安装GUI界面
原文:Windows安装Linux子系统--安装GUI界面  前段时间发现Windows可以安装Linux子系统了,恰逢电脑换了固态,还没装Linux,不如趁机体验一番! 1、准备工作 1.1、打开Windows的子系统功能 1.2、打开Windows开发人员模式 打开设置–>更新和安全–>针对开发人员,选择开发人员模式–>确定  确认后,重启电脑,系统更新配置。
3919 0