mowatermelon / learn-es6

一个有趣的人写的有趣的前端基础
http://blog.iiwhy.cn/learn-es6
7 stars 5 forks source link

win10下开启ubuntu子系统 #51

Open mowatermelon opened 6 years ago

mowatermelon commented 6 years ago

文章参考 https://www.jianshu.com/p/6d6e629df051

开启功能

检验是否开启成功

$ bash
melon@MicroWin10-0003:/mnt/c/Users/Administrator$ cd F:\documentBak\learn\vim
-bash: cd: F:documentBaklearnvim: 没有那个文件或目录 # \ 被直接转译了
melon@MicroWin10-0003:/mnt/c/Users/Administrator$ cd F:/documentBak/learn/vim
-bash: cd: F:/documentBak/learn/vim: 没有那个文件或目录
melon@MicroWin10-0003:/mnt/c/Users/Administrator$ cd F:
-bash: cd: F:: 没有那个文件或目录
melon@MicroWin10-0003:/mnt/c/Users/Administrator$ cd ../../../
melon@MicroWin10-0003:/mnt$ ll
总用量 0
drwxr-xr-x 1 root  root  4096 8月  19 16:40 ./
drwxr-xr-x 1 root  root  4096 8月  19 16:40 ../
drwxrwxrwx 1 melon melon 4096 8月   1 02:21 c/
drwxrwxrwx 1 melon melon 4096 8月   1 02:21 e/
drwxrwxrwx 1 melon melon 4096 8月   1 02:21 f/
drwxrwxrwx 1 melon melon 4096 8月  19 15:54 g/
drwxrwxrwx 1 melon melon 4096 8月   1 02:21 m/
melon@MicroWin10-0003:/mnt$ cd f/documentBak/learn/vim/
melon@MicroWin10-0003:/mnt/f/documentBak/learn/vim$ ll
总用量 16
drwxrwxrwx 1 melon melon 4096 8月  19 22:02 ./
drwxrwxrwx 1 melon melon 4096 8月  19 16:46 ../
-rwxrwxrwx 1 melon melon 4914 8月  19 21:43 help.md*
-rwxrwxrwx 1 melon melon 5128 8月  19 20:25 shortcut.md*
-rwxrwxrwx 1 melon melon  267 8月  19 22:03 win10_help.md*

安装ubuntu子系统

中间有一个插曲,我开启功能之后,第一遍重启,电脑中的应用商店一直打不开,然后重新重启了一遍就好了。

直接进入win10应用商店,搜索ubuntu选择最新的版本进行安装就可以了,截至到2018/08/19,这边Ubuntu的最新版是18.4,这边直接点击安装就可以了。

安装的时候,这边会自动出现一个终端,安装完成之后,这边会提示需要创建一个UNIX user account,创建完账户和设置密码之后,就可以玩系统了

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: melon
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>".
See "man sudo_root" for details.

修改ubuntu子系统镜像

$ cd /etc/apt # 进入对应文件夹

$ sudo cp sources.list sources.list.bak # 备份文件

$ sudo chmod 777 sources.list # 修改对应文件权限

$ sudo vim sources.list # 打开文件

# 进入文件夹中之后,这边有很多源配置。
# 在普通模式下,按下G,跳到文件最后一行。
# 然后再输入`:1,.d`,删除全部内容,`.`当前行 ,`1,.`表示从第一行到当前行 ,`d`删除。
# 或者在正常模式下 直接输入 ggdG,就可以清空当前文件了 
# 按下`i`,进入编辑模式,将下面配置输入到文件中。
# 注意deb和deb-src的配置各有五个,分别是`trusty`,`trusty-security`,`trusty-updates`,`trusty-proposed`和`trusty-backports`。

# 阿里云
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

# 然后按Esc键退出编辑模式,再输入`:wq`保存所写内容并退出

更新ubuntu源

