WSL:桌面 UI + 远程连接 RDP + 配置 VScode

参考文献:

  1. 在windows10上利用WSL安装Ubuntu(带桌面UI)
  2. WSL2 Ubuntu图形界面安装与远程桌面
  3. Linux的桌面环境比较与选择(gnome、kde、xfce、lxde)
  4. Ubuntu 设置国内源,提高下载速度
  5. 解决 PPA 源太慢
  6. Ubuntu 报错:System has not been booted with systemd as init system (PID 1)
  7. 如何修复 System has not been booted with systemd 报错信息?
  8. Ubuntu问题: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.
  9. Add "allow" rule to Windows firewall for WSL2 network #4585
  10. Linux 版 Google Chrome:下载和安装

文章目录

  • [为 WSL 安装桌面](#为 WSL 安装桌面)
  • [Win 远程连接桌面](#Win 远程连接桌面)
  • [Ubuntu 安装 Chrome](#Ubuntu 安装 Chrome)
  • [WSL 安装 VScode](#WSL 安装 VScode)

为 WSL 安装桌面

首先更新 Ubuntu 的软件包。最好使用 Ubuntu 自带的 deb 源 ,虽然速度慢,但是很全很保险。如果使用阿里源等,可能有些包并不会更新,导致一些奇奇怪怪的安装错误。如果要换源,需要注意 Ubuntu 的代号 ,例如 22.04 TLS 代号为 Jammy Jellyfish

bash 复制代码
sudo apt update
sudo apt upgrade
sudo apt autoremove

桌面环境,

bash 复制代码
sudo apt install xfce4 #桌面

图形界面系统,

bash 复制代码
sudo apt install xorg #渲染

远程连接,

bash 复制代码
sudo apt install xrdp #连接

Win 远程连接桌面

配置远程桌面。在 WSL 中要使用 SysV init 管理远程服务,使用 systemctl 会报错。

bash 复制代码
sudo echo xfce4-session >~/.xsession
 
sudo vim /etc/xrdp/xrdp.ini #可以修改 RDP 配置

sudo service xrdp restart

service xrdp status #是否成功启动

配置 WSL 防火墙,

bash 复制代码
curl ifconfig.me #查看 IP

sudo ufw enable #启动防火墙

sudo ufw allow 3389 #允许外部访问 RDP 默认端口

sudo ufw status #查看防火墙状态

在管理员 PowerShell 中配置 Win 防火墙,

bash 复制代码
Get-NetAdapter -IncludeHidden | Format-Table -AutoSize #查看Win的网络

New-NetFirewallRule -DisplayName "WSL by interface" -Direction Inbound  -InterfaceAlias "vEthernet (WSL (Hyper-V firewall))"  -Action Allow #打开Win和WSL之间的防火墙

查看 WSL 的 IP 地址,

bash 复制代码
cat /etc/resolv.conf #在WSL下查看Win的IP

ip a |grep "global eth0" #查看WSL自己的IP

使用 Win 远程桌面连接,输入 usr 和 pass,

bash 复制代码
172.xxx.xxx.xxx:3389

Ubuntu 安装 Chrome

安装

bash 复制代码
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb #下载安装包

sudo apt install ./google-chrome-stable_current_amd64.deb #安装

sudo apt install google-chrome-stable #更新Chrome

启动

bash 复制代码
google-chrome-stable

WSL 安装 VScode

注意 WSL(Win 端)和 Ubuntu(RDP 端)只能存在一个 VScode

  • 如果安装 WSL 版本,就在 Win 的 VScode 中安装 Remote Development 扩展即可,在 WSL 中输入 code . 启动远程连接

  • 如果安装 Ubuntu 版本,去官网下载 .deb 文件,然后运行 sudo apt install xxx.deb 安装即可

相关推荐
未济5 天前
linux 配置环境变量
linux
傲世仙尊5 天前
目录即文件-Ext文件系统收尾篇
linux·c语言
虎头金猫5 天前
4K 视频总卡在公网带宽?用 N1 + OpenList 把网盘播放链路重新理顺
运维·服务器·网络·python·容器·beautifulsoup·pandas
_艾伦 耶格尔.5 天前
进程间通信
linux
Liuqy-055 天前
Linux IO编程——静态库、动态库
linux
彧azz5 天前
Linux 环境下 Redis 学习总结:数据类型、持久化、锁、事务、主从与缓存问题
linux·redis·笔记·学习·面试
-梅5 天前
linux(8) 软硬链接
linux·运维·服务器
Wang's Blog5 天前
Java 项目实战: 外卖平台-文件下载与ServletOutputStream回写浏览器
服务器·项目开发
AIgorithmGEEK5 天前
[Linux]线程三部曲(上):一个执行流的诞生——从操作系统一路拆到 pthread_create
linux·线程·pid
琥珀色糖5 天前
SimlpeHttp
linux·服务器