Windows下安装和配置WSL

百度百科描述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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章