Win10安装子系统Ubuntu

1, 设置开发人员选项

设置/更新和安全/针对开发人员/勾选 开发人员模式

2, 修改系统设置

控制面板/程序/程序和功能/左侧 启用或关闭Windows功能/右侧勾选 适用于Linux的Windows子系统

重启系统

3, 应用商店安装ubuntu

不要选第一个,那个有坑

自己选择了 Ubuntu 18.04 LTS

微软商店下载Ubuntu, 选择第2个 或 第3个Unbtun LTS, 安装

4, 启动Ubuntu, 设置账号和密码

启动Ubuntu, 输入用户名和密码

这里的用户, 应该是指的是 普通用户, 而不是 root用户, 有时间, 再了解一下, 是的, 这里说的正确, 这里确实不是给root用户设置密码

给root用户设置密码

sudo passwd

会提示, 输入2次密码, 即可给root用户设置密码

5, 查看系统版本

#查看命令
lsb_release -a

# 输出下面的内容
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.5 LTS
Release:        18.04
Codename:       bionic

Distributor ID:类别是Ubuntu

Description::LTS是Long Term Support:长时间支持版本

Release::发行日期或者是发行版本号

Codename:ubuntu的代号名称

之所以有这一步, 是因为需要获取 Ubuntu 的 Codename 的名字, 需要替换到 下面阿里云源的 链接中

6, 更换为阿里云源

更换源的时候一定要更换对应的ubuntu版本的源, 否则某些依赖会安装不上

先备份原来的数据源配置文件

sudo cp /etc/apt/sources.list /etc/apt/sources.list_backup

会提示输入密码, 即可

编辑配置文件,使用阿里云的源地址,通过 vim 批量查找替换操作

sudo vim /etc/apt/sources.list

会提示输入密码, 即可

注释掉文件中的内容, 在末尾添加, 换成阿里源

deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

没有使用下面这个

网上有很多其他的博客写的换源,但是有些不全,写了之后会出很多奇怪的问题。我整理了一份可以用的:

deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse  
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse  
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse  
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse  
##测试版源  
deb http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse  
# 源码  
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse  
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse  
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse  
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse  
##测试版源  
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse  
# Canonical 合作伙伴和附加  
deb http://archive.canonical.com/ubuntu/ xenial partner  
deb http://extras.ubuntu.com/ubuntu/ xenial main  

8, 更新配置(更新源和软件)

执行第一条即可

sudo apt-get update
sudo apt-get update
sudo apt-get upgrade

9, Linux子系统与Windows的交互

可通过网络端口 和 文件系统来交互操作

在 bash 中通过指定 /mnt/c /mnt/d … /mnt/盘符 可以直接操作对应的Windows中的 C盘, D盘

好了,子系统安装完成,安装软件就没啥说的了,现在该装啥就装啥,跟平时操作 Linux 服务器基本上一样的啦。

需要注意的是子系统和 win10 是使用的相同网络,端口也都是共用的,避免端口占用冲突。

6, Ubuntu的安装位置

以我安装的Ubuntu16.04为例,Linux安装在路径:

C:\Users\HP\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu16.04onWindows_79rhkp1fndgsc\LocalState\rootfs

不同的Ubuntu版本路径稍有不同,但是都是Canonical这个开头的。

这里可以直接看到Ubuntu子系统中的文件内容,大部分情况下文件可以直接修改。

参考链接
https://blog.csdn.net/daybreak222/article/details/87968078

https://blog.csdn.net/zhouzme/article/details/78780479

https://www.jianshu.com/p/2bcf5eca5fbc

Win10&Ubuntu命令行窗口设置

cmd, 20, 新宋体,

屏幕缓冲区大小120, 9001

窗口大小, 120, 30

窗口位置, 左0, 右0, 由系统定位窗口

bash

bash, 20, DejaVu Sans Mono

屏幕缓冲区大小120, 9001

窗口大小, 120, 30

窗口位置, 左0, 右0, 由系统定位窗口

默认值和属性不一样

默认值

屏幕缓冲区大小80, 9001

窗口大小 80, 40

窗口位置0, 0

修改的时候, 去修改 属性, 而不是 默认值, 修改默认值, 没有变化

以后, 修改属性的时候, 将窗口位置手动设置为0, 0, 养成这个好习惯

字体, 设置为18

字体大小和窗口大小, 有联动作用, 体会

posted on 2021-06-11 07:23  beyondx  阅读(100)  评论(0编辑  收藏  举报

导航