通过WSL在Windows下安装子Linux系统
一、开启开发者模式
步骤: -> 系统设置 -> 更新和安全 -> 针对开发人员 -> 选择开发者模式
点击后会自动安装环境
二、启用WSL
步骤: -> 系统设置 -> 应用 -> 右侧的程序和功能 -> 启动或关闭windows功能 -> 勾选适用于 Linux 的 Windows 子系统
确定后,重启电脑,系统更新配置
三、安装 Linux 子系统
打开 Windows 商店,输入 Ubuntu 搜索,选择你自己想要的系统版本,我选择的是 Ubuntu 18.04。然后点击安装,第一次启动会进行初始化安装。
管理员控制台,属性,关闭使用旧版控制台
使用bash命令进入linux子系统
默认的子系统的路径:
C:\Users\qhong\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc\LocalState\rootfs
查看系统版本:
root@hongda:/# cat etc/os-release NAME="Ubuntu" VERSION="18.04 LTS (Bionic Beaver)" ID=ubuntu ID_LIKE=debian PRETTY_NAME="Ubuntu 18.04 LTS" VERSION_ID="18.04" HOME_URL="https://www.ubuntu.com/" SUPPORT_URL="https://help.ubuntu.com/" BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/" PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy" VERSION_CODENAME=bionic UBUNTU_CODENAME=bionic
通过passwd设置密码:
root@hongda:/# passwd Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully
如果su进入root账户,密码错误,需要设置root账户的密码:
$ sudo passwd root Enter new UNIX password: //此时输入你的密码 Retype new UNIX password: //再次输入,相同密码。 passwd: password updated successfully
更换ubuntu的数据源:
# 1.备份原来的数据源配置文件 cp /etc/apt/sources.list /etc/apt/sources.list_backup # 2.编辑数据源配置文件 vi /etc/apt/sources.list
替换:
deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse deb https://mirrors.ustc.edu.cn/ubuntu/ xenial main restricted universe multiverse deb https://mirrors.ustc.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse deb https://mirrors.ustc.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse deb https://mirrors.ustc.edu.cn/ubuntu/ xenial-security main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
更新配置:
# 3.更新配置 apt-get update
参考:
https://www.jianshu.com/p/bc38ed12da1d
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(1)