摘要: 有些时候,有些程序可能需要依赖图形界面才能启动,例如安装Oracle时(其实oracle支持命令行安装),例如需要启动一个图形界面的浏览器如firefox。作为服务端的系统,通常不会安装臃肿的图形界面。那么如何在不安装图形界面的的情况下启动图形界面的?听起来很矛盾,但是实际上是可行的。 X Win
有些时候,有些程序可能需要依赖图形界面才能启动,例如安装Oracle时(其实oracle支持命令行安装),例如需要启动一个图形界面的浏览器如firefox。
作为服务端的系统,通常不会安装臃肿的图形界面。
那么如何在不安装图形界面的的情况下启动图形界面的?听起来很矛盾,但是实际上是可行的。
X Window System(常被简称为X11或X),是一套基于X display protocol的windowing system,X GUI环境的功能包括窗口的绘制、移动,以及与鼠标、键盘等输入设备的交互。
X采用C/S模型(这是关键):一个X server 和多个应用程序(client)通信。server接收client的请求绘制窗口,并将来自鼠标、键盘等设备的输入传递给client。
因此 X server和client可以位于同一计算机上,例如在Linux主机上使用KDE等桌面环境就是这种模式。X server也可以通过同构网络、异构网络或Internet与client通信。
X server与client之间的通信是不加密的,这个问题可以通过SSH解决。SSH是Secure Shell的简称,SSH可以看作是通信被加密压缩版的telnet。
需要用到SSH的forwarding功能,当X server与client所在计算机都支持SSH协议时,X server与client之间不安全的TCP/IP连接可以转送到(forwarding)二者之间建立的SSH连接上。
了解原理后,我们就可以在本地自建X服务,然后服务器作为X client,把绘图的请求发给本地的X server。 这样就实现了本地显示图像的目的。
例子, 以本地为Windows为例,使用ssh连接到服务器, 把服务器的X请求转发到本地的 X server。
简单的几个步骤即可
.1. 配置服务器的sshd,重启服务
# vi /etc/ssh/sshd_config
X11Forwarding yes
X11DisplayOffset 10
X11UseLocalhost yes
# service sshd restart
.2. 在windows主机安装Xming, 启动X server
option 1:
1.运行xmanger passive
2,观察右下角的Xmanager 小窗口的 端口号 (比如【:1.0】或者【:0.0】),用于本地securecrt export DISPLAY 用。
option 2:
windows下的X server可以通过Xming软件来构建。
https://sourceforge.net/projects/xming/
.3. 在windows主机安装securecrt或putty
.4. 在windows主机配置securecrt或者putty,配置对应会话的转发X11,并重新连接会话
.5. 在securecrt或putty命令行启动GUI命令
开启securecrt FORWARDX11后,会自动设置DISPLAY环境变量.
#echo $DISPLAY
localhost_ip:1.0
或者
localhost_ip:0.0
# firefox
####xmnager
xmnager server 端在windows;
需要在UNIX client 端打开X11 转发功能
/etc/sshd/sshd_config file
add two lines to ~/.ssh/config then connect the system
Host *
ForwardX11 yes
Brief
The X Window System (X or X11 for version 11, for short) is a platform independent method of providing graphics capabilities to an operating system, while also being network transparent. It is most commonly used on Unix and Unix-like systems such as Linux. X itself dates back to 1984 at MIT.
While other systems for providing graphics capabilities are possible, the standard graphical interface system on Linux is the X Window System.
X mechanics
Essentially, what X provides is a program (the X server) which controls the graphics card and performs actual graphics drawing tasks such as splitting the screen into windows, drawing the mouse pointer, drawing lines, accessing the keyboard, etc. It runs the actual video driver, as well as provides an interface through which other programs can issue drawing commands (using the X11 protocol), get input, etc, without having to know what hardware its running on Programs which attach to the X server are called X clients, and may include applications such as word processors, games, etc.
Window managers
One client is special, and is the window manager - X on its own does not manage drawing the window widgets (title bar and borders) and minimizing, maximizing, raising, and other specifics - this is delegated to the window manager. Before desktop environments became more commonly used, the window manager was the primary piece of software responsible for determining the look and feel of the GUI, however, window managers can only address look and feel at the window level - within the application consistency is derived from the use of a common toolkit, which was not a feature of X applications previously. Many window managers are available, such as metacity, kwin4, Window Maker, Enlightenment, and FVWM.
Gnome/KDE Installation and Configuration
The X/windows installing environment includes our recommended package selection as following:
Desktop shell(GNOME/KDE)
Office suit (OpenOffice.org)
Web browser
Email(Evolution)
Instant messaging
Sound and video applications
Software Development Tools
Administration Tools
A. Install Gnome/KDE from System Installation
When we start the Enterprise Linux installation, we'll find this screen: Package Group Selection
Package Group Selection
Select the package groups:
To select a package group, click on the check box beside it.
Once a package group has been selected, click on Details to view which packages are installed by default and to add or remove optional packages from that group.
Desktop
X Windows System
GNOME Desktop Environment
KDE(K Desktop Environment) and all sub categories.
Applications:
Editors ----Emacs/vim-enhanced/XEmacs
Graphical Internet
Text-based Internet
Office/Productivity
Sound and Video
Graphics
Administration Tools
Printing Support
B. No Gnome/KDE even no X Window System's environment
Using ssh X-forward to install the software.
We can use other Linux do below action:
add two lines to ~/.ssh/config then connect the system
Host *
ForwardX11 yes
a. Please install system-config-packages*.rpm by dependence:
insert CD-DISK
# mount /media/cdrom
# rpm -Uvh /media/cdrom/system-config-packages*.rpm
b. Run Redhat Package Management
# system-config-packages
After boot configuration
There are a few more steps to take before your system is ready to use.
The Setup Agent will now guide you through some basic configuration. Please fill appropriate information and click the "Next" button in the lower right corner to continue to finish setup.
Service/Server management
For Gnome please run:
# gnome-session-properties
For KDE please run:
# kcontrol
It's very easy to manage Service/Session using KDE Control Center.
X Window System log
The X Window System log file contain much useful information blow:
/var/log/Xorg.0.log
/var/log/Xorg.1.log
External links
http://en.wikipedia.org/wiki/X_Window_System
http://www.x.org
http://www.xfree86.org
Linux错误:xhost unable to open display
在ixpub上看到很多朋友遇到关于xhost命令的问题,例如报错:xhostunabletoopendisplay
很多没有得到很好哦解决,其实这个命令的使用很简单,只要熟悉了命令的使用,就不会有这么多问题了,下面先说说这个命令的使用,然后结合问题,说说遇到这类问题的解决办法.
xhost命令
用途
控制什么人可以访问当前主机上的增强 X-Windows。
语法
xhost[ + | - ] [ Name ]
描述
xhost命令添加或删除 X 接受连接的机器列表上的主机名。
该命令必须从有图形显示连接的机器上运行。可以通过使用 -Host 参数,从访问列表中除去一个名称。不要从访问列表中除去当前的名称。如果已经这样做了,请在作出任何更改之前注销系统。
输入无变量的xhost命令将显示访问 X 服务器的当前主机名,并显示一条消息表明访问是否已启用。
为了安全起见,只能从控制主机运行影响访问控制的选项。对于工作站来说,这台机器也就是服务器。对于 X 终端来说,这台机器是登录主机。
要在缺省情况下启用远程名称,可以在 /etc/X?.hosts 文件中定义名称,其中 ? 为启用访问的号。
例如,显示器 jeanne:0 可以由使用 jeanne 的缺省主机名的系统上的 /etc/X0.hosts 文件中定义的系统访问。在显示名称和文件名中,0 表明已定义的远程系统允许通过增强 X-Windows 访问的显示器号。
标志
+Name 定义要添加到 X 服务器访问列表的主机名(可以选用加号标记)。
- Name 定义要从 X 服务器访问列表中除去的主机名。已有的连接没有被中断,但将拒绝新的连接请求。注意:可以除去当前的机器;然而,不允许进行进一步的连接(包括试图将其添加回来)。再一次启用本地连接的唯一方法就是将服务器复位(因此也会中断所有连接)。
+ 指定访问不受限制。访问控制被关闭。
- 打开访问控制。
完整的 Name 有以下 family:name 语法:
inet
因特网主机
local
只包含一个名称,空字符串
注: 该系列是区分大小写的。名称的格式随系列而不同.
只要了解了命令的使用,上面的问题就迎刃而解了,一般在安装的时候会出现这个问题,因为oracle的安装需要图形界面的支持!
遇到这类问题的一般解决办法是:
先在root下xhost+
如何是在远程客户端启动桌面服务,需要设置客户机的DISPLAY值(exportDISPLAY=IP(客户端的IP地址,你要设成别的地址,那你就看不到图形):0.0
如果是在本机执行的话,直接到oracle图形用户下执行exportDISPLAY
如果上述设置后,还是不能启动图形的话,就要检查系统图形界面支持的问题了,例如是否安装了图形程序,是否有权限执行图形程序.或者系统时候屏蔽了图形功能等等.
最后执行./runInstaller就行了。
用motxtem 可以解决,putty 没有图像化窗口