$ sudo apt-get update
Ign:1 http://mirrors.aliyun.com/ubuntu trusty InRelease
Get:2 http://mirrors.aliyun.com/ubuntu trusty-security InRelease [65.9 kB]
Get:3 http://mirrors.aliyun.com/ubuntu trusty-updates InRelease [65.9 kB]
Get:4 http://mirrors.aliyun.com/ubuntu trusty-proposed InRelease [65.9 kB]
Get:5 http://mirrors.aliyun.com/ubuntu trusty-backports InRelease [65.9 kB]
Ign:6 http://mirrors.aliyun.com/ubuncput trusty InRelease
Get:7 http://mirrors.aliyun.com/ubuntu trusty Release [58.5 kB]
Err:8 http://mirrors.aliyun.com/ubuncput trusty Release
  404  Not Found [IP: 101.89.125.213 80]
Get:9 http://mirrors.aliyun.com/ubuntu trusty Release.gpg [933 B]
Get:10 http://mirrors.aliyun.com/ubuntu trusty-security/restricted Sources [4931 B]
Get:11 http://mirrors.aliyun.com/ubuntu trusty-security/main Sources [161 kB]
Get:12 http://mirrors.aliyun.com/ubuntu trusty-security/multiverse Sources [3260 B]
Get:13 http://mirrors.aliyun.com/ubuntu trusty-security/universe Sources [78.4 kB]
Get:14 http://mirrors.aliyun.com/ubuntu trusty-security/main amd64 Packages [760 kB]
Get:15 http://mirrors.aliyun.com/ubuntu trusty-security/main Translation-en [411 kB]
Get:16 http://mirrors.aliyun.com/ubuntu trusty-security/restricted amd64 Packages [14.2 kB]
Get:17 http://mirrors.aliyun.com/ubuntu trusty-security/restricted Translation-en [3556 B]
Get:18 http://mirrors.aliyun.com/ubuntu trusty-security/universe amd64 Packages [242 kB]
Get:19 http://mirrors.aliyun.com/ubuntu trusty-security/universe Translation-en [132 kB]
Get:20 http://mirrors.aliyun.com/ubuntu trusty-security/multiverse amd64 Packages [4806 B]
Get:21 http://mirrors.aliyun.com/ubuntu trusty-security/multiverse Translation-en [2564 B]
Get:22 http://mirrors.aliyun.com/ubuntu trusty-updates/multiverse Sources [7441 B]
Get:23 http://mirrors.aliyun.com/ubuntu trusty-updates/restricted Sources [6322 B]
Get:24 http://mirrors.aliyun.com/ubuntu trusty-updates/universe Sources [206 kB]
Get:25 http://mirrors.aliyun.com/ubuntu trusty-updates/main Sources [420 kB]
Get:26 http://mirrors.aliyun.com/ubuntu trusty-updates/main amd64 Packages [1098 kB]
Get:27 http://mirrors.aliyun.com/ubuntu trusty-updates/main Translation-en [544 kB]
Get:28 http://mirrors.aliyun.com/ubuntu trusty-updates/restricted amd64 Packages [17.2 kB]
Get:29 http://mirrors.aliyun.com/ubuntu trusty-updates/restricted Translation-en [4021 B]
Get:30 http://mirrors.aliyun.com/ubuntu trusty-updates/universe amd64 Packages [469 kB]
Get:31 http://mirrors.aliyun.com/ubuntu trusty-updates/universe Translation-en [252 kB]
Get:32 http://mirrors.aliyun.com/ubuntu trusty-updates/multiverse amd64 Packages [14.6 kB]
Get:33 http://mirrors.aliyun.com/ubuntu trusty-updates/multiverse Translation-en [7616 B]
Get:34 http://mirrors.aliyun.com/ubuntu trusty-proposed/universe Sources [17.0 kB]
Get:35 http://mirrors.aliyun.com/ubuntu trusty-proposed/restricted Sources [783 B]
Get:36 http://mirrors.aliyun.com/ubuntu trusty-proposed/main Sources [8978 B]
Get:37 http://mirrors.aliyun.com/ubuntu trusty-proposed/main amd64 Packages [23.7 kB]
Get:38 http://mirrors.aliyun.com/ubuntu trusty-proposed/main Translation-en [15.5 kB]
Get:39 http://mirrors.aliyun.com/ubuntu trusty-proposed/restricted amd64 Packages [774 B]
Get:40 http://mirrors.aliyun.com/ubuntu trusty-proposed/restricted Translation-en [281 B]
Get:41 http://mirrors.aliyun.com/ubuntu trusty-proposed/universe amd64 Packages [13.2 kB]
Get:42 http://mirrors.aliyun.com/ubuntu trusty-proposed/universe Translation-en [12.1 kB]
Get:43 http://mirrors.aliyun.com/ubuntu trusty-backports/universe Sources [35.4 kB]
Get:44 http://mirrors.aliyun.com/ubuntu trusty-backports/main Sources [9709 B]
Get:45 http://mirrors.aliyun.com/ubuntu trusty-backports/multiverse Sources [1896 B]
Get:46 http://mirrors.aliyun.com/ubuntu trusty-backports/main amd64 Packages [13.3 kB]
Get:47 http://mirrors.aliyun.com/ubuntu trusty-backports/main Translation-en [7503 B]
Get:48 http://mirrors.aliyun.com/ubuntu trusty-backports/universe amd64 Packages [43.1 kB]
Get:49 http://mirrors.aliyun.com/ubuntu trusty-backports/universe Translation-en [36.8 kB]
Get:50 http://mirrors.aliyun.com/ubuntu trusty-backports/multiverse amd64 Packages [1567 B]
Get:51 http://mirrors.aliyun.com/ubuntu trusty-backports/multiverse Translation-en [1215 B]
Get:52 http://mirrors.aliyun.com/ubuntu trusty/main amd64 Packages [1350 kB]
Get:53 http://mirrors.aliyun.com/ubuntu trusty/restricted amd64 Packages [13.0 kB]
Get:54 http://mirrors.aliyun.com/ubuntu trusty/universe amd64 Packages [5859 kB]
Get:55 http://mirrors.aliyun.com/ubuntu trusty/multiverse amd64 Packages [132 kB]
Reading package lists... Done
E: The repository 'http://mirrors.aliyun.com/ubuncput trusty Release' does not have a Release file.
N: Updating from such a repository can’t be done securely, and is therefore disableE: Invalid operation updrade

