VNC stands for virtual network computing and is a way of offering desktop capability to operating systems. it works well on both windows and linux.
today we want to show how to install vnc server on CentOS 7 linux. installing vnc server on windows is straightforward.
Here is our environment:
OS: CentOS 7 linux on VMware
IP address: 192.168.26.129
1- Install prerequisites
in order to use vnc, we need to install one of the two most usable x window systems: GNOME or KDE.
it’s up to you to choose between these two x window system, but here we will install GNOME:
# yum groupinstall "GNOME Desktop"
2- Install VNC server
after installing GNOME, it’s time to install vnc server itself. so issue the following command:
# yum install tigervnc-server xorg-x11-fonts-Type1
3- Configure VNC server
for configuring vnc server, we need to run the following command:
# cp /lib/systemd/system/[email protected] /etc/systemd/system/vncserver@:3.service
mind “:3” in above command. it’s related to port which vnc server will listen to and it will be 5903. if you want to change it, you can use another number like 1 or 2 or any other.
so if you change it to 1, vnc server will listen to port 5901.
now open config file and change <USER> to user you want vnc server run by. here we will use root (remember that it’s dangerous):
# vim /etc/systemd/system/vncserver@:3.service
also becuase here we use root user, the following line needs to to be changed and remove /home:
Note: if you want to change resolution and also default port, you should edit /usr/bin/vncserver and change these lines:
$vncPort = 5900 + $displayNumber; $geometry = "1024x768";
remember the above change will affect all users. if you want to change resolution per user, you should edit config file for that user. here we use root user:
# vim /root/.vnc/config
then because service config file has been changed, daemon needs to be reloaded:
# systemctl daemon-reload # systemctl enable vncserver@:3.service
4- Configure firewall
based on configuration in previous step, if you use default port for vnc server, you should open port 5903 on your firewall.
here we will use csf as firewall.
5- Start vnc server
finally start vnc server service:
# systemctl start vncserver@:3.service
because it’s first time, we need to set password to access by vnc client. so run the following command:
6- Access remote desktop
now, if you use windows, simply download and install vnc viewer from Realvnc website.
if you use Centos linux simply install tigervnc:
# yum install tigervnc
then use sever address such the following:
replace above IP address with your own.