啟動方式 | 優點 | 缺點 |
---|---|---|
命令列介面, CLI | 1. 未啟動時,不佔用系統資源。 2. 使用者可自行啟動。 | 每次使用前需要確認已啟動, 若常用它的話有些不方便。 |
Systemd | 開機時,即自動啟動。 | 1. 啟動後,即佔用系統資源。 2. 多個使用者時,會佔用可觀資源。 |
[root@EeePC ~]# vncserver :2266 -geometry 1920x1004 -screen scrn -name [user @EeePC]但是會跳出一個訊息,提醒您使用 Systemd 開啟 VNC。被提醒久了想說就研究一下使用 Systemd 啟動 VNC 的設定,系統的發展一定有其必要原因,早晚要轉換就趁早,免得某次更新後就出問題。
WARNING: vncserver has been replaced by a systemd unit and is about to be removed in the next Fedora release.
Please read /usr/share/doc/tigervnc/HOWTO.md for more information.
New '[user @EeePC]' desktop is EeePC:2266
Starting applications specified in /home/user/.vnc/xstartup
Creating default config /home/user/.vnc/config
Starting applications specified in /home/user/.vnc/xstartup
Log file is /home/user/.vnc/EeePC:2266.log
1.VNC 伺服器的基本設定
以下操作都需先切換成 root 身份,請參考 "在 Linux 中,切換為 root 身分以操作、設定系統" 一文。假設 VNC 伺服器的設定參數為:使用者名稱為 SiB、連接埠為 8166,[root@EeePC ~]# vncserver :2266 -geometry 1920x1004 -screen scrn -name [SiB @EeePC]其中 WARNING 起頭那一列文字就是提醒『改用 Systemd 取代 VNCserver 來啟動 VNC 伺服器。
WARNING: vncserver has been replaced by a systemd unit and is about to be removed in the next Fedora release.
Please read /usr/share/doc/tigervnc/HOWTO.md for more information.
New '[SiB @EeePC]' desktop is SiB:2266
Starting applications specified in /home/cmchang/.vnc/xstartup
Log file is /home/cmchang/.vnc/EeePC:2266.log
2. 設定 VNC 伺服器使用 SystemD 的設定
同前例,假設 VNC 伺服器的設定參數為:使用者名稱為 SiB、連接埠為 8166,開啟 /etc/tigervnc/vncserver.users,編輯使用者設定檔,[root@EeePC ~]# vim /etc/tigervnc/vncserver.users第二個指令是顯示編輯後的設定檔內容。其中,
[root@EeePC ~]# cat /etc/tigervnc/vncserver.users
# TigerVNC User assignment
#
# This file assigns users to specific VNC display numbers.
# The syntax is <display>=<username>. E.g.:
#
# :2=andrew
# :3=lisa
:2266=SiB
- :2266 是連接埠 8166 減去神秘數字 5900 後的結果。
- SiB 是使用者名稱。
[root@EeePC ~]# vim /etc/tigervnc/vncserver-config-defaults第二個指令是顯示編輯後的設定檔內,其中
[root@EeePC ~]# cat /etc/tigervnc/vncserver-config-defaults
## Default settings for VNC servers started by the vncserver service
#
# Any settings given here will override the builtin defaults, but can
# also be overriden by ~/.vnc/config and vncserver-config-mandatory.
#
# See HOWTO.md and the following manpages for more details:
# vncsession(8) Xvnc(1)
#
# Several common settings are shown below. Uncomment and modify to your
# liking.
# session=gnome
# securitytypes=vncauth,tlsvnc
# geometry=2000x1200
# localhost
# alwaysshared
session=mate
# session=gnome | : | 預設為 GNOME「桌面環境」, 欲設為 MATE 桌面則改為 session=mate。 |
# securitytypes=vncauth,tlsvnc | : | VNC 預設加密演算法 |
# geometry=2000x1200 | : | VNC 桌面的預設大小 |
# localhost | : | 設定為使用內部連接埠,不可由外部連入。 |
# alwaysshared | : | 可同時接受多個 VNC 客戶端的連接 |
設定完成,用這個指令開啟 VNC 伺服器,
[root@EeePC ~]# systemctl start vncserver@\:2266.service若要在每次開機時自動啟動 VNC 伺服器,則使用這個指令
[root@EeePC ~]# systemctl enable vncserver@\:2266.service萬一需要重啟 VNC 伺服器,則使用這個指令
[root@EeePC ~]# systemctl restart vncserver@\:2266.service
已測試版本:
- Fedora: 37 ~ 40, TigerVNC
沒有留言:
張貼留言
感謝你耐心看完本文,歡迎留下任何指正、建議,筆者會儘快回應。(English is also welcome.)