你也注意到了,从man vncserver中可以看到:
-kill :display#
This kills a VNC desktop previously started with vncserver. It does
this by killing the Xvnc process, whose process ID is stored in the
file "$HOME/.vnc/host:display#.pid". It actually ignores anything
preceding a ":" in its argument. This can be useful so you can write
"vncserver -kill $DISPLAY", for example at the end of your xstartup
file after a particular application exits.
Display number = (Port number) ‒ 5900
如果没有手动设置的话(也不一样),显示器的端口号是和显示器的端口号相连的,其中
-rfbport port
Specifies the TCP port on which Xvnc listens for connections from
viewers (the protocol used in VNC is called RFB - "remote
framebuffer"). The default is 5900 plus the display number.
例如:端口5901 → 显示器 :1。这个信息可以在man Xvnc中找到(vncserver只是一个调用这个工具的封装脚本),里面写着:
25697 ? S 55:38 Xvnc4 :1 [...]
[...]
30481 ? S 17:57 Xvnc4 :2 [...]
如果你不知道这个号码(但是如果你要连接到服务器的话,你需要知道这个号码),你可以检查一下,比如ps ax | grep vnc的信息。如果我在本地这样做,我看到了
vncserver -kill :1
vncserver -kill :2
的进程,从而知道它们分别代表VNC服务器的显示号为:1和:2,可以通过
&001
来查杀。