Windows下安装和配置WSL

百度百科描述WSL:Windows Subsystem for Linux(简称WSL)是一个在Windows 10上能够运行原生Linux二进制可执行文件(ELF格式)的兼容层。它是由微软与Canonical公司合作开发,其目标是使纯正的Ubuntu 14.04 "Trusty Tahr"映像能下载和解压到用户的本地计算机,并且映像内的工具和实用工具能在此子系统上原生运行。

1、启用或关闭Windows功能
Windows下安装和配置WSL_第1张图片

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
Windows下安装和配置WSL_第2张图片

错误解决办法:
1)在Windows“开始”处右键打开,选择Windows PowerShell管理员打开;
Windows下安装和配置WSL_第3张图片
输入下面命令后回车执行:

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

2)在设置–>更新和安全–>开发者选项处,将开发人员模式打开;
Windows下安装和配置WSL_第4张图片

完成后,重启电脑;

打开Ubuntu应用,
创建用户名跟密码:
Windows下安装和配置WSL_第5张图片

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

你可能感兴趣的:(Linux)