首页 > 编程知识 正文

vnc安装教程,linux卸载vncserver

时间:2023-05-05 02:50:05 阅读:111688 作者:4800

原始链接

VNC是远程桌面协议。 根据本文的说明进行操作,可以通过VNC远程控制Ubuntu 20.04。 一般的VNC安装方式在主机没有连接显示器时不可用。 以下操作在主机有显示器和没有显示器时均正常工作。

首先安装x11vnc

sudoapt-getinstallx11VNC-yVNC密码的设定

创建sudo X11 VNC-store passwd/etc/X11 VNC.pas sx11 VNC自启动服务

创建/etc/systemd/system/X11 VNC.service,并写入以下内容

[ unit ] description=start X11 vncatstartup.after=multi-user.target [ service ] type=simpleexecstart=/bzd by xauthority-forever-loop-NOx damage-repeat-rfb auth/etc/X11 VNC.pass-RF bport 5900-shared [安装] wanted

sudosystemctlenablex 11 vncsudoservicex 11 VNC start此时只要将监视器连接到远程主机,就可以通过局域网进行VNC访问。

为了允许通过VNC远程访问,无论远程主机上是否有显示器,请进行以下更改

创建默认的xorg.conf文件

sudo Xorg :1 -configure此时,程序将生成/root/xorg.conf.new文件

我的默认文件内容如下

section ' server layout ' identifier ' x.org configured ' screen0' screen0'0input device ' mouse0' core pointer ' inputdedeeevion xorg/modules ' font path '/usr/share/fonts/X11/misc ' font path '/misc ' font path fonts/X11/100 dpi/3: unscasc : unscaled ' font path '/usr/shant 100 dpi ' font path '/usr/share/fonts/X11/75 dpi ' font path ' built-ins ' endsectionsection ' module ' load ' glx ' endsectionsection ' input device ' identifier ' keyb on ' protocol ' ' auto ' option ' device ' '/dev/input/mice ' option ' zaxismapping ' 4567 ' endsectionsection ' monitor ' identifier ' monitor0' vendor name ' monitor vendor ' mod availabledriveroptionsare :-- # # # values 3360 I : integer,f: float,bool : ' true '/' false ' freq 3360 ' f heq # # percent : ' f % ' # # # # [ arg ] : arg optional # option ' Accel ' # [ bool ] # option ' Accel ' # [ bool ] # # ool # option

r> #Option "DRI" # <str> #Option "Present" # [<bool>] #Option "ColorKey" # <i> #Option "VideoKey" # <i> #Option "Tiling" # [<bool>] #Option "LinearFramebuffer" # [<bool>] #Option "HWRotation" # [<bool>] #Option "VSync" # [<bool>] #Option "PageFlip" # [<bool>] #Option "SwapbuffersWait" # [<bool>] #Option "TripleBuffer" # [<bool>] #Option "XvPreferOverlay" # [<bool>] #Option "HotPlug" # [<bool>] #Option "ReprobeOutputs" # [<bool>] #Option "XvMC" # [<bool>] #Option "ZaphodHeads" # <str> #Option "VirtualHeads" # <i> #Option "TearFree" # [<bool>] #Option "PerCrtcPixmaps" # [<bool>] #Option "FallbackDebug" # [<bool>] #Option "DebugFlushBatches" # [<bool>] #Option "DebugFlushCaches" # [<bool>] #Option "DebugWait" # [<bool>] #Option "BufferCache" # [<bool>]Identifier "Card0"Driver "intel"BusID "PCI:0:2:0"EndSectionSection "Screen"Identifier "Screen0"Device "Card0"Monitor "Monitor0"SubSection "Display"Viewport 0 0Depth 1EndSubSectionSubSection "Display"Viewport 0 0Depth 4EndSubSectionSubSection "Display"Viewport 0 0Depth 8EndSubSectionSubSection "Display"Viewport 0 0Depth 15EndSubSectionSubSection "Display"Viewport 0 0Depth 16EndSubSectionSubSection "Display"Viewport 0 0Depth 24EndSubSectionEndSection

将此文件复制至 /usr/share/X11/xorg.conf.d/xorg.conf

这个文件保证在主机上插有显示器的时候,系统界面能在显示器上正常显示。下面我们再给系统添加一个虚拟显示器,当主机没有显示器的时候系统就使用这个虚拟显示器。

安装虚拟显卡驱动

sudo apt install xserver-xorg-video-dummy

在这个文件的最后添加下面的内容

Section "Monitor" Identifier "Monitor1" HorizSync 1.0 - 2000.0 VertRefresh 1.0 - 200.0 # Add 16:9 modes, others are automatically detected. Modeline "1280x720" 74.48 1280 1336 1472 1664 720 721 724 746 Modeline "1920x1080" 172.80 1920 2040 2248 2576 1080 1081 1084 1118EndSectionSection "Device" Identifier "Card1" Driver "dummy" VideoRam 256000EndSectionSection "Screen" DefaultDepth 24 Identifier "Screen1" Device "Card1" Monitor "Monitor1" SubSection "Display" Depth 24 Modes "1920x1080" EndSubSectionEndSection

这样我们就创建了一个使用虚拟显卡的虚拟显示器。为了让虚拟的显示器和真实显示器都能工作,我们需要把最上面的 ServerLayout 进行更改

Section "ServerLayout" Identifier "X.org Configured" Screen 0 "Screen0" 0 0Screen 1 "Screen1" 0 0EndSection

现在重新启动远程电脑,就可以在没有显示器的情况下远程了。

以上的方法还有一个问题。就是在用户没有登录的其情况下是没办法远程的。所以需要把用户设置成自动登录。

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。