安装和使用VNC
resbian系统自带realvnc-vnc-server
启动vnc服务:vncserver :1
(:1类似与端口号,也可以理解为桌面序号)
关闭vnc服务:vncserver kill :1
注意:启动服务不需要root权限,如果使用root权限启动,那么pi账户无法登陆。
电脑上也需要安装vnc,请自行百度。
树莓派上启动vnc后,电脑上打开vnc客户端,输入内网IP地址和树莓派启动VNC时携带的端口号。
VNC使用的是5901端口,如果使用了防火墙可能需要注意一下。
启动和连接vnc
先使用ssh连接,启动vnc服务
然后window端启动vnc客户端:
成功登陆:
启动时可以指定分辨率vncserver -geometry 1920x1080 :1
设置vnc开机启动
现在如果要连接vnc还得先连接一次ssh,太麻烦了。让我们直接设置vnc开机启动
创建/etc/init.d/vncserver
输入以下内容:
#!/bin/sh
VNCUSER='pi'
case "$1" in
start)
su $VNCUSER -c 'vncserver :1'
echo "Starting VNC Server for $VNCUSER"
;;
stop)
su $VNCUSER -c 'vncserver -kill :1'
echo "TightVNC Server stopped"
;;
*)
echo "Usage: /etc/init.d/vncserver {start|stop}"
exit 1
;;
esac
exit 0
然后对该文件添加可执行权限:sudo chmod 755 /etc/init.d/vncserver
添加到开机启动列表:sudo update-rc.d vncserver defaults
(取消开机启动:sudo update-rc.d -f vncserver remove
)
设置完成。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)