Welcome 微信登录

首页 / 操作系统 / Linux / Windows 10预览版14316开启Linux Bash命令行

Windows 10预览版14316中已经提供bash组件,默认关闭的,启用的方法是先选中“开始->设置->更新和安全->针对开发人员->开发人员模式”,然后按 Win+X,F 打开“程序和功能”,点击左侧的“启用或关闭Windows功能”,然后找到并勾选 Windows Subsystem for Linux (Beta) ,确定后会提示重启启动系统。系统重启完成后,按 Win+X,A 打开命令提示符(或者按 Win+R 打开运行对话框),输入 bash 回车,第一次运行会从网上下载Ubuntu linux组件,按提示输入y。-- Beta feature --This will install Ubuntu on Windows, distributed by Canonicaland licensed under its terms available here:https://aka.ms/uowtermsType "y" to continue: yDownloading from the Windows Store... 100%Extracting filesystem, this will take a few minutes...????! ???????...root@localhost:~#查看版本信息和分区映射:root@localhost:~# uname -aLinux localhost 3.4.0+ #1 PREEMPT Thu Aug 1 17:06:05 CST 2013 x86_64 x86_64 x86_64 GNU/Linuxroot@localhost:~# cat /etc/issueUbuntu 14.04.4 LTS lroot@localhost:~# ls -al /mnttotal 24drwxrwxr-x 2 root 1000 0 Apr7 07:22 .drwxrwxr-x 2 root root 0 Apr7 07:22 ..drwxrwxrwx 2 root root 0 Apr7 06:58 cdrwxrwxrwx 2 root root 0 Apr7 04:59 droot@localhost:~# sudo ls /devadss fb0kmsgptmxrandomtty urandomblockinputnullpts shm tty0zeroroot@localhost:~#注意是root用户,/dev 下也没有很多的设备,输入 exit 可退出bash。 /root 目录对应Windows系统的 %localappdata%lxss oot 文件夹(注意,不要删除lxss目录,bash会失败)。
如果不幸删除了lxss或者其他原因 bash 启动失败。可以在CMD里用下面两条命令卸载再重新安装:echo y|lxrun /uninstallecho y|lxrun /install更新linux子系统,在CMD里运行:lxrun /update// 更新linux子系统// - 或者 -lxrun /update /critical// 只更新关键更新,更新完成后会强制关闭linux进程
使用命令 apt-get 安装软件前建议先在 /etc/apt/sources.list 文件前端添加国内的镜像服务器, http://mirrors.163.com/ubuntu 是163的镜像源:deb http://mirrors.163.com/ubuntu trusty main restricted universe multiversedeb http://mirrors.163.com/ubuntu trusty-upadates main restricted universe multiversedeb http://mirrors.163.com/ubuntu trusty-security main restricted universe multiverse
可用vi编辑:vi /etc/apt/sources.list按3yy复制原来的3行,按Shift+G到结尾,按p粘贴。输入 :1,3s/w*.ubuntu/mirrors.163/ 替换前3行为163的镜像,Shift+ZZ保存退出。
然后用 apt-get update 命令更新源(163的更新源最后会出现一些校验警告,可以忽略)。安装 git: apt-get --assume-yes install git--assume-yes可选:安装交互全部yes。删除用remove替换install。自动移除:apt-get autoremove查询7z软件:apt-cache search 7z----下面是安装swift编译环境的例子(未成功):1. 安装 CLang 和 libicu-devapt-get install clang libicu-dev2. 下载swift发行包(到swift.org里找ubuntu14.04平台的版本,目前DEV快照是Swift 3.0预览版本)curl -O https://swift.org/builds/development/ubuntu1404/swift-DEVELOPMENT-SNAPSHOT-2016-03-24-a/swift-DEVELOPMENT-SNAPSHOT-2016-03-24-a-ubuntu14.04.tar.gz注:可以先在Windows系统中用下载工具下载好,然后用touch命令在linux文件系统里先创建个同名的文件root@localhost:~# touch swift-DEVELOPMENT-SNAPSHOT-2016-03-24-a-ubuntu14.04.tar.gz然后再用Windows进行文件复制,覆盖到 %localappdata%lxss oot 文件夹里。3. 解压tar.gz包。tar xzf swift-DEVELOPMENT-SNAPSHOT-2016-03-24-a-ubuntu14.04.tar.gz如果产生了如下错误:root@localhost:~# tar zxf swift-DEVELOPMENT-SNAPSHOT-2016-03-24-a-ubuntu14.04.tar.gztar: swift-DEVELOPMENT-SNAPSHOT-2016-03-24-a-ubuntu14.04/usr/bin/swift-autolink-extract: Cannot create symlink to ‘swift’: Invalid argumenttar: swift-DEVELOPMENT-SNAPSHOT-2016-03-24-a-ubuntu14.04/usr/bin/swiftc: Cannot create symlink to ‘swift’: Invalid argumenttar: swift-DEVELOPMENT-SNAPSHOT-2016-03-24-a-ubuntu14.04/usr/bin/lldb-server: Cannot create symlink to ‘lldb-server-3.9.0’: Invalid argumenttar: swift-DEVELOPMENT-SNAPSHOT-2016-03-24-a-ubuntu14.04/usr/bin/lldb: Cannot create symlink to ‘lldb-3.9.0’: Invalid argumenttar: swift-DEVELOPMENT-SNAPSHOT-2016-03-24-a-ubuntu14.04/usr/bin/lldb-mi: Cannot create symlink to ‘lldb-mi-3.9.0’: Invalid argumenttar: swift-DEVELOPMENT-SNAPSHOT-2016-03-24-a-ubuntu14.04/usr/lib/liblldb.so: Cannot create symlink to ‘liblldb.so.3.9.0’: Invalid argumenttar: swift-DEVELOPMENT-SNAPSHOT-2016-03-24-a-ubuntu14.04/usr/lib/python2.7/site-packages/lldb/_lldb.so: Cannot create symlink to ‘../../../../lib/liblldb.so’: Invalid argumenttar: swift-DEVELOPMENT-SNAPSHOT-2016-03-24-a-ubuntu14.04/usr/lib/python2.7/site-packages/lldb/lldb-argdumper: Cannot create symlink to ‘../../../../bin/lldb-argdumper’: Invalid argumenttar: Exiting with failure status due to previous errors改用7z来解压,设置可执行权限。rm -rf swift-DEVELOPMENT-SNAPSHOT-2016-03-24-a-ubuntu14.04apt-get install p7zip-full7z x swift-DEVELOPMENT-SNAPSHOT-2016-03-24-a-ubuntu14.04.tar.gz7z x swift-DEVELOPMENT-SNAPSHOT-2016-03-24-a-ubuntu14.04.tarrm swift-DEVELOPMENT-SNAPSHOT-2016-03-24-a-ubuntu14.04.tarchmod +x /root/swift-DEVELOPMENT-SNAPSHOT-2016-03-24-a-ubuntu14.04/usr/bin/* 4. 配置环境变量,编辑 ~/.bashrc 文件,结尾加入export PATH=/root/swift-DEVELOPMENT-SNAPSHOT-2016-03-24-a-ubuntu14.04/usr/bin:"${PATH}"5. 重新载入配置,查看结果:root@localhost:~# source ~/.bashrcroot@localhost:~# swift --versionSwift version 3.0-dev (LLVM b010debd0e, Clang 3e4d01d89b, Swift 7182c58cb2)Target: x86_64-unknown-linux-gnuroot@localhost:~#6. 目前仍不能进入REPL环境或者编译swift文件。编译错误:<unknown>:0: error: could not load the swift standard library在Windows 10上用Bash运行有图形用户界面Ubuntu应用  http://www.linuxidc.com/Linux/2016-04/130125.htmWindows 10上使用Bash on Ubuntu  http://www.linuxidc.com/Linux/2016-04/130016.htm本文永久更新链接地址