Windows 配置 WSL (Ubuntu) 环境完整指南

1. 前言

Windows Subsystem for Linux (WSL) 允许开发者在 Windows 上直接运行 Linux 环境,无需双系统或虚拟机。本文将详细介绍在 Windows 10/11 上安装和配置 WSL 2 及 Ubuntu 发行版的完整步骤。

2. 系统要求

  • Windows 版本:Windows 10 版本 2004 及更高版本(内部版本 19041 及以上)或 Windows 11。
  • 虚拟化支持:确保 BIOS/UEFI 中已启用虚拟化技术(Intel VT-x 或 AMD-V)。
  • 存储空间:建议预留至少 10 GB 可用磁盘空间。

3. 启用 WSL 功能

首先,我们需要在 Windows 中启用 WSL 和虚拟机平台功能。

  1. Windows开始菜单右键点击"应用和功能" -> 右侧"程序和功能" -> "启用或关闭 Windows 功能"。
  2. 勾选"适用于 Linux 的 Windows 子系统"和"虚拟机平台"。
  3. 点击"确定"并重启计算机。

4. 安装 Ubuntu 发行版

4.1 通过 Microsoft Store 安装(推荐)

  1. 打开 Windows应用商店 Microsoft Store。
  2. 搜索"Ubuntu",点击获取并安装。

5. 首次启动与配置 Ubuntu

  1. 安装完成后,从开始菜单启动"Ubuntu"。
  2. 首次启动会进行解压,请耐心等待几分钟。
  3. 系统会提示你创建新的 UNIX 用户名和密码(此用户将拥有 sudo 权限)。
bash 复制代码
# 示例:首次启动后的配置过程
Installing, this may take a few minutes...
Please create a default UNIX user account. The username does not need to match your Windows username.
For more information visit: https://aka.ms/wslusers
Enter new UNIX username: yourusername
New password:
Retype new password:
passwd: password updated successfully
Installation successful!
相关推荐
懂点Tech1 天前
ctfshow misc28:GIF 高度修改解题与脚本实现
开发语言·windows·python
qq_401700411 天前
Linux设备树详解
linux·运维·服务器
云梦谭1 天前
让 Linux 主动连接 Windows:配置 Windows 11 SSH 服务端
linux·windows·ssh
奇树谦1 天前
Windows CMD 下 mc 运维指南:SeaweedFS 安装验收与 MinIO 数据迁移
运维·windows
刚入门的大一新生1 天前
Linux-信号
linux·运维·服务器
keren21 天前
SceneDock:Windows 场景化工作台——一键启动工作链,还能被 AI Agent 调用(CLI / MCP)
windows·开发工具·效率工具·mcp
GeW1 天前
新质生产力路线图解读:数据库性能优化与Linux调优专场
linux
mounter6251 天前
深入理解 gccrs:GCC 如何实现 Rust 编译器,以及编译 Linux 内核面临的挑战
linux·驱动开发·rust
垚垚学技术_聚焦云原生1 天前
Ansible Playbook 进阶:when 条件、loop 循环、handlers 触发器落地
linux·ansible·自动化运维·devops
无足鸟ICT1 天前
【RHCA+】type命令(判断命令类型)
linux·ssh·bash