The environment variable DISPLAY tells all X clients, including Emacs, where to display their windows. Its value is set up by default in ordinary circumstances, when you start an X server and run jobs locally. Occasionally you may need to specify the display yourself; for example, if you do a remote login and want to run a client program remotely, displaying on your local screen.
With Emacs, the main reason people change the default display is to let them log into another system, run Emacs on that system, but have the window displayed at their local terminal. You might need to log in to another system because the files you want to edit are there, or because the Emacs executable file you want to run is there.
The syntax of the DISPLAY environment variable is host:display.screen, where host is the host name of the X Window System server machine, display is an arbitrarily-assigned number that distinguishes your server (X terminal) from other servers on the same machine, and screen is a rarely-used field that allows an X server to control multiple terminal screens. The period and the screen field are optional. If included, screen is usually zero.
For example, if your host is named glasperle and your server is the first (or perhaps the only) server listed in the configuration, your DISPLAY is glasperle:0.0.
You can specify the display name explicitly when you run Emacs, either by changing the DISPLAY variable, or with the option -d display or -display=display. Here is an example:
emacs --display=glasperle:0 &
You can inhibit the direct use of the window system and GUI with the -nw option. It tells Emacs to display using ordinary ASCII on its controlling terminal. This is also an initial option.
Sometimes, security arrangements prevent a program on a remote system from displaying on your local system. In this case, trying to run Emacs produces messages like this:
Xlib: connection to "glasperle:0.0" refused by server
You might be able to overcome this problem by using the xhost command on the local system to give permission for access from your remote machine.