VNC (Virtual Network Computer) is a low-bandwidth cross-platform display system. VNC is a system for controlling a computer remotely and sharing desktops over a network using a graphical interface. Access to a remote desktop requires a VNC server installed on the remote system, a VNC viewer on the system from which access is being established and, optionally, a secure SSH connection.
Sometimes you may have to kill a particular VNC session from a Linux box. This post outlines the steps to kill a VNC session from the command line using the vncserver command.
1. Stop entire VNC service:
[root@server ~]# service vncserver stop
2. Kill individual VNC Sessions. To stop individual VNC session, you need to first login as the user account that associated with the VNC session. For example if you assigned VNC session 1 (:1) for the user “nix”, login as “nix” and run the below command
[nix@server ~]# vncserver -kill :1
3. To start VNC session again:
[nix@server ~]# vncserver :1
4. Command to Start new VNC Session:
[nix@server ~]# vncserver :2
5. Find Running VNC server sessions (login as associated user first):
[nix@server ~]# vncserver -list
Killing All VNC sessions
You can also use the following command to kill all currently running VNC server sessions:
$ vncserver -kill :* Killing Xtigervnc process ID 1607... success! Killing Xtigervnc process ID 5287... success!
You start the VNC server on your remote Linux database server by running vncserver and a port number. Like the other Linux daemons–such as httpd, which usually listens on port number 80, and sshd, which usually listens on 22–the VNC server listens on port number 5901 by default. If you include a port number when running vncserver, the actual port number is plus 5900. For example, if you run vncserver :9, then the VNC server listens on port number 5909.
To manually stop the VNC server on your Linux database server, run the Linux command vncserver -kill, and provide the same port number you used when starting the VNC server. For example:
# /usr/bin/vncserver -kill :9 Killing Xvnc process ID 13836