Fix: xterm: DISPLAY is not set

Xterm is the X window emulator used to run command-line programs. We can also establish connections to remote machines using the ssh service. Sometimes Linux users face the issue of “xterm: DISPLAY is not set” while using the xterm package.

This error can be fixed by the methods explained in this write-up. The blog’s contents are:

Let’s get into the reasons and solutions for this error.

Reason: xterm Display variable is not set

The application of the “xterm” needs the GUI interface, which means it works on the Unix/Linux distributions that have the desktop environment. When installed and run on the Linux, which has no desktop environment. it will display the error “xterm: DISPLAY is not set”. For example, we have installed and run the “xterm” on the Ubuntu server with the command:

$ xterm

The above figure shows that the error “xterm: DISPLAY is not set”.

Solution: Set the Value of the DISPLAY Variable

From the error, we can see that this error is associated with the variable “DISPLAY”. We have to set the value of the DISPLAY environmental variable to the localhost. This can be set with the export command:

$ export DISPLAY=localhost:0.0

Then, connect to the local machine using the username and IP address of that machine with the ssh command:

The connection has been established with the “itslinux” and its terminal is displayed on the new window:

This is the simplest way to fix “xterm: DISPLAY is not set”.

That’s how you can fix the error “xterm: DISPLAY is not set”.


To fix the “xterm: DISPLAY is not set”, we have to set the value of the DISPLAY environment variable. This error occurs when you use the xterm on UNIX devices that do not support any desktop environment. This post has demonstrated the reason and solution of the error “xterm: DISPLAY is not set”.