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.
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).
echo $DISPLAY
is printing:0
NOT:0.0