欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

WSL记录

程序员文章站 2022-03-14 08:53:30
...

1.安装wsl

有些东西太简单了就不码字了
通过控制面板勾选subsystem
WSL记录
通过win+u打开开发者选项
WSL记录
通过应用商店安装Linux发行版
WSL记录

2.迁移

这里最好先备份好你原先的subsystem linux
CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc

(1)先卸载Linux子系统

wslconfig /l
从列表中选择要卸载的发行版(例如Ubuntu)并键入命令
wslconfig /u Ubuntu

WSL记录
把通过控制面板勾选subsystem去掉,然后重启

然后先删CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc里面的文件
再删CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc
这里是个坑,刚开始卸载以为需要windows的管理员权限和subsystemlinux的管理员权限才可以删除
删除这些是因为要创建链接,减少c盘的负担

(2)mklink创建链接

mklink /j C:\Users\xxx\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc D:\WSL-ubuntu\

WSL记录

3创建成功后再打开应用商店,安装Linux子系统

WSL记录

(1).更换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 multiver

备份源,以免改错

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

WSL记录
经过多次是错,不知是为何原因,上google找答案也是说要找有能力的人才能弄,我已经因为这个重装了几次了,建议上网查查怎么备份下来

更改源,我用的是中科大的源

sudo vi /etc/apt/sources.list

i是写入,h,j,k,l左上下右,[[最上,]]最下一行,:wq是保存并退出,:q是退出不保存,进入写入模式的时候就可以编辑了,退出写入模式是按esc便进入命令行模式,也可以自己去学一下vim