树莓派基本配置与管理

玩转树莓派

树莓派系统配置与管理

安装基本工具

1
sudo apt-get install -y git build-essential vim tmux curl

ssh访问

Tips

SSH disabled by default; can be enabled by creating a file with name “ssh” in boot partition
意思是说创建一个名叫”ssh”的文件在boot分区,就是内存卡的根目录

  • 安装nmap端口扫描工具,扫描本网段ip,windows下可使用PortScan工具
    1
    2
    3
    4
    5
    sudo apt-get install nmap
    ```
    - 扫描raspberry ip
    ```
    nmap -v -sn 192.168.0.1/10

Nmap scan report for 192.168.0.106
Host is up (0.055s latency).
All 1000 scanned ports on 192.168.0.106 are closed

扫描到树莓派的ip为192.168.0.106
这种扫描方式很慢,可直接用arp -a查看 arp缓存表

  • 登录ssh
    linux下登录
    1
    ssh pi@192.168.0.106

windows下登录,使用mobaxterm

vnc访问

  • 安装vnc服务
1
2
sudo apt-get update
sudo apt-get install tightvncserver
  • 启动vnc服务
1
vncserver -depth 16 -geometry 800x600 :1
  • 编写服务脚本
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
### 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
  • 增加执行权限,并启动服务

    1
    2
    3
    4
    sudo chmod +x /etc/init.d/tightvncserver
    sudo update-rc.d tightvncserver defaults
    sudo /etc/init.d/tightvncserver stop
    sudo /etc/init.d/tightvncserver start
  • 安装chkconfig, 并将vnc服务设为开机启动

    1
    2
    3
    sudo apt-get install chkconfig
    chkconfig --add tightvncserver
    chkconfig tightvncserver on

Tips

这里重新启动后,vncservice服务并没有启动,需要手动启动,具体原因未知
sudo /etc/init.d/tightvncserver

  • 客户端链接,使用mobaxterm的vnc客户端

远程桌面访问

安装xrdp服务

1
sudo apt-get install xrdp

安装过后便可以用windows下的远程桌面工具 mstsc访问了

raspi-config管理树莓派

1
sudo raspi-config


这里的配置工具里描述的比较详细,根据个人喜好和具体环境配置即可

文章目录
  1. 1. 玩转树莓派
    1. 1.1. 树莓派系统配置与管理
      1. 1.1.1. 安装基本工具
      2. 1.1.2. ssh访问
      3. 1.1.3. vnc访问
      4. 1.1.4. 远程桌面访问
      5. 1.1.5. raspi-config管理树莓派