centos7通过startx后进入图形界面,使用eog命令提示unable to open display

问题描述:开机后以root身份通过startx后进入图形界面,想用eog命令显示图片,unable to open display。

尝试解决无果:根据网上的办法进行如下修改,依然不行。

执行顺序 命令/键盘 输出
1 echo $DISPLAY :0
2 host + unable to open display
3 xdpyinfo unable to open display
4 export DISPLAY=:unix:0 DISPLAY=:unix:0
5 xhost + unable to open display
6 xdpyinfo unable to open display
7 rm  /root/.Xauthority  
8 xhost + access control disabled, clients can connect from any host
9 eog test.png unable to open display
10 init 3 无反应,无法退出图形界面
11 Alt+Ctrl+Backspace 无反应,无法退出图形界面

       最终解决办法

          1:重启后通过init 5进入图形界面,执行host +、xdpyinfo、eog命令都能成功,此时在终端中执行runlevel 命令,显示3 5,通过init 3可退出图形界面。

         2:重启后通过startx进入图形界面,执行host +、xdpyinfo、eog成功,在终端中执行runlevel 命令,显示5 3,startx代表5,终端代表3,此时执行init 3无反应,因为打开的终端就是level3,只能通过注销当前用户才能退出图形界面

备注:无论是init 5还是startx进入图形界面,按Alt+Ctrl+Backspace都不起作用?

新问题:为什么通过init 5和startx进入图形界面后,在终端中执行runlevel 命令结果不一致init 5和startx有何不同?

下表是根据https://blog.csdn.net/ztguang/article/details/51014920进行总结。

  startx init 5
运行内容 启动X图形界面

启动 runlevel 5对应的服务

并运行 GNOME显示管理器gdm

权限 任意用户 root用户
语系 英文无法且无法更改 通过gdm设置语系

针对语系,我自己电脑Centos7 的实际情况如下,和上表中情况不太一样

       echo $LANG =zh_CN.UTF-8,

    1:系统启动后,默认为init 3,此时无法正常显示中文或输入中文

    2:通过startx进入图形界面,可以正常显示并输入中文,此时再打开终端(init 3)也能正常显示和输入中文

    3:通过init 5切换到图形界面,终端和输入框均不能输入中文,即使刚切换进来时输入法中有中文的情况下都需要通过系统工具->设置->添加语言来重新添加中文输入法才能输入中文;

猜你喜欢

转载自blog.csdn.net/weixin_41413693/article/details/85028779