Linux安装X11实现GUI

简介

X11,X Window System,以位图方式显示软件窗口,为 GUI 环境提供基本框架




安装

查看是否已安装 X11

dpkg -l | grep xserver-xorg-core

安装 X11,大概需要 17 - 222 MB(前者是在服务器上装,后者在自己的 WSL 装,具体视情况而定)

sudo apt-get install xorg
sudo apt-get install xauth
sudo apt-get install openbox
sudo apt-get install xserver-xorg-legacy

查看是否开启 X11 转发

cat /etc/ssh/sshd_config | grep X11Forwarding

安装 xclock

sudo apt install x11-apps




初试

Windows 使用 MobaXterm

xclock




跳板机

许多生产服务器是这样连接的:本机 → 多台跳板机 → 服务器

配置映射可阅读:How to forward an X11 client through a Jump Host back to a PC with an X Emulator

但最简单的是让运维开个外网 IP 让直接连接




Error: Can’t open display:

修改 sshd 配置文件

sudo vim /etc/ssh/sshd_config

保证该配置文件有

X11Forwarding yes
X11DisplayOffset 10
X11UseLocalhost no

PermitTunnel yes

重启 sshd 服务

service sshd restart

重新连接 SSH

查看转发,有的话就 OK 了

echo $DISPLAY
xclock

推荐阅读:sshd_config 参数详解




切换用户无法显示

切换用户

sudo su - xxx

时钟

xclock

报错

MoTTY X11 proxy: Unsupported authorisation protocol
Error: Can't open display: xxx:10.0

Ctrl + D 退回到能显示的用户,输出配置并复制

xauth list $DISPLAY
testpy-10-13-128-183/unix:10  MIT-MAGIC-COOKIE-1  0bf3f86382d0315c5f902384dbd7571e
echo $DSIPLAY
localhost:10.0

切换用户

sudo su - xxx

添加配置

xauth add testpy-10-13-128-183/unix:10  MIT-MAGIC-COOKIE-1  0bf3f86382d0315c5f902384dbd7571e

时钟可以正常显示

xclock

如果 xauth add 那步失败

sudo vim /etc/X11/Xwrapper.config

allowed_users=console

改成

allowed_users=anybody




参考文献

  1. How to install X11/xorg?
  2. linux服务器通过X11实现图形化界面显示
  3. ServerGUI - Community Help Wiki
  4. How to check if the X11 display manager is installed?
  5. How do I fix a “cannot open display” error when opening an X program after ssh’ing with X11 forwarding enabled? - Super User
  6. 使用x11 forwarding显示X Windows
  7. How to forward an X11 client through a Jump Host back to a PC with an X Emulator
  8. sshd_config
  9. macOS使用XQuartz支持X11实现Linux图形化界面显示
  10. xorg - PuTTY X11 forwarding: Unsupported authorisation protocol
  11. Can’t start X11 applications after “su” or “su -” to another user
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

XerCis

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值