windows10下安装ubuntu子系统

windows10下安装ubuntu子系统

在win10上使用Ubuntu除了使用虚拟机外,还有一种官方支持的Linux子系统模式。子系统上的流畅度比虚拟机高出了不知多少!经过多次尝试才成功配置。
废话不多说,下面开始搭建~!
win10+ubuntu+vscode安装详解

第一步:开启开发者模式
系统设置 -> 更新和安全 -> 针对开发人员 -> 选择开发者模式
windows10下安装ubuntu子系统_第1张图片
windows10下安装ubuntu子系统_第2张图片
第二步:启用 Linux 子系统组件
系统设置 -> 应用 -> 右侧的程序和功能 -> 启动或关闭windows功能 -> 勾选适用于 Linux 的 Windows 子系统
设置完成后一定要重启电脑更新设置

windows10下安装ubuntu子系统_第3张图片
windows10下安装ubuntu子系统_第4张图片

windows10下安装ubuntu子系统_第5张图片

注意: 重启电脑!!!!

第三步:安装 Linux 子系统
打开 Windows 应用市场,输入 linux 搜索,选择你自己想要的系统版本,一般选择的是 Ubuntu ,然后下载安装。
windows10下安装ubuntu子系统_第6张图片
windows10下安装ubuntu子系统_第7张图片

(等一会,别着急)
安装成功后首次打开要等待几分钟,然后界面会出现用户设置用户密码设置,按照提示进行操纵即可。

第四步:修改Linux国内镜像
Ubuntu子系统默认源,安装软件速度极慢,所以我建议修改镜像源,例如:阿里云镜像源、清华大学镜像源等。
这里我使用的是阿里云镜像源:

  • 先进行root用户的密码设置:
sudo passwd root
  • 切换到root用户设置国内镜像
vim /etc/apt/sources.list
# See http://help. the distribution.
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted
# deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted

## Major bug fix updates produced after the final release of the
## distribution.
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted
# deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://mirrors.aliyun.com/ubuntu/ bionic universe
# deb-src http://mirrors.aliyun.com/ubuntu/ bionic universe
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates universe
# deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates universe

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://mirrors.aliyun.com/ubuntu/ bionic multiverse
# deal Xerus_ - Release amd64 (20160420.1)]/ xenial main restricted
 deb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-properties
 deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted
 deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-properties
 deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted
 deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties
 deb http://mirrors.aliyun.com/ubuntu/ xenial universe
 deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
 deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse
 deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse
 deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
 deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties
 deb http://archive.canonical.com/ubuntu xenial partner
 deb-src http://archive.canonical.com/ubuntu xenial partner
 deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted
 deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties
 deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
 deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverseb-src http://mirrors.aliyun.com/ubuntu/ bionic multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates multiverse
# deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates multiverse

## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
# deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu bionic partner
# deb-src http://archive.canonical.com/ubuntu bionic partner

#deb http://security.ubuntu.com/ubuntu/ bionic-security main restricted
# deb-src http://security.ubuntu.com/ubuntu/ bionic-security main restricted
#deb http://security.ubuntu.com/ubuntu/ bionic-security universe
# deb-src http://security.ubuntu.com/ubuntu/ bionic-security universe
#deb http://security.ubuntu.com/ubuntu/ bionic-security multiverse
# deb-src http://security.ubuntu.com/ubuntu/ bionic-security multiverse

复制粘贴替换原来的即可,建议把原来的另保存下(复制后打开文件按I进入 插入模式,然后点击鼠标右键完成粘贴操作)

更改完镜像源一定要 apt-get update

最后提示:
Ubuntu子系统的文件存放在

C:\Users\用户名\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState\rootfs\

安装gcc和g++

apt-get install gcc -y
apt-get install g++ -y

vim 编辑代码环境设置

vim ~./vimrc     # 仅当前用户有效

su - root
vim /etc/vim/vimrc    #  所有用户有效

windows10下安装ubuntu子系统_第8张图片

你可能感兴趣的:(windows10下安装ubuntu子系统)