How do I set the DISPLAY variable on Linux
2012-07-17 22:11
323 查看
startx
ps -e | grep X
pidof X && echo "yup X server is running"
if you're on the main display, then
or if you're using csh or tcsh
Actually, I'm surprised it isn't set automatically. Are you trying to start this application from a non-graphic terminal? If not, have you modified the default .profile, .login, .bashrc or .cshrc?
Note that setting the DISPLAY to :0.0 pre-supposes that you're sitting at the main display, as I said, or at least that the main display is logged on to your user id. If it's not logged on, or it's a different userid, this will fail.
If you're coming in from another machine, and you're at the main display of that machine and it's running X, then you can use "ssh -X hostname" to connect to that host, and ssh will forward the X display back. ssh will also make sure that the DISPLAY environment
variable is set correctly (providing it isn't being messed with in the various dot files I mentioned above). In a "ssh -X" session, the DISPLAY environment variable will have a value like "localhost:11.0", which will point to the socket that ssh is tunnelling
to your local box.
f you're already within a graphical environment, try export DISPLAY=:0 for bash like shells (bash, sh, etc) or setenv DISPLAY :0 for C shell based shells (csh, tcsh, etc)
If you've connected from another machine via SSH, you use the -X option to display the graphical interface on the machine you're sitting at (provided there's an X server running there (such as xming for windows, and your standard Linux X server).
Don't forget to execute "host +" on your "home" display machine, and when you ssh to the machine you're doing "ssh -x hostname"
Using Linux, and especially configuring Linux, normally require some insight, and we strongly suggest (to inexperienced linux users) to get some help from a system administrator.
In short, you must open up a shell (csh, bash, etc), so that it is possible to issue commands on Linux. Then you must enter the commands to set the environment variable, as explained in the setup-instructions.
Also, if you are starting Tomcat (or other application server) automatically by calling the startup-script in the this script:
/etc/rc.local
..then you must make sure that the command for setting the DISPLAY variable is called before starting the application server.
There are many discussions/guides on the Internet regarding this issue. Here is an extract from one:
"1. A Little Theory
The magic word is DISPLAY. In the X window system, a display consists
(simplified) of a keyboard, a mouse and a screen. A display is managed
by a server program, known as an X server. The server serves
displaying capabilities to other programs that connect to it.
A display is indicated with a name, for instance:
* DISPLAY=light.uni.verse:0
* DISPLAY=localhost:4
* DISPLAY=:0
The display consists of a hostname (such as light.uni.verse and
localhost), a colon (:), and a sequence number (such as 0 and 4). The
hostname of the display is the name of the computer where the X server
runs. An omitted hostname means the local host. The sequence number is
usually 0 -- it can be varied if there are multiple displays connected
to one computer.
If you ever come across a display indication with an extra .n attached
to it, that's the screen number. A display can actually have multiple
screens. Usually there's only one screen though, with number n=0.
Other forms of DISPLAY exist, but this will do for our purposes.
2. Telling the Client
The client program (for instance, your graphics application) knows
which display to connect to by inspecting the DISPLAY environment
variable. This setting can be overridden, though, by giving the client
the command line argument -display hostname:0 when it's started. Some
examples may clarify things.
Our computer is known to the outside as light, and we're in domain
uni.verse. If we're running a normal X server, the display is known as
light.uni.verse:0. We want to run the drawing program xfig on a remote
computer, called dark.matt.er, and display its output here on light.
If you have csh running on the remote computer:
dark% setenv DISPLAY light.uni.verse:0
dark% xfig &
Or alternatively:
dark% xfig -display light.uni.verse:0 &
If you have sh running on the remote computer:
dark$ DISPLAY=light.uni.verse:0
dark$ export DISPLAY
dark$ xfig &
Or alternatively:
dark$ DISPLAY=light.uni.verse:0 xfig &
Or, of course, also:
dark$ xfig -display light.uni.verse:0 &
It seems that some versions of telnet automatically transport the
DISPLAY variable to the remote host. If you have one of those, you're
lucky, and it's automatic. If not, most versions of telnet _do_
transport the TERM environment variable; with some judicious hacking
it is possible to piggyback the DISPLAY variable on to the TERM
variable."
ps -e | grep X
pidof X && echo "yup X server is running"
if you're on the main display, then
export DISPLAY=:0.0
or if you're using csh or tcsh
setenv DISPLAY :0.0
Actually, I'm surprised it isn't set automatically. Are you trying to start this application from a non-graphic terminal? If not, have you modified the default .profile, .login, .bashrc or .cshrc?
Note that setting the DISPLAY to :0.0 pre-supposes that you're sitting at the main display, as I said, or at least that the main display is logged on to your user id. If it's not logged on, or it's a different userid, this will fail.
If you're coming in from another machine, and you're at the main display of that machine and it's running X, then you can use "ssh -X hostname" to connect to that host, and ssh will forward the X display back. ssh will also make sure that the DISPLAY environment
variable is set correctly (providing it isn't being messed with in the various dot files I mentioned above). In a "ssh -X" session, the DISPLAY environment variable will have a value like "localhost:11.0", which will point to the socket that ssh is tunnelling
to your local box.
f you're already within a graphical environment, try export DISPLAY=:0 for bash like shells (bash, sh, etc) or setenv DISPLAY :0 for C shell based shells (csh, tcsh, etc)
If you've connected from another machine via SSH, you use the -X option to display the graphical interface on the machine you're sitting at (provided there's an X server running there (such as xming for windows, and your standard Linux X server).
Don't forget to execute "host +" on your "home" display machine, and when you ssh to the machine you're doing "ssh -x hostname"
Using Linux, and especially configuring Linux, normally require some insight, and we strongly suggest (to inexperienced linux users) to get some help from a system administrator.
In short, you must open up a shell (csh, bash, etc), so that it is possible to issue commands on Linux. Then you must enter the commands to set the environment variable, as explained in the setup-instructions.
Also, if you are starting Tomcat (or other application server) automatically by calling the startup-script in the this script:
/etc/rc.local
..then you must make sure that the command for setting the DISPLAY variable is called before starting the application server.
There are many discussions/guides on the Internet regarding this issue. Here is an extract from one:
"1. A Little Theory
The magic word is DISPLAY. In the X window system, a display consists
(simplified) of a keyboard, a mouse and a screen. A display is managed
by a server program, known as an X server. The server serves
displaying capabilities to other programs that connect to it.
A display is indicated with a name, for instance:
* DISPLAY=light.uni.verse:0
* DISPLAY=localhost:4
* DISPLAY=:0
The display consists of a hostname (such as light.uni.verse and
localhost), a colon (:), and a sequence number (such as 0 and 4). The
hostname of the display is the name of the computer where the X server
runs. An omitted hostname means the local host. The sequence number is
usually 0 -- it can be varied if there are multiple displays connected
to one computer.
If you ever come across a display indication with an extra .n attached
to it, that's the screen number. A display can actually have multiple
screens. Usually there's only one screen though, with number n=0.
Other forms of DISPLAY exist, but this will do for our purposes.
2. Telling the Client
The client program (for instance, your graphics application) knows
which display to connect to by inspecting the DISPLAY environment
variable. This setting can be overridden, though, by giving the client
the command line argument -display hostname:0 when it's started. Some
examples may clarify things.
Our computer is known to the outside as light, and we're in domain
uni.verse. If we're running a normal X server, the display is known as
light.uni.verse:0. We want to run the drawing program xfig on a remote
computer, called dark.matt.er, and display its output here on light.
If you have csh running on the remote computer:
dark% setenv DISPLAY light.uni.verse:0
dark% xfig &
Or alternatively:
dark% xfig -display light.uni.verse:0 &
If you have sh running on the remote computer:
dark$ DISPLAY=light.uni.verse:0
dark$ export DISPLAY
dark$ xfig &
Or alternatively:
dark$ DISPLAY=light.uni.verse:0 xfig &
Or, of course, also:
dark$ xfig -display light.uni.verse:0 &
It seems that some versions of telnet automatically transport the
DISPLAY variable to the remote host. If you have one of those, you're
lucky, and it's automatic. If not, most versions of telnet _do_
transport the TERM environment variable; with some judicious hacking
it is possible to piggyback the DISPLAY variable on to the TERM
variable."
相关文章推荐
- Linux 平台 Oracle 安装 报错 Check if the DISPLAY variable is set 解决方法
- Linux 平台 Oracle 安装 报错 Check if the DISPLAY variable is set 解决方法
- Linux 平台 Oracle 安装 报错 Check if the DISPLAY variable is set 解决方法
- Linux 平台 Oracle 安装 报错 Check if the DISPLAY variable is set 解决方法
- Linux 平台 Oracle 安装 报错 Check if the DISPLAY variable is set 解决方法
- Linux 平台 Oracle 安装 报错 Check if the DISPLAY variable is set 解决方法
- How to Record your Voice from the Microphone on Ubuntu/Linux Mint
- How to set the current user on the model instance in the admin:
- How to Set Up DTrace to Detect PHP Scripting Problems on Oracle Linux
- how can display please wait message on the button
- How to get a notification from Linux when the set of network interfaces changes
- How do I set the timeout for a JAX-WS webservice client? if you want to set timeouts for specific se
- Linux下安装oracle数据库提示DISPLAY not set. Please set the DISPLAY and try again。
- 转:How to Disable the SELinux on RHEL 6
- Linux下安装oracle数据库提示DISPLAY not set. Please set the DISPLAY and try again.解决方法
- Linux下运行Java项目时,出现No X11 DISPLAY variable was set, but this program performed an operation which requires it.的问题解决
- Linux下安装oracle数据库提示DISPLAY not set. Please set the DISPLAY and try again.解决方法
- How to Set Up an Rsync Daemon on Your Linux Server
- How to programmatically clear the filesystem memory cache in C++ on a Linux system?
- how to find the tomcat version info on linux