史上最全win10下Linux子系統的安裝及優化方案

相信大家都會對Linux系統有一定程度的需求,但是目前所有Linux發行版的桌面環境實在是不太友好,並不能完全滿足我們所有的學習和娛樂。於是我們會想到安裝Windows+Linux雙系統,或者在Windows下用虛擬機安裝Linux。即便這樣,兩個系統間切換來切換去還是特別麻煩。今天給大家帶來一個完美的解決方案,安裝Linux子系統。讓你在win10下像使用軟件一樣的使用Linux。

先上一張最終效果圖。


效果圖

子系統的安裝

安裝子系統很簡單。安裝前先要做下準備。首先,打開win10開發人員模式,在設置-->更新和安全-->針對開發人員,中勾選開發人員模式。


1

然後在控制面板中勾選添加Linux子系統。依次進入控制面板-->程序-->啓用或關閉windows功能,勾選適用於windows的linux的子系統,點擊確定。之後重啓電腦。

2

3

重啓後就可以安裝Linux子系統了。可以有兩種方法安裝,第一種是在Microsoft store裏面直接搜索Ubuntu進行安裝。(Ubuntu是Linux的發行版之一)


4

第二種是在win10 命令行內進行安裝。win+R打開cmd,進入Windows下的命令行。命令行下輸入命令bash回車,它會問你是否安裝,輸入y繼續。(bash是Linux下的一個命令行)


5

6

使用時,直接在cmd中輸入bash即可進入Linux子系統。
也可以直接打開在Microsoft store中下載的Ubuntu進入子系統。
初次進入Linux子系統需要設置Linux的用戶名及密碼。
之後就可以愉快地玩耍了

子系統的優化

更換apt源。

因爲Linux子系統的apt源使用的是官方源,需要連接到國外的服務器。所以安裝一些軟件時下載會很慢,我們可以改用國內的鏡像apt源。
國內的鏡像源主要有:
阿里源

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

科大源

deb https://mirrors.ustc.edu.cn/ubuntu/ xenial main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ xenial-security main restricted universe multiverse

網易源

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

可以直接使用vim對 /etc/apt/sources.list文件進行修改。
先進行一下備份。

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

然後

sudo vim  /etc/apt/sources.list
7

選擇一個源添加到文件最前面或直接替換掉原文件。
保存後運行

sudo apt-get update

Linux子系統運行圖形界面程序。

首先在win10中安裝開源軟件xming,可以直接在官網上下載到。
再在子系統下安裝x11-apps

sudo apt-get install x11-apps 

運行圖形界面程序時,在程序名前面加上DISPLAY=:0 即可。比如打開Linux下的一個程序編輯器geany。

DISPLAY=:0 geany
8

終端的美化

win10下實在太醜了,而且功能很少,很不好用。推薦大家一個開源軟件cmder,可以完美解決這一問題。這個軟件同樣可以在官網上下載到,而且是免安裝的哦。

9

選擇下載那個mini版的,完整版與mini版的功能是一樣的,只是完整版中多了bash。因爲我們已經安裝了bash所以直接用mini版的就可以了。


10

上圖是cmder的主界面,是不是好看多了。
打開cmder直接進入的是cmd,我們可以在設置中更改它的startup方式,選擇command line ,填入bash -cur_console:p
保存設置,下次打開時就直接進入Linux子系統了。

11

我們還可以在colors選項中選擇自己喜歡的主題,在transparency中更改主界面的透明度。
而且cmder還有分屏功能,下圖是我美化的最終結果。


12

最後,送給大家一個cmder的小絕招。
我們可以將cmder添加進win10的環境變量中,這樣我們就可以像在Linux系統中那樣,在任意文件目錄下直接右鍵打開cmder並進入當前路徑了。
比如在桌面點擊右鍵,選擇cmder here,這樣打開cmder就可以直接進入桌面的路徑了。


13
14

設置環境變量的具體方法是,依次進入控制面板-->系統和安全-->系統,選擇高級系統設置。

15

點擊環境變量。


16

編輯系統環境變量Path。


17

把cmder路徑添加進來,保存之後就可以用win+R的方式打開cmder了。

接下來,以管理員方式打開cmd,輸入命令Cmder.exe /REGISTER ALL。之後就可以直接在右鍵中打開cmde了。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章