win10下安装linux子系统

原文链接:https://www.jianshu.com/p/444789681e2a

查看系统版本,快捷键Win+R打开运行,输入winver,打开“关于Windows”,查看当前Windows10版本。

 
关于Windows

开启开发者选项

打开【开始】>【设置】>【更新和安全】>【开发者选项】>【开发人员模式】

启用适用于Linux的Windows子系统

 
适用于Linux的Windows子系统

安装Microsoft Store

在【开始】菜单中找到PowerShell,右键【以管理员身份运行】,输入命令。

$ Get-AppxPackage -allusers | Select Name, PackageFullName
Microsoft.WindowsStore                      Microsoft.WindowsStore_12104.1001.1.0_x64__8wekyb3d8bbwe

安装Windowns Store

$ Add-appxpackage -register "C:Program FilesWindowsAppsMicrosoft.WindowsStore_12104.1001.1.0_x64__8wekyb3d8bbweappxmanifest.xml" -disabledevelopmentmod

安装成功后,在【开始】菜单中出现Microsoft Store。

下载安装Linux系统

在Microsoft Store中搜索Linux获取Ubuntu,获取后安装然后启动。

 
ubuntu

配置新账户和密码,同时修改默认root的密码。

$ sudo passwd root

使用Cmder打开Ubuntu

  1. 下载Cmder命令行工具
  2. 输入bash命令会自动进入Ubuntu系统
  3. 设置启动为Linux的Bash环境,进入设置选择启动。
 
启动进入Ubuntu
%windir%system32ash.exe ~ -cur_console:p:n

查看当前Ubuntu版本的代号为focal

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.2 LTS
Release:        20.04
Codename:       focal

修改Ubuntu默认的下载镜像为阿里云

$ cd /etc/apt/
$ sudo cp sources.list sources.list.ori

查找对应Ubuntu版本的阿里源

$ sudo vim sources.list

deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse

更新镜像并升级

$ sudo apt update
$ sudo apt upgrade

查看Ubuntu防火墙

$ sudo ufw status
Status: inactive

关闭Ubuntu防火墙

$ sudo ufw disable

允许外部访问本机

$ sudo ufw default allow

Ubuntu安装配置Python

$ sudo apt install python
$ python --version
Python 2.7.18

切换到root下没有颜色标识,将默认用户下的配置拷贝到root目录下。(无效)

$ cp /home/junchow/.bashrc /home/.bashrc

Ubuntu安装成功后会自动将本机磁盘挂载到Ubuntu的/mnt目录下



作者:JunChow520
链接:https://www.jianshu.com/p/444789681e2a
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
到win10下记得完善修改
人就像是被蒙着眼推磨的驴子,生活就像一条鞭子;当鞭子抽到你背上时,你就只能一直往前走,虽然连你也不知道要走到什么时候为止,便一直这么坚持着。
原文地址:https://www.cnblogs.com/guochaoxxl/p/15169606.html