参考文献:
- 在windows10上利用WSL安装Ubuntu(带桌面UI)
- WSL2 Ubuntu图形界面安装与远程桌面
- Linux的桌面环境比较与选择(gnome、kde、xfce、lxde)
- Ubuntu 设置国内源,提高下载速度
- 解决 PPA 源太慢
- Ubuntu 报错:System has not been booted with systemd as init system (PID 1)
- 如何修复 System has not been booted with systemd 报错信息?
- Ubuntu问题: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.
- Add "allow" rule to Windows firewall for WSL2 network #4585
- 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:3389Ubuntu 安装 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-stableWSL 安装 VScode
注意 WSL(Win 端)和 Ubuntu(RDP 端)只能存在一个 VScode
- 
如果安装 WSL 版本,就在 Win 的 VScode 中安装 Remote Development扩展即可,在 WSL 中输入code .启动远程连接
- 
如果安装 Ubuntu 版本,去官网下载 .deb文件,然后运行sudo apt install xxx.deb安装即可