设置ubuntu语言

概要

$ sudo apt install -y language-pack-zh-hans language-
pack-zh-hans-base # 下载相关语言包
$ echo "LANG=zh_CN.UTF-8" >> ~/.profile # 设置系统语言为中文

全部内容

$ sudo apt install -y language-pack-zh-hans language-
pack-zh-hans-base
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following package was automatically installed and is no longer required:
  libfreetype6
Use 'sudo apt autoremove' to remove it.
The following NEW packages will be installed:
  language-pack-zh-hans language-pack-zh-hans-base
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 1950 kB of archives.
After this operation, 7762 kB of additional disk space will be used.
Get:1 http://mirrors.aliyun.com/ubuntu trusty-updates/main amd64 language-pack-zh-h
Unpacking language-pack-zh-hans-base (1:14.04+20160720) ...
Selecting previously unselected package language-pack-zh-hans.
Preparing to unpack .../language-pack-zh-hans_1%3a14.04+20160720_all.deb ......]
Unpacking language-pack-zh-hans (1:14.04+20160720) ...
Setting up language-pack-zh-hans (1:14.04+20160720) ...
Setting up language-pack-zh-hans-base (1:14.04+20160720) ...
Generating locales (this might take a while)...
  zh_CN.UTF-8... done
  zh_SG.UTF-8... done
Generation complete.

$ echo "LANG=zh_CN.UTF-8" >> ~/.profile

修改当前用户权限

21行是本次新增的内容,即给melon用户授予sudo权限

