linux子系統折騰記 (二)

今天一早起牀,打開debian,竟然出現 錯誤: 0x80070040 。不知道是怎麼回事,網上有篇文章詳細介紹了windows linux子系統,打算參考來作作:https://www.jianshu.com/p/bc38ed12da1d 。很是有技術的一篇文章。linux

用wslconfig /u Debian刪了系統,輸入debian從新安裝。過程卻是很簡單快捷,就是想不到這個子系統那麼容易完蛋。git

既然如此就整理一下安裝的步驟吧:github

1. 安裝Linux子系統

imageimage

2.微軟商店搜索linux

image

選debian 安裝就好了。windows

3.配置Linux 更新源

由於linux不少東西都是網上更新的,並且是外國,網速是一大問題,必需要找到快速的更新源。因此第一步就是要更改更新源,不然什麼都別想幹了。注意:win10自帶的debian是版本9。編輯器

debian 的配置放在/etc 這個目錄,而更新工具叫apt,因此在/etc/apt 目錄下面的sources.list 文本文件就是咱們要修改的對象。工具

阿里巴巴的源替換一下,用#能夠註釋掉原來的內容。 網站

阿里巴巴有各類linux的備份源,很是棒: https://opsx.alibaba.com/mirror (不知道騰訊有沒有作這方面的工做)編碼

命令:sudo nano /etc/apt/sources.list加密


#deb http://deb.debian.org/debian stretch main
#deb http://deb.debian.org/debian stretch-updates main
#deb http://security.debian.org/debian-security/ stretch/updates main命令行

#阿里源
deb http://mirrors.aliyun.com/debian/ stretch main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ stretch main non-free contrib
deb http://mirrors.aliyun.com/debian-security stretch/updates main
deb-src http://mirrors.aliyun.com/debian-security stretch/updates main
deb http://mirrors.aliyun.com/debian/ stretch-updates main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ stretch-updates main non-free contrib
deb http://mirrors.aliyun.com/debian/ stretch-backports main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ stretch-backports main non-free contrib


其中sudo表示提高權限,nano是一個命令行編輯器,linux的命令行工具真是很是強大,這麼簡單的工具都有語法識別,上色功能。

image

下面的是菜單,^表示ctrl 按鍵。ctrl + O 寫入,而後ctrl + X退出便可。

4.自動更新

sudo apt-get update

5.安裝dotnet core sdk

微軟官方指導:https://www.microsoft.com/net/download/linux-package-manager/debian9/sdk-current

wget https://packages.microsoft.com/keys/microsoft.asc --no-check-certificate

下載微軟的證書,不知道爲何不能下載,用—no-check-certificate參數避免檢查證書。linux這方面是很嚴格的,有點煩。

wget是一個下載工具。

gpg --dearmor microsoft.asc

gpg是一個加密工具,這裏面是將文本編碼microsoft.asc 解碼成二進制的 microsoft.asc.gpg。 gpg後綴是一個密鑰文件。

sudo mv microsoft.asc.gpg /etc/apt/trusted.gpg.d/

mv移動文件

wget  https://packages.microsoft.com/config/debian/9/prod.list --no-check-certificate

一樣也要不檢查網站證書才能下載成功,此次不知道是怎麼回事,上次沒這個問題。

sudo mv prod.list /etc/apt/sources.list.d/microsoft-prod.list
sudo chown root:root /etc/apt/trusted.gpg.d/microsoft.asc.gpg
sudo chown root:root /etc/apt/sources.list.d/microsoft-prod.list

移動,並把文件的擁有者改爲root 和root組。

這些操做的目的大概就是把微軟的源增長進去。

sudo apt-get update 自動更新,結果提示沒有 apt-transport-https 庫,先安裝一下:

sudo apt-get install apt-transport-https

注意:原來以前沒有https組件的支持,因此wget纔會出現這種錯誤,我把順序搞亂了。

在更新一次就ok了。而後就能夠正常安裝dotcore了。

sudo apt-get install dotnet-sdk-2.1

會增長412m。安裝過程會卡半天,要等待回到命令提示符狀態便可。

image

6.備份一下

這個環境那麼難配置,嘗試備份一下。

找到C:\Users\zhouy\AppData\Local\Packages\TheDebianProject.DebianGNULinux_76v4gfsz19hv4\LocalState\ 用xcopy把rootfs 備份一份,暫時還沒法驗證這個方法有沒有用。

7.配置遠程開發

繼續今天的目標,就是在windows上用vscode 鏈接 debian上的netcore來開發。嘗試了remote vscode 擴展,確實能夠打開遠程文件,可是這有什麼用呢?怎麼編譯?暫時沒什麼好思路,先放下了。

發現官方是有文檔支持遠程調試,特別是支持linux子系統調試的,看來個人需求是獲得支持的,不過是英文資料,須要慢慢啃。

wsl 官方文檔:https://github.com/OmniSharp/omnisharp-vscode/wiki/Windows-Subsystem-for-Linux

待續

相關文章
相關標籤/搜索