On a Raspberry Pi, as in any Linux system, it is possible to manage multiple graphical sessions simultaneously.
X11 or the X Window System is a windowing system for Unix and Linux systems that provides the foundation for the graphical user interface (GUI). It allows users to run graphical applications and manage windows on their desktop.
This can be useful for running multiple graphical applications in different X11 (X Window System) sessions without interfering with each other. It is also very useful when we have a Raspberry Pi in a setup with multiple displays, some of which may be “non-standard”.
For example, this is common in the case of a machine intended to play a video, or an application, or even a robot with a screen, where one of the displays is not a “normal” screen.
In this article, we will explore how to run a graphical application in another X11 session on Raspberry Pi and, if necessary, how to access another user’s session by importing their authentication token.
Run Application in Another Session
To run an application in another X11 session, we use the following command:
DISPLAY=:0.0 applicationName &
Here,
DISPLAY=:0.0indicates that the application will run on the first X11 session (:0) and on the first screen of that session (.0).- The
&character at the end of the command allows the application to run in the background.
Run in Another User’s Session
If we need to run the application in an X11 session that belongs to another user, we must first import the authentication token (xauth token) of the user who owns that session.
This is done with the following command:
xauth merge ~user/.Xauthority
In this command,
~user/.Xauthorityis the path to the other user’s.Xauthorityfile, which contains the information needed to authenticate to their X11 session.
By executing this command, we import that authentication token into our session, allowing us to run applications in the other user’s session.

