Setting display variable linux

How can I specify a display?

I would like to open many displays, still showing the stdout of each program. Initial Question: How can I specify the display to get a many-displayed program? Pablo Santa Cruz gives me the following code as a solution. I do not understand it.

$ export DISPLAY=yourmachine.yourdomain.com:0.0 $ firefox & 

12 Answers 12

The way that X works is the same as the way any network program works. You have a server of some description (in this case, the X display server) which runs on a specific machine, and you have X clients (like firefox) that try to connect to that server to get their information displayed.

Often (on «home» machines), the client and server run on the same box and there’s only one server, but X is powerful enough that this doesn’t need to happen. It was built with the server/client separation built in from the start.

This allows you to do such wondrous things such as log on to your box (in text mode) halfway around the planet, tell it that the display server is the box you’re currently on and, voila, the windows suddenly start appearing locally.

In order for a client to interact with a user, it needs to know how to find the server. There are a number of ways to do this. Many clients allow the -display or —display option to specify it:

xeyes -display paxbox1.paxco.com:0.0 

Many will use the DISPLAY environment variable if a display isn’t specifically given. You can set this variable like any other:

DISPLAY=paxbox1.paxco.com:0.0; export DISPLAY # in .profile export DISPLAY=paxbox1.paxco.com:0.0 # in your shell DISPLAY=paxbox1.paxco.com:0.0 firefox & # for that command (shell permitting) 

The first part of the DISPLAY variable is just the address of the display server machine. It follows the same rule as any other IP address; it can be a resolvable DNS name (including localhost ) or a specific IP address (such as 192.168.10.55).

The second part is X-specific. It gives the X «display» (X server) number and screen number to use. The first (display number) generally refers to a group of devices containing one or more screens but with a single keyboard and mouse (i.e., one input stream). The screen number generally gives the specific screen within that group.

+----------------------------------------+ |paxbox1.paxco.com| | +-----------------+ | | | | +----------+----+ +----------+----+ | | |Display :0| | |Display :1| | | | +----------+ | +----------+ | | | | | | | | | | +-----------+ | | | | | | |Screen :0.0| | | | | | | +-----------+ | | | | | | +-----------+ | | | | | | |Screen :0.1| | | | | | | +-----------+ | | | | | | +-----------+ | | +-----------+ | | | | |Screen :0.2| | | |Screen :1.0| | | | | +-----------+ | | +-----------+ | | | | +-----------+ | | +-----------+ | | | | |Screen :0.3| | | |Screen :1.1| | | | | +-----------+ | | +-----------+ | | | | +-----------+ | | +-----------+ | | | | | Keyboard | | | | Keyboard | | | | | +-----------+ | | +-----------+ | | | | +-----------+ | | +-----------+ | | | | | Mouse | | | | Mouse | | | | | +-----------+ | | +-----------+ | | | +---------------+ +---------------+ | | | +----------------------------------------+ 

Here you have a single machine ( paxbox1.paxco.com ) with two display servers. The first has four screens and the second has two. The possibilities are then:

DISPLAY=paxbox1.paxco.com:0.0 DISPLAY=paxbox1.paxco.com:0.1 DISPLAY=paxbox1.paxco.com:0.2 DISPLAY=paxbox1.paxco.com:0.3 DISPLAY=paxbox1.paxco.com:1.0 DISPLAY=paxbox1.paxco.com:1.1 

depending on where you want your actual windows to appear and which input devices you want to use.

Источник

How to set display variable for Ubuntu

So i’m using Cygwin on my local windows machine with Xming Xserver. What I want to do is set the display variable so I can use the full graphical version of my code editor(XEmacs) on the server. At the moment I can only SSH into my Ubuntu server and use the text version of the program. Has anyone got any ideas? Is this a permissions error or is there something I’m missing

Читайте также:  Линукс снс что это

2 Answers 2

First of all, you should tell us what commands you have tried and what was the output you got from them.

ssh -CX barney@server xemacs

The -C option is to enable compression. The -X option is to enable X11 forwarding. See the man page of ssh for details.

If you’re on a local network this should work fine. If you have a high latency you’ll get a little frustrated.

This should work from Linux to Linux, I’m not sure about cygwin since I’ve never used it.

i voted for this answer based on Cygwin’s documentation: Displaying remote X clients with Cygwin/X is nearly identical to displaying remote X clients with any other X Server. You may use the secure ssh method, or the insecure telnet or rsh method (not recommended).

Cygwin’s documentation advises to use -Y instead. Since -Y works, I’d reason that -X works too, but may require special configuration. Pay attention to the notes:

Note: The ssh server will automatically set the DISPLAY environment variable appropriately, typically to something like localhost:10.0, so clients will connect to a proxy X11 display on the remote host from which the X11 protocol will be forwarded over ssh to your X server.

If your login scripts unconditionally set DISPLAY to something else, this will break X11 forwarding.

Note: By default, the OpenSSH server does not allow forwarded X connections. This must be configured on the remote host by adding X11Forwarding yes to the sshd_config configuration file. The OpenSSH server must be restarted or SIGHUP’ed to re-read the configuration file after it is changed.

