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.