• Get In Touch
September 9, 2016

Using a Desktop Environment on a CentOS 7 VPS

Want your very own server? Get our 1GB memory, Xeon V4, 25GB SSD VPS for £10.00 / month.
Get a Cloud Server

When you purchase a remote VPS or Cloud Server, it is likely that they will come with a command line interface only. If you want to use a graphical desktop to manage your server and do different tasks, you can follow this guide.

In this guide you will learn to install a different lightweight graphical desktop environment for your CentOS 7 system. You will also learn to install XRDP on your remote VPS so that you can use the graphical based interface from your computer.

Requirements

To follow this tutorial, you will need a VPS or Cloud Server running CentOS 7.x. Additionally you will also need access to the root user. If you are logged in as a non root user, run sudo -i to switch to root account. Running a Desktop Environment requires additional RAM compared to a command line interface, so make sure you have at least 512 MB, recommended is 1GB.

Installing the Desktop Environment

In this tutorial we will be installing GNOME, MATE and XFCE desktop environments. All of these environments are open source and come with different features. You can install any of these desktop environments depending on your choice. Please note that you should install only one desktop environment from the choices below. Installing more than one desktop environment will break your machine.

Before installing any package, it is recommended to upgrade your system and installed packages using the following command.

    yum -y update

Once the system is updated, you can proceed further to install any of these desktop environments.

Installing GNOME

GNOME is a desktop environment which is built using open source and free software only. GNOME is supported on almost all linux platforms. GNOME is in active development for past 17 years and being developed by The GNOME Project. Latest version of this software is GNOME 3, which is packed with many different features.

To install GNOME, run the following command.

    yum -y groupinstall "GNOME Desktop"

The above command will install many packages in your system, hence it will take some time according to your network and hardware speed. Now run the following command to start GNOME at boot time.

    ln -sf /lib/systemd/system/runlevel5.target /etc/systemd/system/default.target

Now reboot your system using init 6 command and proceed to Installation of XRDP on your system.

Installing MATE

MATE originated from unmaintained code of GNOME 2. It is also very popular desktop environment and it has been default desktop for Mint and Fedora.

MATE is not available in the default YUM repository hence you will also need to add EPEL repository in your system. To add EPEL repository run the following command.

    yum -y install epel-release
    yum -y update
    yum clean all

The above command will install the EPEL repository in your system and then, it will update the repository. Finally the last command will clear YUM cache from your system.

Now run the following command to install minimal X windows system in your system.

    yum -y groupinstall "X Window system"

Now run the following command to install MATE graphical desktop system.

    yum -y groupinstall "MATE Desktop"

MATE desktop installs less packages in your system as compared to GNOME desktop, hence it will take less time compared to GNOME. Additionally we can say it is more lightweight than GNOME desktop.

Now run the following command to start GUI or MATE desktop at boot time.

    systemctl set-default graphical.target

You should see following output:

    [root@Mate ~]# sudo systemctl set-default graphical.target
    Removed symlink /etc/systemd/system/default.target.
    Created symlink from /etc/systemd/system/default.target to /usr/lib/systemd/system/graphical.target.

Now reboot your system using init 6 command and proceed to Installation of XRDP on your system.

Installing XFCE

XFCE is another open source graphical desktop environment, it is written in C. XFCE is recommended desktop environment for remote servers as it is lightweight and fast hence does not uses much amount of hardware resources.

XFCE is not available in default YUM repository hence you will also need to add EPEL repository in your system. To add EPEL repository run the following command.

    yum -y install epel-release
    yum -y update
    yum clean all

The above command will install EPEL repository in your system and then, it will update the repository. Finally the last command will clear YUM cache from your system.

Now run the following command to install minimal X windows system in your system.

    yum -y groupinstall "X Window system"

Now run the following command to install XFCE desktop in your system.

    yum -y groupinstall xfce

Now run the following command to start GUI or XFCE desktop at boot time.

    systemctl set-default graphical.target

You should see following output:

    [root@Mate ~]# sudo systemctl set-default graphical.target
    Removed symlink /etc/systemd/system/default.target.
    Created symlink from /etc/systemd/system/default.target to /usr/lib/systemd/system/graphical.target.

Now reboot your system using init 6 command and proceed to Installation of XRDP on your system.

Installing XRDP

Hopefully you have successfully installed any of the abov graphical desktop environments. Now as we have our desktop ready, we will need to install XRDP into our machine so that we can access the remote machine in graphical mode. XRDP supports windows remote desktop client as well as VNC viewer.

To install XRDP on your system, you will need to add EPEL repository in your system. If you have it installed previously, you can skip, or you can install EPEL using following commands.

    yum -y install epel-release
    yum -y update
    yum clean all

Now run the following commands to install XRDP into your machine.

    yum -y install xrdp tigervnc-server

Now you will need to make changes to your SELINUX. You can either adjust your SELINUX using the following commands.

    chcon --type=bin_t /usr/sbin/xrdp
    chcon --type=bin_t /usr/sbin/xrdp-sesman

You will also need to adjust your firewall rules to allow port number 3389, on which RDP service will listen to. Run the following commands for same.

    firewall-cmd --permanent --zone=public --add-port=3389/tcp
    firewall-cmd --reload

Now you can start XRDP on your system using following command.

    systemctl start xrdp

To automatically start XRDP on boot time run the following command.

    systemctl enable xrdp

To check if XRDP service is running, use the following command.

    netstat -antup | grep xrdp

You will get following output.

    [root@ip-172-31-24-179 ~]# netstat -antup | grep xrdp
    tcp        0      0 127.0.0.1:3350          0.0.0.0:*               LISTEN      23532/xrdp-sesman
    tcp        0      0 0.0.0.0:3389            0.0.0.0:*               LISTEN      23533/xrdp

You can also use the following command to check the status of XRDP service.

    systemctl status xrdp

You should see following output.

    [root@ip-172-31-24-179 ~]# systemctl status xrdp
    ● xrdp.service - xrdp daemon
       Loaded: loaded (/usr/lib/systemd/system/xrdp.service; disabled; vendor preset: disabled)
       Active: active (running) since Wed 2016-09-07 03:27:39 UTC; 2s ago
     Main PID: 23579 (xrdp)
       CGroup: /system.slice/xrdp.service
               └─23579 /usr/sbin/xrdp --nodaemon

    Sep 07 03:27:39 ip-172-31-24-179 systemd[1]: Started xrdp daemon.
    Sep 07 03:27:39 ip-172-31-24-179 systemd[1]: Starting xrdp daemon...

Connecting to CentOS Machine

If you are on windows machine you can use the inbuilt Remote Desktop Client to connect to the CentOS machine running your favorite graphical desktop environment.

Start remote desktop client from search or you can also run mstsc command at run prompt.

Enter the IP address of your remote machine Computer field.

HP_NO_IMG/data/uploads/users/166e68d1-e927-457c-b7b0-14eca571ad0c/1852332012.png” alt=”” />

Then click on Show Options, and click on Display tab. Select True Colour (24 bit) from the dropdown menu of Colours.

HP_NO_IMG/data/uploads/users/166e68d1-e927-457c-b7b0-14eca571ad0c/181828492.png” alt=”” />

Finally click Connect button and you will see a warning saying that the identity of remote machine is not verified, click OK to proceed and you will see the prompt to enter the username and password of your remote machine.

HP_NO_IMG/data/uploads/users/166e68d1-e927-457c-b7b0-14eca571ad0c/872724407.png” alt=”” />

Once you are logged in, you will see the following screen.

HP_NO_IMG/data/uploads/users/166e68d1-e927-457c-b7b0-14eca571ad0c/716095169.png” alt=”” />

Conclusion

In this tutorial we have learned to install different graphical environments. We also learned to install XRDP to enable RDP server on your system. We also learnt to connect to your remote machine using windows Remote Desktop Client.

Want your very own server? Get our 1GB memory, Xeon V4, 25GB SSD VPS for £10.00 / month.
Get a Cloud Server

Share this Article!

Related Posts

Node.js Authentication – A Complete Guide with Passport and JWT

Node.js Authentication – A Complete Guide with Passport and JWT

Truth be told, it’s difficult for a web application that doesn’t have some kind of identification, even if you don’t see it as a security measure in and of itself. The Internet is a kind of lawless land, and even on free services like Google’s, authentication ensures that abuses will be avoided or at least […]

Node.js and MongoDB: How to Connect MongoDB With Node

Node.js and MongoDB: How to Connect MongoDB With Node

MongoDB is a document-oriented NoSQL database, which was born in 2007 in California as a service to be used within a larger project, but which soon became an independent and open-source product. It stores documents in JSON, a format based on JavaScript and simpler than XML, but still with good expressiveness. It is the dominant […]

Using MySQL with Node.js: A Complete Tutorial

Using MySQL with Node.js: A Complete Tutorial

Although data persistence is almost always a fundamental element of applications, Node.js has no native integration with databases. Everything is delegated to third-party libraries to be included manually, in addition to the standard APIs. Although MongoDB and other non-relational databases are the most common choice with Node because if you need to scale an application, […]

Node.Js Vs Django: Which Is the Best for Your Project

Node.Js Vs Django: Which Is the Best for Your Project

Django and NodeJs are two powerful technologies for web development, both have great functionality, versatile applications, and a great user interface. Both are open source and can be used for free. But which one fits your project best? NodeJs is based on JavaScript, while Django is written in Python. These are two equally popular technologies […]

Nodejs Vs PHP:  Which Works Best?

Nodejs Vs PHP: Which Works Best?

Before getting into the “battle” between Node.js and PHP we need to understand why the issue is still ongoing. It all started with the increased demand for smartphone applications, their success forcing developers to adapt to new back-end technologies that could handle a multitude of simultaneous requests. JavaScript has always been identified as a client-side […]