Windows 系统在 WSL 中安装 Debian。

安装 WSL

在 Windows 10 或 Windows 11 系统中,打开 Windows Terminal (终端),如果没安装 WSL,使用以下命令安装 WSL:

1
wsl.exe --install

如果失败就多试几次,期间可能会显示需要提权,点击“是”或“允许”。

如果开始下载了就耐心等待,可能比较慢,下载完会自动安装。

安装完成后,需要重启系统才能开始使用。

WSL 安装 Debian

重启系统以后,打开 Windows Terminal,输入以下命令开始安装 Debian:

1
wsl --install Debian

安装完成后,会要求输入系统的用户名,输入 debian 即可,接着设置密码。

输入完密码,按回车,会再次让确认密码,再输一次后按回车。

安装完成。

启动 Debian

打开 Windows Terminal,输入以下命令启动 Debian:

1
wsl -d Debian

配置 Debian 系统

截止 2026年4月17日,WSL 中的 Debian 版本是 13。

输入以下命令打开 apt 源配置:

1
nano /etc/apt/sources.list

把文件中的 deb.debian.org 替换为 mirrors.tuna.tsinghua.edu.cn

替换前:

1
2
3
4
deb http://deb.debian.org/debian trixie main
deb http://deb.debian.org/debian trixie-updates main
deb http://security.debian.org/debian-security trixie-security main
deb http://ftp.debian.org/debian trixie-backports main

替换后:

1
2
3
4
deb http://mirrors.tuna.tsinghua.edu.cn/debian trixie main
deb http://mirrors.tuna.tsinghua.edu.cn/debian trixie-updates main
deb http://security.debian.org/debian-security trixie-security main
deb http://mirrors.tuna.tsinghua.edu.cn/debian trixie-backports main

替换完成后,按 Ctrl + X,再按 Y 保存,再按回车,即可实现 “保存 + 退出” nano 编辑器。

执行如下命令更新源:

1
apt update

安装 CA 证书:

1
apt install ca-certificates

安装完 CA 证书后,就可以把 /etc/apt/sources.list 中清华源镜像改为 https

如下所示:

1
2
3
4
deb https://mirrors.tuna.tsinghua.edu.cn/debian trixie main
deb https://mirrors.tuna.tsinghua.edu.cn/debian trixie-updates main
deb http://security.debian.org/debian-security trixie-security main
deb https://mirrors.tuna.tsinghua.edu.cn/debian trixie-backports main

OK,初步配置完成,后续就可以愉快的玩耍了。