1、打开树莓派设置 sudo raspi-config,选择 5、Interfacing Options ,然后回车:
2、选择3 VNC,再回车:
3、选择yes:
4、编辑vncserver,sudo vim /etc/init.d/vncserver,添加以下命令,然后保存退出:
#!/bin/sh ### BEGIN INIT INFO # Provides: vncserver # Required-Start: $local_fs # Required-Stop: $local_fs # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Start/stop vncserver ### END INIT INFO # More details see: # http://www.penguintutor.com/linux/vnc ### Customize this entry # Set the USER variable to the name of the user to start vncserver under export USER=‘pi‘ ### End customization required eval cd ~$USER case "$1" in start) # 启动命令行。此处自定义分辨率、控制台号码或其它参数。 su $USER -c ‘/usr/bin/vncserver -depth 16 -geometry 1024x768 :1‘ echo "Starting VNC server for $USER " ;; stop) # 终止命令行。此处控制台号码与启动一致。 su $USER -c ‘/usr/bin/vncserver -kill :1‘ echo "vncserver stopped" ;; *) echo "Usage: /etc/init.d/vncserver {start|stop}" exit 1 ;; esac exit 0
5、修改权限:
sudo chmod 755 /etc/init.d/vncserver
6、设置开机自启动:
sudo update-rc.d vncserver defaults
7、重启服务器:sudo reboot
原文:https://www.cnblogs.com/penuel/p/11416239.html