树莓派安装vnc server并设置自启动

  • 在SSH终端输入sudo raspi-config, 这里需要打开几个选项:
    • expand_rootfs – 将根分区扩展到整张SD卡;
    • change_pass – 默认的用户名是pi,密码是raspberry;
    • change_timezone – 更改时区, 选择Asia – Shanghai;
    • configure_keyboard, 选English(US);
    • change_locale – 更改语言设置,选择en_US.UTF-8和zh_CN.UTF-8

设置完成后,选择Finish,会提示是否重启,选择Yes

在树莓派上安装vnc服务端(debian):sudo apt install tightvncserver

修改vnc密码:vncpasswd

创建vnc-server配置文件:sudo vi /etc/init.d/tightvncserver ,在这个文件里输入如下内容:

### BEGIN INIT INFO
# Provides:          tightvncserver
# Required-Start:    $local_fs
# Required-Stop:     $local_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start/stop tightvncserver
### END INIT INFO

# More details see:
# http://www.penguintutor.com/linux/tightvnc

### Customize this entry
# Set the USER variable to the name of the user to start tightvncserver under
export USER='pi'
### End customization required

eval cd ~$USER

case "$1" in
    start)
        su $USER -c '/usr/bin/tightvncserver -depth 16 -geometry 800x600 :1'
        echo "Starting TightVNC server for $USER "
        ;;
    stop)
        su $USER -c '/usr/bin/tightvncserver -kill :1'
        echo "Tightvncserver stopped"
        ;;
    *)
        echo "Usage: /etc/init.d/tightvncserver {start|stop}"
        exit 1
        ;;
esac
exit 0

然后给增加执行权限,并启动服务:

sudo chmod +x /etc/init.d/tightvncserver

sudo service tightvncserver stop

sudo service tightvncserver start

安装chkconfig, 并将vnc服务设为开机启动:

sudo apt-get install chkconfig

chkconfig –add tightvncserver

chkconfig tightvncserver on

  • 1
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
树莓(Raspberry Pi)是一种小型、单板式的计算机,常用于各种 DIY 项目和教育用途。要安装 VNC (Virtual Network Computing) 在树莓上,以便远程查看其桌面,你需要按照以下步骤操作: 1. **安装Raspbian**: 如果你的树莓还没有安装 Raspbian,首先需要下载适合版本的镜像并使用 SD 卡将其写入。 2. **启动Raspberry Pi**: 插入SD卡后,连接电源并启动树莓。 3. **登录到Raspberry Pi**: 连接到树莓的网络,然后通过 SSH (Secure Shell) 登录。默认用户名通常是 "pi",密码是 "raspberry"(但建议首次登录后立即修改密码)。 4. **更新系统**: 执行 `sudo apt update && sudo apt upgrade` 来确保你的系统是最新的。 5. **安装VNC服务器**: 输入 `sudo apt install tightvncserver`,这将安装 TightVNC 服务器。 6. **配置VNC**: 创建或编辑配置文件,例如在 `/etc/vnc/xstartup` 中添加启动命令。通常会设置启动一个桌面环境(如 LXDE 或 XFCE),例如: ``` #!/bin/sh export DISPLAY=:0 startlxde & disown ``` 7. **启用VNC服务**: 使用 `sudo systemctl enable vnc` 命令,让 VNC启动时自动运行。 8. **启动VNC服务**: 最后,启动 VNC 服务 `sudo systemctl start vnc`。你可能需要输入密码,然后就可以通过 VNC 客户端访问了。 9. **连接VNC**: 使用一个 VNC 客户端,如 Windows 上的 RealVNC Viewer,或者 Linux/Mac 上的 TightVNC Viewer,输入树莓的 IP 地址和默认端口 5900。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值