English
+370 5 205 5502 sales@monovm.com

Want to have a remote connection and a GUI on a Linux server? Throughout this step-by-step tutorial, we will show you how yo get exactly that.

22

May, 19

Install GNOME and VNC Server on CentOS

Linux servers are based on a command-line interface by default, however, some might want to use them with a visual interface. In these cases, we can install an application which provides a GUI (i.e. Graphical User Interface). One of such applications is named GNOME and you can follow the steps outlined below to get it on your machine.

Please note: our Linux server is running Centos 7 and the following codes might vary for other distributions.

At first, we should update the OS:

Yum update -y

After completion, install Gnome with the following command:

sudo yum groupinstall -y "GNOME Desktop"

Please note: to install this package, you must have at least 2.2Gb of free space.

Now, reboot server after the installation is complete.

Install VNC server to have remote access to the server:

sudo yum install -y tigervnc-server 

Now, we want to configure the VNC server for the client. In this case, we should copy the generic VNC service unit file under /etc/system/system.

sudo cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:4.service 

Please note: to make multiple connections with multiple clients, you should define users and make a copy of the file for each user. Also, you should change the port of each user.  We defined port 5904 for our user with vncserver@:4.service in the previous command.

Open the copied file to change the configuration with vi command.

sudo vi /etc/systemd/system/vncserver@:4.service

go to [service] section and replace username and screen resolution with default values:

[Service]

Type=forking# Clean any existing files in /tmp/.X11-unix environmentExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'ExecStart=/sbin/runuser -l root -c "/usr/bin/vncserver %i -geometry 1280x1024" PIDFile=/home/root/.vnc/%H%i.pid

Then save the file and exit. Run the following command to reload daemon and the user will be enabled during boot time.

sudo systemctl daemon-reloadsudo systemctl enable vncserver@:4.service 

Now we should add the ports to the firewall.

sudo firewall-cmd --permanent --zone=public --add-port=5904/tcp 

Then, reload the firewall:

sudo firewall-cmd --reload

In this step, we should start the VNC server. Run below command and set a password to the VNC server.

Vncserver 

The output should look something like this:

You will require a password to access your desktops.

Password:

Verify:

Now restart the VNC server and reload the services:

vncserversudo systemctl daemon-reloadsudo systemctl restart vncserver@:4.service 

Open VNC viewer from your PC and type the server IP followed by port and click on Connect.

Install GNOME and VNC Server on CentOS

Enter the password we set previously:

 gnome2

You should now be able to see the welcome screen:

gnome3

Oliver K

I’m Oliver k. I have MS degree in Computer Engineering. For nearly 5 years that I have been working on web programing and also in last 2 years I have worked on windows and Linux VPS. This is my honor to share my experiences with a new community.