How do I set the DISPLAY variable on Linux – Jenny

startx

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 TheoryThe magic word is DISPLAY. In the X window system, a display consists(simplified) of a keyboard, a mouse and a screen. A display is managedby a server program, known as an X server. The server servesdisplaying 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=:0The display consists of a hostname (such as light.uni.verse andlocalhost), a colon (:), and a sequence number (such as 0 and 4). Thehostname of the display is the name of the computer where the X serverruns. An omitted hostname means the local host. The sequence number isusually 0 — it can be varied if there are multiple displays connectedto one computer.If you ever come across a display indication with an extra .n attachedto it, that’s the screen number. A display can actually have multiplescreens. 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 ClientThe client program (for instance, your graphics application) knowswhich display to connect to by inspecting the DISPLAY environmentvariable. This setting can be overridden, though, by giving the clientthe command line argument -display hostname:0 when it’s started. Someexamples may clarify things.Our computer is known to the outside as light, and we’re in domainuni.verse. If we’re running a normal X server, the display is known aslight.uni.verse:0. We want to run the drawing program xfig on a remotecomputer, 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:0dark% xfig &Or alternatively:dark% xfig -display light.uni.verse:0 &If you have sh running on the remote computer:dark$ DISPLAY=light.uni.verse:0dark$ export DISPLAYdark$ 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 theDISPLAY variable to the remote host. If you have one of those, you’relucky, and it’s automatic. If not, most versions of telnet _do_transport the TERM environment variable; with some judicious hackingit is possible to piggyback the DISPLAY variable on to the TERMvariable."

也不要说曾经失去,失去的不是永远失去,得到的不是永远拥有,

How do I set the DISPLAY variable on Linux – Jenny

相关文章:

你感兴趣的文章:

标签云: