Multiple Virtual Displays on One Linux PC. Running Concurrently. Now That’s Greedy!

kubuntu 13:10 and Ubuntu 13:10 Desktop Screenshots
Kubuntu 13:10 and Ubuntu 13:10 Desktop Screenshots

What could be better than looking at one beautiful Linux desktop? How about looking at 2 desktops or 3 or 4 desktops.. all running different apps and different desktop environments? All managed from one computer.

We are talking here about independent desktops running independent apps running from the same computer and all running simultaneously.

Think about that: we can log into a Gnome environment, a KDE environment, a Unity environment and any of the other Linux desktop environments without logging out of a single one. They can all run together on the same computer. Simultaneously.

Multiple monitors not required

Linux is full of surprises. Having multiple virtual desktops to slide apps between is good. Opening multiple virtual displays with each display using its own desktop manager and its own desktop environment is loads more fun.

What is a virtual display?

You are reading this guide to using virtual displays on a monitor attached to your computer. Your monitor displays one desktop environment. If you want to display another desktop from your computer you could attach a second monitor. What if you don’t have a second monitor? Well, you can use a virtual display.

Virtual displays let us use one computer with one attached monitor to show multiple desktop sessions running independent desktop instances on that same computer.

We have access to 6 command-line shells from which 6 desktop sessions and 6 displays can be spawned. Displays are numbered 0 to 5 and correspond to function keys F7 through F12. This is the typical set-up for a Linux OS.

The default display — the one you see when you log into your computer — is display 0. The terminal for this display is under key combination Ctrl+Alt+F1. From a shell environment, this display is usually accessed by pressing Ctrl+Alt+F7.

Test those key combinations. Press Ctrl+Alt+F1 then press Ctrl+Alt+F7 to switch between the shell environment and the GUI display environment. If F7 does not bring your desktop back, try Ctrl+Alt in combination with any of F8, F9, F10, F11 or F12. F7 will usually work fine.

Function keys F1 through F6 give access to one of six Linux shell environments. Pressing Ctrl+Alt+F1 through F6 will drop you into a shell environment.

More details about getting into the Linux shell here.

In other words, one physical computer, keyboard, mouse and display can be used to run multiple desktop sessions by one or more users. Each desktop initialized on a virtual display is accessed by pressing Ctrl+Alt+ a function key from F7 to F12. The function key that is typically used to make a display visible is the key that is associated with the shell a user is logged into.

Table 1: Display, Shell & Desktop Mappings
Display Number012345
Shell KeyF1F2F3F4F5F6
Desktop KeyF7F8F9F10F11F12

How to initialise a virtual display

The easiest way to start a desktop environment from a shell is to type startx while logged into a command-line shell. Doing this will spawn a desktop session on display 0 which can be viewed by pressing Ctrl+Alt+F7.

If you usually log into GNOME, typing startx will spawn a GNOME session. This will not be your usual desktop session which is nicely configured to look and behave the way you want it to do. The startx command opens a default desktop session using the system’s default desktop environment such as KDE or GNOME.

Typing just startx at a terminal prompt will launch a display for that terminal session. If we drop to a shell with Ctrl+Alt+F2 then type startx, we will launch display 1. If we drop to another shell with Ctrl+Alt+F1, we will be able to get back to the display opened for Ctrl+Alt+F2 by pressing Ctrl+Alt+F8.

See table 1, above, to view the typical terminal and display key combination mappings.

How to specify which display to spawn

Command-line shells are not fixed to opening a specific display and desktop session. We can specify which virtual desktop to open a display on.

Drop to a shell by pressing Ctrl+Alt+F3 then tell X to start another desktop session by typing,

startx -- :2

The part after the two dashes is an instruction to xserver. The colon and the number, :2, tell xserver which display number to open. startx – – :2 opens a desktop session on display 2. Display 2 is usually mapped to F9 so this new display can be accessed by pressing Ctrl+Alt+F9.

Type man startx and man xserver at a command-line prompt to learn more about the options we can use to configure a new session when initializing one.

How to set the display manager used for a session

We can start a desktop session with any installed display manager. When we open a desktop session with a display manager we can log into our normal desktop environment and it will behave as we have configured it to behave.

We tell Linux which display manager to load by specifying the path to the binary file (executable file) of the display manager we wish to use. Display manager binary files are usually stored in the directory /usr/bin/.

To start a KDE session using KDM to log into virtual display 1 we would type

startx /usr/bin/kdm -- :1

To start a GNOME session using GDM to log into virtual display 2 we would type

startx /usr/bin/gdm -- :2

Remember that display 0 is mapped to F7, display 1 is mapped to F8 and display 2 is mapped to F9 and so on. Press Ctrl+Alt+F8 to view virtual display 1 or Ctrl+Alt+F9 to view virtual display 2.

The exact location of display manager binary files can be found with the locate command. New display managers can be installed with aptitude,  apt or yum, depending on your distro.

Easier way to start a Linux display

Some Linux distros like Ubuntu and Kubuntu will let us stop a display with the command sudo stop [display manager] and start a display with sudo start [display manager]. For example:

To stop KDE, we can use

sudo stop kdm

To start KDE, we can use

sudo start kdm

We use kdm and not kde in the above command examples because we need to stop and start the display manager and not the desktop environment. The display manager stops and starts the desktop environment.

When we start a display this way we launch the display that is mapped to the terminal we are in. If we dropped to shell with Ctrl+Alt+F1 and typed sudo start lightdm then Kubuntu would launch display 0 with the LightDM display manager; display 0 would be spawned at Ctrl+Alt+F7.

Non recommended way to spawn a display

Another way to spawn a Linux virtual display from the command line is to use Xorg. This is not recommended in the xorg man page. The way to start X with Xorg is Xorg :[Display Number]. For example:

Xorg :1

Pay attention to the capitalization of the X. The capital X is deliberate and necessary.

How to keep desktop configurations separate

Opening multiple desktop sessions for use by the same user will cause each desktop to use the same configuration files. Although different applications can be opened in different sessions and the same applications can be opened in different sessions concurrently, changes made to the settings within each application will affect each active desktop session unless each concurrent desktop session is opened by a different user.

If you wish to use different configurations for each desktop environment and for each application then you need to login as a different user for each simultaneous session.

New users can be added at the command line with the adduser command.

Summary notes

  • For a Linux computer with 6 allowed shell sessions, the virtual displays are numbered 0 to 5
  • Shell sessions are mapped to function keys F1 through F6
  • Virtual displays are mapped to function keys F7 through F12
  • A virtual display can be spawned from a shell by typing (for example) startx /usr/bin/kdm or startx /usr/bin/gdm
  • In some distros like Kubuntu and Ubuntu a virtual display can be opened with sudo start kdm or sudo start gdm or sudo start lightdm etc…
  • A user who is logged into a terminal session can usually spawn a virtual display
  • A single user can open more than one desktop environment simultaneously
  • More than one user can use the same Linux computer at the same time and each can use 1 or more of his own desktop environments

Sharing is caring!

Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

2 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
2
0
Would love your thoughts, please comment.x
()
x