0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

ubuntu 20.04 VNC Server のインストール

Last updated at Posted at 2022-09-14

インストール

  • server install
sudo apt install tigervnc-standalone-server -y
  • 設定ファイルを

xstartupという名前のファイルを~/.vnc内に作成

#!/bin/bash

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
vncconfig -iconic &
dbus-launch --exit-with-session gnome-session &

実行権限付与

sudo chmod +x ~/.vnc/xstartup

自動起動設定

  • serviceファイル作成

/etc/systemd/system/vncserver@.serviceというファイルを作成hoshinaの部分を自分のユーザー名に変更する

/etc/systemd/system/vncserver@.service
[Unit]
Description=Start TightVNC server at startup
After=syslog.target network.target

[Service]
Type=forking
User=hoshina
Group=hoshina
WorkingDirectory=/home/hoshina

PIDFile=/home/hoshina/.vnc/%H:%i.pid
ExecStartPre=-/usr/bin/vncserver -kill :%i > /dev/null 2>&1
ExecStart=/usr/bin/vncserver -depth 24 -geometry 1280x800 -localhost :%i
ExecStop=/usr/bin/vncserver -kill :%i

[Install]
WantedBy=multi-user.target
  • serviceの起動
sudo systemctl daemon-reload
sudo systemctl enable vncserver@1.service
sudo systemctl start vncserver@1

確認

vncserver -list

以下のように出力されればOK(※PROCESS IDのあとに、英語でなんか書かれていたらvnc serverの起動失敗してい)

TigerVNC server sessions:

X DISPLAY #	RFB PORT #	PROCESS ID
:1		5901		907

参考

おまけ

vncクライアントのインストール

  • vncのクライアント取得
wget https://downloads.realvnc.com/download/file/viewer.files/VNC-Viewer-6.22.515-Linux-x64.deb
sudo dpkg -i VNC-Viewer-6.22.515-Linux-x64.deb
  • 実行
vncviewer

vnc server手動実行

vncserver --local no :1
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?