DISPLAY environment variable indicates to applications where to send GUI commands such as “create a window”, “display some text”, “draw an image”, “wait for a key or mouse click”, etc. It's the counterpart for graphical user interfaces of the standard streams for text mode applications.
For the most part, you don't need to care about this variable. If you run a program from a GUI session, the variable is already set. If you run a program over SSH, the variable is set automatically if you're forwarding the GUI, and if it's not set, that indicates that you aren't forwarding the GUI and setting the variable won't help. You only need to set the variable when you want to interact with a GUI session from the outside, for example to run a GUI program in a cron job, or to display a program on a machine's screen with the program started from an SSH session to that machine.
To start a GUI session, there are two methods: either log in first then start the GUI, or start the GUI and log in from there.
- If you've logged in on a text mode console, you can start the GUI environment with the command
startx. This command starts an X11 server (the GUI backend, that does basic things like remember that a certain window is at a certain position) as well as a bunch of useful applications, typically at least a window manager (a program that provides ways to switch between windows, to move windows around and control which one is active, to start programs, etc.) and often a desktop environment (that completes the window manager with additional screen widgets and utilities such as a clock, a desktop switcher, an icon tray, a session saver, etc.).
- Most distributions for desktop use set up a display manager. The X server runs and the only program on screen is the display manager, which is a program that displays a login prompt. Once you log in, a session is started, just like the second part of
startx (with a window manager, etc.).
If you haven't installed a display manager, you can choose between
slim, etc. Use e.g.
sudo yum install gdm to install one.
If you don't want to install a window manager, or you want to start a GUI session from a console login for any reason, run just
sudo startx. Many GUI programs are not meant to run as root and some environments will simply refuse to start if they're running as root.