win10安装ubuntu子系统

转自:https://blog.csdn.net/u010606602/article/details/80782650

准备

  • win10最新系统,我这边当前能升级的最新版本为17134.112(因为swl是只有在win10系统下才有的)

安装WSL(Windows Subsystem for Linux) ubuntu系统

  • 网上的教程有很多,以下是我的安装过程: 
    • 升级当前win10为最新的系统,否则在“启用或关闭Windows功能”中会找不到“适用于Linux的Windows子系统”
    • 勾选安装wsl前提条件:控制面板=>程序和功能=>启用或关闭Windows功能=>勾选 适用于Linux的Windows子系统(当然也可以像网友提供的直接在管理员权限的windown power shell下执行: Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux) 
      安装wsl1
    • 做完以上步骤然后直接重启系统
    • 系统启动成功后打开运用商场(如果已经卸载了可以网上找下装回来),直接搜索wsl找到Ubuntu选个合适版本(我是直接选下载量大的那个)Ubuntu的安装过程不需要选择路径都是直接安装在c盘 
      这里写图片描述
    • 安装成功后打开应用,在系统的软件安装列表中能找到ubuntu的图标,可以打开它运行初始化工作,也可以通过在win+R或者cmd中输入wsl、bash、安装的系统名(这里是ubuntu)启动它 
      启动界面图
  • 配置调整过程: 
    • 第一次启动初始化工作:设置用户名、密码,成功登入后可以设置root密码,root默认是没有密码的直接sudo su即可进入root用户,然后通过sudo passwd root 设置root密码;
    • 在cmd或者power shell做常规设置(管理员权限运行), 
      • 设置bash、wsl启动的默认linux系统:wslconfig /setdefault [Linux_System_name(我这里是Ubuntu)]
      • 还有一些wslconfig的命令比如: 
        • 卸载:wslconfig /unregister [Linux_System_name(我这里是Ubuntu)
        • 查看已经安装的系统列表:wslconfig /list
      • 设置bash、wsl默认登入的用户(这个还有配合默认系统系统,我这边安装的ubuntu所以命令开头是ubuntu):ubuntu config --default-user root
  • 更换/etc/apt/sources.list的源提高安装下载速度这里我们网友提供的清华大学的源;备份/etc/apt/sources.list文件之后直接覆盖填写下面的源
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main multiverse restricted universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main multiverse restricted universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-proposed main multiverse restricted universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main multiverse restricted universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main multiverse restricted universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main multiverse restricted universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main multiverse restricted universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-proposed main multiverse restricted universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main multiverse restricted universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main multiverse restricted universe

#这里要注意下每条源中ubuntu/后面的 xenial是对应系统的版本代号,可以通过查看版本代号做相应调整
lsb_release -a  #查看当前系统的信息
Distributor ID: Ubuntu #类别是ubuntu
Description:    Ubuntu 16.04.4 LTS #16年4月2日发布的稳定版本,LTS是Long Term Support:长时间支持版本  三年 ,一般是18个月
Release:    16.04 #发行日期或者是发行版本号
Codename:   xenial #ubuntu的代号名称

  • wsl系统与windows系统的路面映射关系: 
    • windows系统在wsl中的路径都是挂载在/mnt下面 
      window与wsl的映射关系
    • wsl在windows10中的映射路径在(友情提示不要直接修改其内容):%localappdata%\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState\rootfs 
      这里写图片描述
  • 到此window下的wsl环境安装配置算告一段落了。

猜你喜欢

转载自blog.csdn.net/xieganyu3460/article/details/81490370