NoMachine Support

Your questions answered

Knowledge Base

Searching in: Articles & FAQs
Filter the search results
Applies to:
Last update:
Searching in: Articles & FAQs
ID: AR04K00667
Applies to: NX Server Products
Added on: 2013-04-03
Last update: 2018-12-04
How to run a virtual desktop environment on Linux different from the default one with NoMachine

This article applies to NoMachine v. 4 or later.

During installation, NoMachine detects which is the default desktop environment set on the system and configures the node accordingly. When the user requests to create a new virtual desktop, the default desktop is launched automatically, in a transparent way for the user. There are two ways to run a session to a different desktop environment instead of the default one.

You can either choose to (i) run a custom session in virtual desktop mode after authentication: select the radio button 'Run the following command' and insert the path to the desired DE in the field provided.

Alternatively, (ii) the server or node host can be configured by making some changes to the node.cfg configuration file.

Below are the instructions on how to do (i) and (ii).

1. How to launch a desktop environment in a custom session
2. How to run a non-default virtual desktop environment
2.1. How to find out which desktop environments are already installed
3. How to run a specific virtual desktop environment on a per-user basis
4. How to install a desktop environment (some examples)


1. How to launch a desktop environment in a custom session

Create a wrapper script to launch the desktop of your choice.

Connect to the server and choose to 'Create a new custom session'.

In the 'Running the following command' field of the user's interface specify path to the wrapper script.

Be sure to select the 'Run the command in a virtual desktop' option.

You can also choose to save settings to re-use it at the next connection.


This is an example of a wrapper script, named nxsession, suitable for launching LXDE on for example Ubuntu 16.04:

/bin/kill -s SIGTERM $PPID

Place the nxsession file in the /usr/bin/ directory and add the execute permissions:

chmod +x /usr/bin/nxsession

When creating the new custom session, specify /usr/bin/nxsession as command.


2. How to run a non-default virtual desktop environment (some examples)

First step - ensure that the desktop environment of your choice is installed.

Second step - edit the /usr/NX/etc/node.cfg file.
You can use a text editor like Emacs or Vi/Vim. Be sure you have administrative privileges for saving changes to this file.

Third step - be sure that the DefaultDesktopCommand key is not commented (in case, remove the pre-pending #).

Set the proper command to start the desktop environment in the DefaultDesktopCommand key.

Changes will be effective from the start of the next session. No need to restart NoMachine services.

For example, to run the Xfce lightweight desktop on CentOS 7:

First step, install Xfce:

yum install -y epel-release && yum groupinstall Xfce

Then set the following in node.cfg:
DefaultDesktopCommand /"usr/bin/X11/startxfce4"


2.1. How to find which desktop environments are already installed

To find the desktop environments installed on your system:

1) Execute this command in a terminal:

ls /usr/share/xsessions

2) Then retrieve the command to start the desktop of your choice. Such command is written in the *.desktop file in the line starting with Exec.

For example:
grep ^Exec /usr/share/xsessions/gnome.desktop

Specify this command in the DefaultDesktopCommand key in node.cfg:
DefaultDesktopCommand gnome-session

Some other examples of commands:

Desktop Command
LXDE DefaultDesktopCommand "/usr/bin/startlxde"
XFCE DefaultDesktopCommand "/usr/bin/X11/startxfce4"
KDE DefaultDesktopCommand "/usr/bin/startkde"
MATE DefaultDesktopCommand "/usr/bin/mate-session"
CINNAMON DefaultDesktopCommand "/usr/bin/cinnamon"
UNITY DefaultDesktopCommand "/etc/X11/Xsession 'gnome-session -session=ubuntu' "
GNOME (on RHEL 7/CentOS 7) DefaultDesktopCommand "env GNOME_SHELL_SESSION_MODE=classic gnome-session -session gnome-classic"

Further references:
Use GNOME-classic or GNOME-Fallback



To use dbus-launch, specify command to start the desktop in the dbus-launch --exit-with-session <desktop command> format. E.g:

DefaultDesktopCommand "dbus-launch --exit-with-session gnome-session --session=ubuntu"

DefaultDesktopCommand "dbus-launch --exit-with-session cinnamon-session"

DefaultDesktopCommand "dbus-launch --exit-with-session startkde"

DefaultDesktopCommand "dbus-launch --exit-with-session mate-session"



3. How to run a specific virtual desktop environment on a per-user basis

If NoMachine is configured to use the default desktop environment on the system (i.e. you didn't customize the DefaultDesktopCommand key), you can define which desktop environment will be started for a certain user by configuring the .xsessionrc (on Debian, Ubuntu and derivatives) or the .xsession file (on RHEL and derivatives) in the user's home folder: ~/.xsessionrc or ~/.xsession.

For example, ensure that user nxtest01 has KDE as desktop environment on Ubuntu, edit the .xinitrc file in the home of user nxtest01 (/home/nxtest01/.xinitrc) and specify this command:

exec startkde

To ensure ensure instead that user nxtest02 will run a gnome-classic desktop environment on RHEL edit the nxtest02's .xsession file (home/nxtest01/.xsession) and specify this command:

/usr/bin/gnome-session --session=gnome-classic


4. How to install a desktop environment (some examples)


Ubuntu 16.04
apt-get install lxde-common

Fedora 27
dnf groupinstall lxde-desktop-environment

OpenSuseLeap 42.2
zypper -n in patterns-openSUSE-lxde

Debian 9
apt-get install lxde


Ubuntu 16.04
apt-get install xfce4

Fedora 27
dnf groupinstall xfce-desktop-environment

CentOS 7
yum install -y epel-release && yum groupinstall Xfce

OpenSuseLeap 42.2
zypper -n in patterns-openSUSE-xfce

Debian 9
apt-get install xfce4


Ubuntu 16.04
apt-get install mate-desktop-environment

Fedora 27
dnf groupinstall mate-desktop-environment

CentOS 7
yum install epel-release && yum groupinstall mate

OpenSuseLeap 42.2
zypper -n in patterns-openSUSE-mate

Debian 9
apt-get install mate-desktop-environment


Ubuntu 16.04
apt-get install ubuntu-desktop


Fedora 27
dnf groupinstall gnome-desktop

CentOS 7
yum groupinstall gnome-desktop

Debian 9
apt-get install task-gnome-desktop


Ubuntu 16.04
apt-get install plasma-desktop

Fedora 27
dnf groupinstall kde-desktop-environment

CentOS 7
yum groupinstall "KDE Plasma Workspaces”

Debian 9
apt-get install kde-plasma-desktop


Ubuntu 16.04
apt-get install cinnamon

Fedora 27
dnf groupinstall cinnamon-desktop-environment

CentOS 7
yum install epel-release && yum groupinstall cinnamon-desktop-environment

OpenSuseLeap 42.2
zypper install cinnamon

Debian 9
apt-get install task-cinnamon-desktop