Force Stop a VNC Server Session in UNIX & Linux

1. Login to your operating system. Check the VNC server process in the system.

# ps -ef | grep vnc
nobody   10639  4192  0 02:40 ?        00:00:16 Xvnc :42 -inetd -once
root     11388     1  0 03:45 pts/1    00:00:00 Xvnc :2 -desktop X
nobody   11422  4192  0 03:49 ?        00:00:00 Xvnc :42 -inetd -once
root     13445 13388  0 12:54 pts/3    00:00:00 grep vnc

2. Kill the VNC server session based on the PID.

# kill -9 <PID>

3. Change the directory to /tmp, find and delete the X* files. Then, go to .X11-unix folder and delete the X* files. (you can select which session you want to delete based on number X0, X1, X2..)

# cd /
# cd tmp/
# more .X*
::::::::::::::
.X0-lock
::::::::::::::
4237
::::::::::::::
.X1-lock
::::::::::::::
10639

*** .X11-unix: directory ***

::::::::::::::
.X2-lock
::::::::::::::
11388
::::::::::::::
.X3-lock
::::::::::::::
11422
# rm -rf .X*
# cd .X11-unix/
# rm -rf .X*

4. Go to the user directory (which user that you use to connect to vncserver), delete the log and pid files of the session.

# cd /root/.vnc/
# ls
<server-name>:2.log  <server-name>:3.log  <server-name>:4.log  passwd
<server-name>:2.pid  <server-name>:3.pid  <server-name>:4.pid  xstartup
# rm -rf <pid files>
# rm -rf <log files>

You May Also Like

Leave a Reply?