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 安装即可

相关推荐
桑榆4163 小时前
双系统(Windows + Ubuntu)安装流程
linux·windows·ubuntu
ltl9 小时前
实时 OS 巡礼:VxWorks、QNX、Zephyr 与 PREEMPT_RT
linux
我是谁??9 小时前
Ubuntu22.04更换清华源
linux·运维·服务器
圣殿骑士-Khtangc10 小时前
Go字符串高效拼接性能对比与底层原理分析
服务器·前端·golang
ze^010 小时前
【软考信息安全】第2章 网络攻击原理与常用方法
网络·web安全·网络安全
Shell运维手记10 小时前
Linux 常用基础命令学习笔记
linux·运维·笔记·学习·算法·github
这个DBA有点耶11 小时前
数据库一体机架构演进:从硬件堆叠到软硬深度耦合
服务器·网络·数据库·硬件架构·运维开发·database·数据库架构
测试运维日常笔记12 小时前
Linux系统安装配置TigerVNC服务器完整指南
linux·运维·服务器
像风一样自由202012 小时前
加强版VScode结合remote-ssh远程连接服务器开发指南
服务器·vscode·ssh
雾时之林12 小时前
Linux----cron定时服务
linux·运维·服务器