ICode9

精准搜索请尝试: 精确搜索
首页 > 系统相关> 文章详细

Windows10上使用Linux子系统(WSL)

2019-06-29 20:55:21  阅读:356  来源: 互联网

标签:Ubuntu Windows10 WSL 169.125 ms Linux root 61.135


Windows10上使用Linux子系统(WSL)

Linux的Windows子系统让开发人员可以直接在Windows上运行Linux环境(包括大多数命令行工具,实用程序和应用程序),而无需建立在虚拟机的开销之上,整个系统共200多M,但包含了你能用到的所有功能,并且和windows完美互操作(省去Linux挂载本地windows分区或目录的操作),目前Linux的windows子系统已经相当完善,可当作完整linux系统使用.

您可以使用以下功能:

  1. 从Windows应用商店中选择您最喜爱的Linux发行版。
  2. 运行常用的命令行实用程序,如grepsedawk等。
  3. 运行Bash shell脚本和Linux命令行应用程序,包括:
    • 工具:vim,emacs,tmux, nmap, df -h, ifconfig, top
    • 语言:Javascript / node.js,Ruby,Python,C / C ++,C#和F#,Rust,Go等
    • 服务:sshd,MySQL,Apache,Nginx, lighttpd
  4. 使用发行版的内置包管理器(apt-get)安装其他Linux工具。
  5. 从Linux控制台调用Windows应用程序。
  6. 在Windows上调用Linux应用程序。

windows文件和Linux文件的位置

要是想在Ubuntu里查看windows分区里面的文件 可以在 /mnt 里面查看 要是想在windows里面查看Ubuntu里面的文件,在我电脑上位置是:
C:\Users\Administrator\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState\rootfs

Linux根目录文件位置

安装过程中遇到的一些坑

错误代码是0x8007007e的小伙伴看这里

1、打开 [控制面板]
2、找到 [程序与功能] 处的 [启用或关闭windows功能]
3、在 [适用于linux的windows子系统] 一栏处打上勾
4、点击确定并重启电脑
注:以上步骤在win10专业版上测试,win10家庭版可能不支持

安装Windows的Linux子系统

使用快捷键微软光标键)微软光标键+S 搜索 “功能”

打开功能

在这里插入图片描述

或者直接PowerShell中运行以下命令

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

出现提示重新启动计算机

安装Linux

  1. 打开应用商店,
    在这里插入图片描述
  2. 在应用商店搜索“Linux”,选择您喜欢的Linux版本,推荐安装Ubuntu
    在这里插入图片描述
  3. 获取这些应用在这里插入图片描述

注意:应用商店的程序使用默认路径,不要更换到其他盘符

  1. 开发者推荐安装Ubuntu
    在这里插入图片描述

安装完毕后开始菜单出现Ubuntu图标在这里插入图片描述

  1. 或者再应用商店里直接启动Ubuntu
    在这里插入图片描述

现在可以在里面进行任何和Linux相关的命令

进入Ubuntu系统之后自动初始化并安装,稍等几分钟即可

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: # 输入你的Ubuntu系统用户名
Enter new UNIX password: # 输入你的密码
Retype new UNIX password: # 再次输入你的密码
passwd: password updated successfully # 提示密码更新成功
Installation successful! # 系统安装成功
To run a command as administrator (user "root"), use "sudo <command>". # 切换到root用户
See "man sudo_root" for details. # sudo命令帮助

输入Linux命令测试

alan@Alan:~$ sudo su - root
[sudo] password for alan:
root@Alan:~# whoami
root
root@Alan:~# pwd
/root
root@Alan:~# ll
total 4
drwx------ 1 root root  512 May 21 22:42 ./
drwxr-xr-x 1 root root  512 Jun 29 19:46 ../
-rw-r--r-- 1 root root 3106 Apr  9  2018 .bashrc
-rw-r--r-- 1 root root  148 Aug 17  2015 .profile
root@Alan:~# ping www.baidu.com
PING www.a.shifen.com (61.135.169.125) 56(84) bytes of data.
64 bytes from 61.135.169.125 (61.135.169.125): icmp_seq=1 ttl=63 time=5.79 ms
64 bytes from 61.135.169.125 (61.135.169.125): icmp_seq=2 ttl=63 time=5.27 ms
64 bytes from 61.135.169.125 (61.135.169.125): icmp_seq=3 ttl=63 time=5.28 ms
64 bytes from 61.135.169.125 (61.135.169.125): icmp_seq=4 ttl=63 time=5.54 ms
64 bytes from 61.135.169.125 (61.135.169.125): icmp_seq=5 ttl=63 time=7.16 ms
64 bytes from 61.135.169.125 (61.135.169.125): icmp_seq=6 ttl=63 time=5.10 ms
^C
--- www.a.shifen.com ping statistics ---
6 packets transmitted, 6 received, 0% packet loss, time 5015ms
rtt min/avg/max/mdev = 5.107/5.694/7.161/0.695 ms

Enjoy !

切记:小心执行 mkdir -rf mnt

标签:Ubuntu,Windows10,WSL,169.125,ms,Linux,root,61.135
来源: https://blog.csdn.net/qq_44741291/article/details/94202043

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有