在Debian系统中启动TigerVNC服务器可以通过以下几种方法实现:
sudo apt update
sudo apt install tigervnc-standalone-server tigervnc-common
vncpasswd
按照提示输入并确认您的密码。
vncserver :1
这将启动TigerVNC服务器,并显示一个类似于以下的输出:
New 'X' desktop is your-hostname:1
请记住这个数字(在这个例子中是1),因为您稍后需要用到它。
your-ip-address:1
将 your-ip-address
替换为您的计算机的IP地址,将 1
替换为之前记下的数字。例如,如果您的IP地址是 192.168.1.5
,则连接地址为:
192.168.1.5:1
输入密码:在VNC客户端中输入您在步骤3中设置的密码,然后按回车键。现在,您应该可以看到Debian桌面环境。
sudo nano /etc/systemd/system/tigervnc.service
将以下内容粘贴到文件中,将 your-user
替换为您的用户名:
[Unit]
Description=TigerVNC Server
After=syslog.target network.target
[Service]
Type=forking
User=your-user
Group=your-user
WorkingDirectory=/home/your-user
PIDFile=/home/your-user/.vnc/%H:%i.pid
ExecStartPre=/usr/bin/vncserver -kill :%i /dev/null 2>&1
ExecStart=/usr/bin/vncserver -depth 24 -geometry 1280x800 :%i
ExecStop=/usr/bin/vncserver -kill :%i
[Install]
WantedBy=multi-user.target
保存并关闭文件。
sudo systemctl daemon-reload
sudo systemctl enable tigervnc.service
sudo systemctl start tigervnc.service
现在,每次系统启动时,TigerVNC服务器都会自动运行。
sudo systemctl stop tigervnc.service
sudo systemctl restart tigervnc.service
通过以上步骤,您可以在Debian系统中成功启动并使用TigerVNC服务器。