$ sudo su # 切换到root用户
$ vi /etc/sudoers # 编辑相关文件

     1  #
     2  # This file MUST be edited with the 'visudo' command as root.
     3  #
     4  # Please consider adding local content in /etc/sudoers.d/ instead of
     5  # directly modifying this file.
     6  #
     7  # See the man page for details on how to write a sudoers file.
     8  #
     9  Defaults        env_reset
    10  Defaults        mail_badpass
    11  Defaults        secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"
    12
    13  # Host alias specification
    14
    15  # User alias specification
    16
    17  # Cmnd alias specification
    18
    19  # User privilege specification
    20  root    ALL=(ALL:ALL) ALL
    21  melon   ALL=(ALL:ALL) ALL
    22
    23  # Members of the admin group may gain root privileges
    24  %admin ALL=(ALL) ALL
    25
    26  # Allow members of group sudo to execute any command
    27  %sudo   ALL=(ALL:ALL) ALL
    28
    29  # See sudoers(5) for more information on "#include" directives:
    30
    31  #includedir /etc/sudoers.d

安装常用应用

$ sudo su # 进入管理员模式

$ apt install tree # 安装tree应用,方便以树结构递归查看文件夹结构
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following package was automatically installed and is no longer required:
  libfreetype6
Use 'sudo apt autoremove' to remove it.
The following NEW packages will be installed:
  tree
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 37.8 kB of archives.
After this operation, 109 kB of additional disk space will be used.
Get:1 http://mirrors.aliyun.com/ubuntu trusty/universe amd64 tree amd64 1.6.0-1 [37
.8 kB]
Fetched 37.8 kB in 0s (238 kB/s)
Selecting previously unselected package tree.
(Reading database ... 28726 files and directories currently installed.)
Preparing to unpack .../tree_1.6.0-1_amd64.deb ...
Unpacking tree (1.6.0-1) ...
Setting up tree (1.6.0-1) ...
Processing triggers for man-db (2.8.3-2) ...
mowatermelon commented 6 years ago

其他尝试

检测python环境

$ whereis python #查看本地python的配置
python: /usr/bin/python3.6 /usr/bin/python3.6m /usr/lib/python2.7 /usr/lib/python3.6 /usr/lib/python3.7 /etc/python3.6 /usr/local/lib/python3.6 /usr/share/python

$ python3 -V # 查看python版本
Python 3.6.5

$ python3 # 进入python编辑状态
Python 3.6.5 (default, Apr  1 2018, 05:46:30)
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> quit()

安装gnome桌面

$ sudo apt-get install gnome
[sudo] password for melon:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 gnome : Depends: gnome-core (= 1:3.8+4ubuntu3) but it is not going to be installed
         Depends: network-manager-gnome (>= 0.9.4) but it is not going to be installed
         Depends: gedit (>= 3.4) but it is not going to be installed
         Depends: gnome-color-manager (>= 3.4) but it is not going to be installed
         Depends: gnome-documents (>= 0.4) but it is not going to be installed
         Depends: gnome-games (>= 1:3.4) but it is not going to be installed
         Depends: nautilus-sendto (>= 3.0) but it is not going to be installed
         Depends: gnome-orca (>= 3.4) but it is not going to be installed
         Depends: seahorse (>= 3.4) but it is not going to be installed
         Depends: totem (>= 3.0) but it is not going to be installed
         Depends: alacarte (>= 0.13.4) but it is not going to be installed
         Depends: avahi-daemon but it is not going to be installed
         Depends: gnome-tweak-tool (>= 3.4) but it is not going to be installed
         Depends: libreoffice-gnome but it is not going to be installed
         Depends: libreoffice-impress but it is not going to be installed
         Depends: rhythmbox (>= 2.96) but it is not going to be installed
         Depends: tomboy (>= 1.10) but it is not going to be installed or
                  gnote but it is not going to be installed
         Depends: gedit-plugins (>= 3.4) but it is not going to be installed
         Depends: gnome-applets (>= 3.4) but it is not going to be installed
         Depends: gnome-shell-extensions (>= 3.4) but it is not going to be installed
         Depends: rhythmbox-plugins but it is not going to be installed
         Depends: rhythmbox-plugin-cdrecorder but it is not going to be installed
         Depends: telepathy-salut but it is not going to be installed
         Depends: totem-plugins but it is not going to be installed
         Depends: libgtk2-perl (>= 1:1.130) but it is not going to be installed
         Recommends: gdebi but it is not going to be installed
E: Unable to correct problems, you have held broken packages.