成熟让步 發表於 2022-7-19 15:21:00

Ubuntu安装VNC

<h1 id="ubuntu安装vnc">Ubuntu安装VNC</h1>
<h2 id="更新源">更新源</h2>
<pre><code class="language-shell">sudo apt update
</code></pre>
<h2 id="安装tigervnc">安装TigerVNC</h2>
<pre><code class="language-shell">sudo apt install xserver-xorg-core

sudo apt install tigervnc-standalone-server tigervnc-xorg-extension tigervnc-viewer

sudo apt-get install gsfonts-x11 xfonts-base xfonts-75dpi xfonts-100dpi
</code></pre>
<h2 id="安装gnome-3桌面">安装Gnome 3桌面</h2>
<pre><code class="language-shell">sudo apt install ubuntu-gnome-desktop
</code></pre>
<p>启动Gnome3桌面,并确保它在启动时运行</p>
<pre><code class="language-shell">sudo systemctl start gdm

sudo systemctl enable gdm
</code></pre>
<h2 id="vnc密码设置">VNC密码设置</h2>
<p>这一步设置连接到VNC服务器时所使用的VNC密码。使用以下命令:</p>
<pre><code class="language-shell">vncpasswd
</code></pre>
<p>输入密码,然后确认。如果需要,您可以将密码设置为只读权限。如果不需要,可以按N键确认。<br>
如果vncpasswd命令无效,请使用vncserver命令,输入密码,然后终止vncserver。</p>
<pre><code class="language-shell">vncserver :1
vncserver -kill :1
</code></pre>
<h2 id="启动脚本设置">启动脚本设置</h2>
<p>使用vim命令新建或者修改~/.vnc/xstartup文件</p>
<pre><code class="language-shell">vim ~/.vnc/xstartup
</code></pre>
<p>添加或者替换成</p>
<pre><code class="language-shell">#!/bin/sh

[ -x /etc/vnc/xstartup ] &amp;&amp; exec /etc/vnc/xstartup

[ -r $HOME/.Xresources ] &amp;&amp; xrdb $HOME/.Xresources

vncconfig -iconic &amp;

dbus-launch --exit-with-session gnome-session &amp;
</code></pre>
<p>保存并退出后,给~/.vnc/xstartup文件添加可执行权限:</p>
<pre><code class="language-shell">sudo chmod a+x ~/.vnc/xstartup
</code></pre>
<h2 id="启动vnc服务器">启动VNC服务器</h2>
<p>要运行VNC服务器,可以使用以下命令:</p>
<pre><code class="language-shell">vncserver -localhost no -geometry 1920x1080 -depth 24
</code></pre>
<p>-localhost 是否只允许本地连接<br>
-geometry VNC窗口尺寸 <code>&lt;width&gt;x&lt;height&gt;</code><br>
-depth 24清晰度,可选择(8|16|24|32)</p>
<p>此时可以运行vnc客户端连接了,端口默认第一个vnc窗口是<code>5901</code></p><br><br>
来源:https://www.cnblogs.com/nanmi/p/16494193.html
頁: [1]
查看完整版本: Ubuntu安装VNC