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

待续

相关文章
相关标签/搜索