Windows使用Linux子系统

两种安装方法:

完成权限设置+命令行激活+cmd安装打开 
    

  1. 系统升级到一周年正式版及以上(1607)

  2. 依次在 设置 - 更新与安全 - 针对开发人员 选项中,启用"开发人员模式"

  3. 在资源管理器中打开 控制面板\所有控制面板项\程序和功能 , 打开 启用或关闭 Windows功能 , 勾选 适用于Linux的Windows子系统(Beta)

  4. 重启电脑

  5. 命令行运行 lxrun /install /y 开始安装
    安装速度取决于网络情况,下载的文件在 %localappdata%\lxss 目录下 lxss.tar.gz (181M),解压后大概500M, rootfs 目录即为子系统根目录。

  6. 命令行运行 bash 进入Ubuntu
    默认使用的 root 帐号登录,通过指令 passwd 设置密码。

  • 注:本文脚本均在root帐号下操作,因此建议使用root帐号
  1. 毕竟爱折腾,难免会把子系统环境(lxss目录)玩坏掉,因此干正事前最好先备份下以便快速还原。注意,不要直接右键复制或者打包,可能会导致文件权限丢失的。
    xcopy %localappdata%\lxss %localappdata%\lxss.bak /E
  2. 当然,如果你比较任性也可以不执行上一步的备份操作,通过命令行运行 lxrun /uninstall /full 轻松卸载子系统,重复上面的步骤即可重装,不过要注意下载速度时好时坏哦。


完成权限设置+命令行激活+应用商城安装 

在应用商店中搜索linux,选中箱安装的linux系统进行安装

(注意:安装路径必须是系统安装盘;在设置里修改过新内容保存路径的无效)


 

针对第一种安装方法,即只用命令行没有在windows应用商场安装Ubuntu的用户:这时,你的Linux子系统安装路径是:C:\Users\username\AppData\Local\lxss,注意,lxss是系统隐藏文件且是系统文件夹

针对第二种安装方法,在windows应用商场安装Ubuntu的用户: C:\Users\username\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc

 

Linux子系统迁移:

下载 LxRunOffline(点此下载


查看已经安装的子系统

LxRunOffline list

移动子系统到新的目录

LxRunOffline move -n Ubuntu-18.04 -d D:\Ubuntu.windows\installed\Ubuntu

查看子系统安装路径

lxrunoffline get-dir -n Ubuntu-18.04

安装一个子系统

LxRunOffline i -n Ubuntu-18.04 -d D:\Ubuntu.windows\installed\Ubuntu -s

注册一个子系统

LxRunOffline rg -n Ubuntu-18.04 -d D:\Ubuntu.windows\installed\Ubuntu

LxRunOffline使用说明

Supported actions are:
    l, list            List all installed distributions.
    gd, get-default    Get the default distribution, which is used by bash.exe.
    sd, set-default    Set the default distribution, which is used by bash.exe.
    i, install         Install a new distribution.
    ui, uninstall      Uninstall a distribution.
    rg, register       Register an existing installation directory.
    ur, unregister     Unregister a distribution but not delete the installation directory.
    m, move            Move a distribution to a new directory.
    d, duplicate       Duplicate an existing distribution in a new directory.
    e, export          Export a distribution's filesystem to a .tar.gz file, which can be imported by the "install" command.
    r, run             Run a command in a distribution.
    di, get-dir        Get the installation directory of a distribution.
    gv, get-version    Get the filesystem version of a distribution.
    ge, get-env        Get the default environment variables of a distribution.
    se, set-env        Set the default environment variables of a distribution.
    ae, add-env        Add to the default environment variables of a distribution.
    re, remove-env     Remove from the default environment variables of a distribution.
    gu, get-uid        Get the UID of the default user of a distribution.
    su, set-uid        Set the UID of the default user of a distribution.
    gk, get-kernelcmd  Get the default kernel command line of a distribution.
    sk, set-kernelcmd  Set the default kernel command line of a distribution.
    gf, get-flags      Get some flags of a distribution. See https://docs.microsoft.com/en-us/previous-versions/windows/desktop/api/wslapi/ne-wslapi-wsl_distribution_flags for details.
    sf, set-flags      Set some flags of a distribution. See https://docs.microsoft.com/en-us/previous-versions/windows/desktop/api/wslapi/ne-wslapi-wsl_distribution_flags for details.
    s, shortcut        Create a shortcut to launch a distribution.
    ec, export-config  Export configuration of a distribution to an XML file.
    ic, import-config  Import configuration of a distribution from an XML file.
    version            Get version information about this LxRunOffline.exe.

支持的操作包括:

l, list            列出所有已安装的分发版。
gd, get-default    获取bash.exe使用的默认分发。
sd, set-default    设置bash.exe使用的默认分发。
i, install         安装新的分发版。
ui, uninstall      卸载卸载一个分发。
rg, register       注册一个现有的安装目录。
ur, unregister     注销注销分发,但不删除安装目录。
m, move            将分发移动到新目录。
d, duplicate       复制复制新目录中的现有分发。
e, export          导出将分发的文件系统导出到.tar.gz文件,该文件可以通过“install”命令导入。而且。
r, run             在分发中运行一个命令。
di, get-dir        获取一个分发版的安装目录。
gv, get-version    获取分发版的文件系统版本。
ge, get-env        获取分布的默认环境变量。
se, set-env        设置分发的默认环境变量。
ae, add-env        添加到分发的默认环境变量中。
re, remove-env     从分发的默认环境变量中移除。
gu, get-uid        获取分发的默认用户的uid。
su, set-uid        设置分发的默认用户的uid。
gk, get-kernelcmd  获取分发的默认内核命令行。
sk, set-kernelcmd  设置分发的默认内核命令行。
gf, get-flags      得到一些分布的标志。有关详细信息,请参阅https://docs.microsoft.com/en-us/...
sf, set-flags      设置分发的一些标志。有关详细信息,请参阅https://docs.microsoft.com/en-us/...
s, shortcut        快捷方式创建启动分发的快捷方式。
ec, export-config  将分发的配置导出配置导出到XML文件。
ic, import-config  从XML文件导入分发的配置。
version            version获取有关此lxrunoffline.exe的版本信息。

 

使用阿里的镜像源:

# 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-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


 

  • 4
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值