Note: The OpenSSH server requires the xauth command to be available to forward X connections. Consequently, it must be installed on the remote host.

Источник

What is the $DISPLAY environment variable?

The magic word in the X window system is DISPLAY. A display consists (simplified) of:

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.

The remote server knows where it has to redirect the X network traffic via the definition of the DISPLAY environment variable which generally points to an X Display server located on your local computer.

The value of the display environment variable is:

hostname is the name of the computer where the X server runs. An omitted hostname means the localhost.

D is a sequence number (usually 0). It can be varied if there are multiple displays connected to one computer.

S is the screen number. A display can actually have multiple screens. Usually, there’s only one screen though where 0 is the default.

Читайте также:  Create file group linux

hostname:D.S means screen S on display D of host hostname; the X server for this display is listening at TCP port 6000+D.

host/unix:D.S means screen S on display D of host host; the X server for this display is listening at UNIX domain socket /tmp/.X11-unix/XD (so it’s only reachable from host).

:D.S is equivalent to host/unix:D.S, where host is the local hostname.

:0.0 means that we are talking about the first screen attached to your first display in your local host

From the user’s perspective, every X server has a display name of the form:

hostname:displaynumber.screennumber

This information is used by the application to determine how it should connect to the server and which screen it should use by default (on displays with multiple monitors):

hostname The hostname specifies the name of the machine to which the display is physically connected. If the hostname is not given, the most efficient way of communicating to a server on the same machine will be used. displaynumber The phrase «display» is usually used to refer to a collection of monitors that share a common keyboard and pointer (mouse, tablet, etc.). Most workstations tend to only have one keyboard, and therefore, only one display. Larger, multi-user systems, however, frequently have several displays so that more than one person can be doing graphics work at once. To avoid confusion, each display on a machine is assigned a display number (beginning at 0) when the X server for that display is started. The display number must always be given in a display name. screennumber Some displays share a single keyboard and pointer among two or more monitors. Since each monitor has its own set of windows, each screen is assigned a screen number (beginning at 0) when the X server for that display is started. If the screen number is not given, screen 0 will be used.

In normal This must not happen unless there is a problem in your display.. Mostly a restart of your display manager will solve the problem. But this is not a default action.

@ChandrayyaGK For example, when I’m not using any desktop environment like GNOME or KDE, but directly log in with TTY (like /dev/tty1 ), I got the blank $DISPLAY .

@Maythux Sometimes the screen number seems to be omitted when being 0. My GNOME gives :0 for $DISPLAY .

The existing answers fail to address the broader picture.

If you are not using a graphical environment (i.e. you are logging in on the system console with no windows etc; or you are logging in remotely from a text-only terminal over SSH or similar, such as from a Windows computer running PuTTY) then no GUI is involved, and DISPLAY will typically be unset. Your only means of communicating with the computer is the command line (though there may be ways to pivot into a GUI session if you know how).

If you are logging in on the console with a graphical interface (on Ubuntu, typically the GDM greeter is used) or using a graphical terminal (such as from a Windows computer running eXceed or mobaX, or remote desktop software like a VNC client) the DISPLAY variable is set up by the program which manages your graphical session to indicate to graphical clients which I/O devices to connect to.

Читайте также:  Add known host linux

Traditionally, the GUI on an Ubuntu computer was running X.org, an X11 implementation, though more recently, a modernized replacement called Mir was introduced by Canonical; and even more recently, I believe Mir will be abandoned in favor of another project with broadly similar goals called Wayland. These replacements are intended to reduce the complexity of a full X11 stack, which we will not be going into here — they adhere to the same DISPLAY convention, which is after all what we are discussing here.

On X11, the host part of DISPLAY could be a remote server, and you would use your Ubuntu computer as a «graphical terminal» to access files and programs on that remote server (in which case your computer is the «server» which serves a keyboard, a mouse, and one or more display devices to «client» programs running on the remote . server). More commonly, the X11 (or Mir, or Wayland) server and the client programs (a desktop manager and various graphical clients such as a web browser, an email client, a calendar program, etc) all run on your computer. This is indicated by the «server» part of the DISPLAY value, which in the latter case is typically empty (which implies the default value, localhost ).

An X11 server may run one or more graphical sessions — for example, your console login and a remote VNC session could be running at the same time. In this case (if they are managed by the same X11 server instance) you have more than one «display» in X11 terms. In practice, one session (one login event and the desktop instance spawned from this) is one display in X11.

One such display can have one or more screens. Traditionally, this meant one monitor, though the original architecture had some unfortunate traits such as the inability to move a window from one screen to another. Add-ons like Xinerama and Xrandr further muddied the situation to the point where one screen often connects multiple monitors in various ways.

If you have played with multiple-monitor systems, you have probably discovered that you can arrange monitors in various ways and end up with a rectangular area where your monitors display some parts of it and other parts are not assigned to any monitor. This is the «screen» that X11 creates, and if you have more than one display card, you can have multiple of these screens, each assigned to one or more monitors (or in theory, running without a monitor; Xvfb exploits this to allow you to run X11 without any monitors, simply mapping the GUI to a memory region for whatever purpose).

Источник

Оцените статью
Adblock
detector