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 Files\WindowsApps\Microsoft.WindowsStore_12104.1001.1.0_x64__8wekyb3d8bbwe\appxmanifest.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%\system32\bash.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下記得完善修改


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM