Windows安装WSL

Windows安装WSL

一月 31, 2021 本文共计: 484 字 预计阅读时长: 2分钟

Windows 安装 WSL

alt

详细教程

https://docs.microsoft.com/en-us/windows/wsl/install-win10

Install oh-my-zsh

Step 1

1
2
3
# update install source
$ sudo apt-get update
$ sudo apt-get upgrade

Step 2

1
2
# install zsh
$ sudo apt-get install zsh

Step 3

1
2
# set default shell
$ chsh -s $(which zsh)

Step 4

1
2
3
4
# install oh-my-zsh
$ sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
# or
$ sh -c "$(wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"

Step 5(安装 nvm

1
2
3
4
# install & update
$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
# or
$ wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
1
2
# setUp Path
$ vi ~/.zshrc
1
2
3
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
1
$ source ~/.zshrc

Step 6(重要提示)

完成了上述步骤,需要做最后一步,屏蔽windows的环境变量,使wslwindows独立环境。

1
$ vi ~/.zshrc
1
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
1
$ source ~/.zshrc

采坑指南

  1. 当你的 WSL抽风时,例如报错错误0x8000000d;

解决办法:

可以打开管理员(PowerShell),运行Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

如果没用!请重装系统,或者是重置 windows

  1. curl的时候报如下错误:

1> SSL certificate problem: unable to get local issuer certificate

2> curl:Failed to connect to raw.githubusercontent.com port 443: Connection refused

3> 404 not found

我们可以选用 ProxyChains 这个软件,能够使特定的命令走SOCKS5

  • Step 1
1
$ sudo apt install proxychains
  • Step 2
1
2
3
4
5
6
7
8
9
$ sudo vim /etc/proxychains.conf

###按i键进入vim的写入模式####

###将最后一行改成socks5 你的代理服务器IP 端口号###

# socks5 127.0.0.1 1080

###按下Esc后键入“:x”保存并退出vim编辑器###
  1. github clone 仓库很慢?

添加如下 host/etc/hosts;

1
2
3
4
5
# 199.232.68.133  raw.githubusercontent.com
# 199.232.68.133 user-images.githubusercontent.com
# 199.232.68.133 avatars2.githubusercontent.com
# 199.232.68.133 avatars1.githubusercontent.com
# 151.101.108.133 raw.github.com
1
$ sudo vi /etc/hosts
1
$ source /etc/hosts

alt