Window下安装Ubantu18.04子系统并连上VSCode

1、打开适用于Linux的Windwos子系统选项

控制面板->程序->启用或关闭Window功能->适用于Linux的Windwos子系统选项

2、下载Ubantu并安装

Window10版本中,打开应用商店,搜索Ubantu18.04下载,并安装。

注:若提示所在地区无法下载,则设置国家或地区为美国。具体操作如下:设置->时间和区域->区域->国家或地区中选择美国。

3、安装Ubantu18.04

安装时会提示输入用户名和密码

4、更改Ubantu18.04镜像源

备份/etc/apt/sources.list
#备份
cp /etc/apt/sources.list /etc/apt/sources.list.bak

在/etc/apt/sources.list文件前面添加如下条目
#添加阿里源
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

最后执行如下命令更新源
##更新
sudo apt-get update
sudo apt-get upgrade

5、VSCode连接Ubantu子系统

打开VSCode(该VSCode是安装在Window下的),下载插件Remote - WSL

6、Ubantu子系统启动VSCode

1、打开Ubantu18.04

注:Window下的C盘内容默认是挂载在/mnt目录下的

2、确定需要创建的文件位置,并输入code . 启动VSCode

3、首次连接成功后,下一次连接时,直接打开VSCode,点击Remote Explorer,点击目标文件

 

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值