VNC远程登录树莓派的图形界面

3,222 views次阅读
没有评论

树莓派的官方系统raspbian自带了x window,因此是可以使用它的类WIN风格的GUI界面的。但是ssh是不支持GUI图形界面的,因此我们这次要用到是vnc。

 

安装

 

sudo apt-get install tightvncserver

 

安装好之后设置一个VNC登录密码:

 

vncpasswd

 

先输入操作密码两次,输入密码后还会问你是否输入个只能观看不能操作的密码,一般选择n,也就是不设置。

 

开机启动VNC

设置开机启动,需要在/etc/init.d/中创建一个文件。例如tightvncserver:

sudo nano /etc/init.d/tightvncserver

 

  1. #!/bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides:          tightvncserver
  4. # Required-Start:    $local_fs
  5. # Required-Stop:     $local_fs
  6. # Default-Start:     2 3 4 5
  7. # Default-Stop:      0 1 6
  8. # Short-Description: Start/stop tightvncserver
  9. ### END INIT INFO
  10. # More details see:
  11. # http://www.penguintutor.com/linux/tightvnc
  12. ### Customize this entry
  13. # Set the USER variable to the name of the user to start tightvncserver under
  14. export USER='pi'
  15. ### End customization required
  16. eval cd ~$USER
  17. case "$1" in
  18.   start)
  19.     # 启动命令行。此处自定义分辨率、控制台号码或其它参数。
  20.     su $USER -c '/usr/bin/tightvncserver -depth 16 -geometry 800x600 :1'
  21.     echo "Starting TightVNC server for $USER "
  22.     ;;
  23.   stop)
  24.     # 终止命令行。此处控制台号码与启动一致。
  25.     su $USER -c '/usr/bin/tightvncserver -kill :1'
  26.     echo "Tightvncserver stopped"
  27.     ;;
  28.   *)
  29.     echo "Usage: /etc/init.d/tightvncserver {start|stop}"
  30.     exit 1
  31.     ;;
  32. esac
  33. exit 0

注:如果修改了迷默认用户名不是pi的请自行更改USER变量

按Ctrl+X,回答Y(存盘)退出nano编辑器。

 

然后给tightvncserver文件加执行权限,并更新开机启动列表。

sudo chmod 755 /etc/init.d/tightvncserver

sudo update-rc.d tightvncserver defaults

 

手工启动与参数

tightvncserver -geometry 800x600 :1

 

命令行参数说明

:1,指定控制台的号码。

启动多个控制台,可以提供互不影响的多个桌面环境。(大多数人不用多用户操作所以没意义)

可以不加此参数,tightvncserver会自动寻找从1开始的下一个空闲控制台。

加上此参数,会强制使用指定的控制台,如果此控制台已经启动则报错。加此参数可有效防止无意多次启动程序(会启动多个控制台)白白浪费系统资源。

 

特殊的0号控制台

0号控制台就是连接真实显示器真正输出图像的那个桌面。

对于VNC客户端,不输入端口号登录,默认就登录到0号控制台,方便。

但是因为0号是真正的桌面,所以和开机启动桌面环境,或者自己用startx命令,都存在啰嗦的冲突。

到头来是个麻烦。因此自动启动的配置教程中,一律使用1号控制台。

 

-geometry 800×600,分辨率。可以不加。

终止VNC控制台:

tightvncserver -kill :1

查看正在运行的控制台列表:

ps ax | grep Xtightvnc | grep -v grep

 

 

 

客户端登陆可以使用tightvnc view或者RealVNC

正文完
 0
HopoL
版权声明:本站原创文章,由 HopoL 于2016-01-16发表,共计1789字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
评论(没有评论)

HopoL's Blog

文章搜索
最新评论
HopoL HopoL full
19731973 19731973 so is this the full os or just a update file
HopoL HopoL Yeah, back in the older Unraid versions, some folks managed to get it booting from drives like SATA or NVMe by compiling the software themselves. But that method never got updated or maintained afterward, so it might not work with the current setups. Hope that helps!
MickeyDee MickeyDee Slightly off topic but anyone managed to get Unraid to boot off anything other than USB, like sata or nvme? If wrong place please delete and advise
Mrg Mrg I cannot Thank you enough. Thank you , Thank you , Thank you.
阿龙 阿龙 谢谢大佬分享
MickeyDee MickeyDee Cancell that, figured it out and it works, Much appriciated .
MickeyDee MickeyDee Hi Thanks for sharing, please clarify, do you mean Rename the folder "unraider-7.2.0" to unraider and copy it to the config . Thanks
lzdwudi lzdwudi 我也想试试 但我目前的版本是6.12.13 我不敢做大的动作
wice222 wice222 archive is demaged