安装 Linuxbrew 和其他软件#

打开 WSL 终端#

安装完成后, 会自动弹出一个 WSL 终端. 你也可以通过 Win⊞-R 打开 运行, 填入 ubuntu回车 来启动终端.

备注

注意打开的窗口样式, 当输入命令后再次出现类似样式时, 说明命令执行完毕.

../../../_images/WSL_%E7%AA%97%E5%8F%A3%E6%A0%B7%E5%BC%8F.png

WSL 窗口样式#

备注

键入命令后, 如果显示以下内容, 则需要 输入刚刚设置的密码回车 以继续!

../../../_images/WSL_%E8%BE%93%E5%85%A5%E5%AF%86%E7%A0%81.png

输入用户密码#

安装系统必须软件#

配置镜像源#

提示

对于以下执行的命令块, 你应该依次执行, 对每个命令进行如下操作:

复制命令

通过 鼠标移到代码右上角 ‣ 点击出现的按钮 来复制命令.

粘贴命令到终端中

在窗口内 右键.

请勿使用 Control-V 进行粘贴! 如果习惯性按了, 请狂按几次 删除键.

执行命令

通过在窗口内 回车 执行命令, 当终端再次出现 终端刚打开时的窗口样式 时, 命令执行完毕.

如果命令停住不继续执行, 可能是因为这个命令需要你进行再次确认; 对于本教程而言, 狂敲几次 回车 即可.

如果实在卡住太长时间, 你可以 Ctrl-C 终止执行, 然后重新输入并执行命令.

确认完成命令

当终端再次出现 终端刚打开时的窗口样式 时, 命令执行完毕. 这时, 你可以执行下一条命令.

sudo sed -i 's@//.*archive.ubuntu.com@//mirrors.ustc.edu.cn@g' /etc/apt/sources.list

安装#

sudo apt update
sudo apt install build-essential procps curl file git libc++-dev libc++abi-dev curl zip unzip tar ninja-build

安装 Linuxbrew#

配置镜像源#

export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.ustc.edu.cn/brew.git"
export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.ustc.edu.cn/homebrew-core.git"
export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles"
export HOMEBREW_API_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles/api"
echo 'export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.ustc.edu.cn/brew.git"' >> ~/.bashrc
echo 'export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.ustc.edu.cn/homebrew-core.git"' >> ~/.bashrc
echo 'export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles"' >> ~/.bashrc
echo 'export HOMEBREW_API_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles/api"' >> ~/.bashrc
echo 'export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.ustc.edu.cn/brew.git"' >> ~/.bash_profile
echo 'export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.ustc.edu.cn/homebrew-core.git"' >> ~/.bash_profile
echo 'export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles"' >> ~/.bash_profile
echo 'export HOMEBREW_API_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles/api"' >> ~/.bash_profile
echo 'export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.ustc.edu.cn/brew.git"' >> ~/.zshrc
echo 'export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.ustc.edu.cn/homebrew-core.git"' >> ~/.zshrc
echo 'export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles"' >> ~/.zshrc
echo 'export HOMEBREW_API_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles/api"' >> ~/.zshrc
echo 'export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.ustc.edu.cn/brew.git"' >> ~/.zprofile
echo 'export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.ustc.edu.cn/homebrew-core.git"' >> ~/.zprofile
echo 'export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles"' >> ~/.zprofile
echo 'export HOMEBREW_API_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles/api"' >> ~/.zprofile
echo 'export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.ustc.edu.cn/brew.git"' >> ~/.profile
echo 'export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.ustc.edu.cn/homebrew-core.git"' >> ~/.profile
echo 'export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles"' >> ~/.profile
echo 'export HOMEBREW_API_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles/api"' >> ~/.profile

安装#

/bin/bash -c "$(curl -fsSL https://mirrors.ustc.edu.cn/misc/brew-install.sh)"

设置环境变量#

eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"' >> ~/.bashrc
echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"' >> ~/.bash_profile
echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"' >> ~/.zshrc
echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"' >> ~/.zprofile
echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"' >> ~/.profile

使用 Linuxbrew 安装其他软件#

brew install llvm cmake ninja git conan ccache dotnet@6