【工具軟體】-Win10 安裝 Linux 子系統
阿新 • • 發佈:2020-12-05
1. 修改配置
進入控制面板,進入“程式”子選單:
單擊“啟用或關閉 Windows 功能”:
勾選“適用於 Linux 的 Windows 子系統”:
2. 下載 Ubuntu
進入 Microsoft Store,搜尋 Ubuntu,這裡會有多個搜尋結果,注意下載標註出的版本:
安裝完成後,即可在開始選單找到 Ubuntu 的入口
首次進入 Ubuntu 系統,會要求設定使用者名稱和密碼。設定完成後,即可使用。
3. 修改軟體源
在 Ubuntu 使用過程中,經常需要線上下載軟體。由於網路問題,使用預設源會出現無法訪問或網速很慢的問題,因此需要修改配置,使用國內軟體源。軟體源在 /etc/apt/sources.list 中配置,直接替換為以下內容即可:
1 # See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to 2 # newer versions of the distribution. 3 deb http://archive.ubuntu.com/ubuntu/ focal main restricted 4 # deb-src http://archive.ubuntu.com/ubuntu/ focal main restricted 5 6 ## Major bug fix updates produced after the final release of the7 ## distribution. 8 deb http://archive.ubuntu.com/ubuntu/ focal-updates main restricted 9 # deb-src http://archive.ubuntu.com/ubuntu/ focal-updates main restricted 10 11 ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu 12 ## team. Also, please note that software in universe WILL NOT receive any13 ## review or updates from the Ubuntu security team. 14 deb http://archive.ubuntu.com/ubuntu/ focal universe 15 # deb-src http://archive.ubuntu.com/ubuntu/ focal universe 16 deb http://archive.ubuntu.com/ubuntu/ focal-updates universe 17 # deb-src http://archive.ubuntu.com/ubuntu/ focal-updates universe 18 19 ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu 20 ## team, and may not be under a free licence. Please satisfy yourself as to 21 ## your rights to use the software. Also, please note that software in 22 ## multiverse WILL NOT receive any review or updates from the Ubuntu 23 ## security team. 24 deb http://archive.ubuntu.com/ubuntu/ focal multiverse 25 # deb-src http://archive.ubuntu.com/ubuntu/ focal multiverse 26 deb http://archive.ubuntu.com/ubuntu/ focal-updates multiverse 27 # deb-src http://archive.ubuntu.com/ubuntu/ focal-updates multiverse 28 29 ## N.B. software from this repository may not have been tested as 30 ## extensively as that contained in the main release, although it includes 31 ## newer versions of some applications which may provide useful features. 32 ## Also, please note that software in backports WILL NOT receive any review 33 ## or updates from the Ubuntu security team. 34 deb http://archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse 35 # deb-src http://archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse 36 37 ## Uncomment the following two lines to add software from Canonical's 38 ## 'partner' repository. 39 ## This software is not part of Ubuntu, but is offered by Canonical and the 40 ## respective vendors as a service to Ubuntu users. 41 # deb http://archive.canonical.com/ubuntu focal partner 42 # deb-src http://archive.canonical.com/ubuntu focal partner 43 44 deb http://security.ubuntu.com/ubuntu/ focal-security main restricted 45 # deb-src http://security.ubuntu.com/ubuntu/ focal-security main restricted 46 deb http://security.ubuntu.com/ubuntu/ focal-security universe 47 # deb-src http://security.ubuntu.com/ubuntu/ focal-security universe 48 deb http://security.ubuntu.com/ubuntu/ focal-security multiverse 49 # deb-src http://security.ubuntu.com/ubuntu/ focal-security multiverse 50 51 deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse 52 deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse 53 deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse 54 deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse 55 deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse 56 deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse 57 deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse 58 deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse 59 deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
替換軟體源後,要執行以下命令方能生效:
1 $ sudo apt-get update
4. 在 Ubuntu 子系統檢視檔案
我們可以在 Ubuntu 子系統中檢視 Windows 檔案。進入 /mnt 目錄,即可看到本地磁碟。譬如 /mnt/d,就是 Windows 下的 D 盤。但 Windows 預設僅掛載了當前磁碟。
4.1 掛載磁碟
對於 U 盤、行動硬碟,需要掛載後使用。命令如下:
1 $ sudo mkdir /mnt/g # 建立掛載目錄 2 $ sudo mount -t drvfs G: /mnt/g # 掛載 3 $ sudo umount /mnt/g # 解除安裝
4.2 掛載網路位置
我們的程式碼儲存在伺服器,並將其對映為 Windows 下的碟符,這種碟符在 Linux 子系統中預設是看不到的。但我們可以使用以下命令掛載網路位置:
1 $ sudo mkdir /mnt/android-server # 建立掛載目錄 2 $ sudo mount -t drvfs '\\192.168.10.3\renzhengzhi' /mnt/android-server/ # 掛載