目录

WSL 环境配置

记录 WSL 环境的配置过程。

  1. 打开 启用或关闭 Windows 功能,勾选 适用于 Linux 的 Windows 子系统虚拟机平台Hyper-V,点击确定并重启电脑。

  2. 打开 PowerShell (管理员权限),执行以下命令安装 WSL 和 Debian 发行版:

    wsl --update
    wsl --set-default-version 2
    wsl --install -d Debian
  3. 配置 Debian 用户名和密码。

  1. 关闭 WSL:

    wsl --shutdown
  2. 直接移动:

    wsl --manage Debian --move <新路径>
  1. 更新软件包列表并升级已安装的软件包:

    sudo apt update && sudo apt upgrade -y
  2. 美化终端:

    sudo apt install -y zsh git wget
    sh -c "$(wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"
    git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
    git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

    修改 ~/.zshrc,添加插件:

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

    重启终端或执行 source ~/.zshrc

  1. 修改系统语言为中文:

    sudo apt install locales
    sudo dpkg-reconfigure locales

    按向下键选择 zh_CN.UTF-8,按空格键选中,回车确认;选择 zh_CN.UTF-8 作为默认语言,回车确认。

  2. 安装中文字体:

    sudo apt install -y fonts-wqy-zenhei fonts-wqy-microhei
  1. 安装 XFCE4 桌面环境:

    sudo apt install -y xfce4
    注意
    执行上述命令后,仅支持窗口级 GUI,不支持完整桌面环境。
  1. 安装 VS Code,并安装 WSL 插件。

  2. 在 WSL 终端中:

    code .
  1. 关闭 WSL:

    wsl --shutdown
  2. 执行:

    diskpart
  3. 在 diskpart 提示符下,执行以下命令:

    select vdisk file=<WSL 虚拟磁盘路径>
    compact vdisk
  1. 添加环境变量:

    nano ~/.zshrc

    在其中添加:

    export DOTNET_CLI_TELEMETRY_OPTOUT=1
  2. https://learn.microsoft.com/zh-cn/dotnet/core/install/linux-debian