1. 下载系统
下载 Raspbian,建议下载种子,然后使用迅雷等下载工具下载。
或者在官网上下载名称为RASPBIAN STRETCH WITH DESKTOP
的系统。
2. 写入SD卡
下载 Win32 Disk Imager,直接下载即可,安装。
将SD卡通过读卡器连接到电脑,从下载的文件(.zip)解压出系统(.img),选择后写入,等待5分钟左右。
写入完成后,在boot
盘里新建空白文件ssh
,不需要后缀,后续SSH连接时使用。
3. SSH连接
将SD卡插到树莓派上,将树莓派连接到路由器,上电。
登录路由器管理界面,便能看到名为raspberrypi
的连接,记下IP地址。
使用Xshell或者Putty等,通过SSH方式登录树莓派,默认帐号pi
,密码raspberry
。
4. 配置网络
给有线网络配置静态IP地址,可通过路由器静态IP配置,也可通过修改树莓派的网络接口配置文件/etc/network/interfaces
。配置完都要重启树莓派。
方法一,用ifconfig
查看eth0
的MAC地址(ether
后就是MAC地址),然后使用路由器静态IP配置。
- pi@raspberrypi:~ $ ifconfig -a
- eth0: flags=4098<BROADCAST,MULTICAST> mtu 1500
- ether 12:34:56:78:9a:bc txqueuelen 1000 (Ethernet)
- RX packets 0 bytes 0 (0.0 B)
- RX errors 0 dropped 0 overruns 0 frame 0
- TX packets 0 bytes 0 (0.0 B)
- TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
- pi@raspberrypi:~ $ sudo vi /etc/network/interfaces
- # interfaces(5) file used by ifup(8) and ifdown(8)
-
- # Please note that this file is written to be used with dhcpcd
- # For static IP,consult /etc/dhcpcd.conf and 'man dhcpcd.conf'
-
- # Include files from /etc/network/interfaces.d:
- source-directory /etc/network/interfaces.d
-
- auto lo
- iface lo inet loopback
-
- iface eth0 inet static
- address 192.168.0.112
- netmask 255.255.255.0
- gateway 192.168.0.1
以下是无线配置,如果打算使用有线就跳过无线配置。
修改网络接口配置文件/etc/network/interfaces
。
- pi@raspberrypi:~ $ sudo vi /etc/network/interfaces
在最后添加:
- auto wlan0
- allow-hotplug wlan0
- iface wlan0 inet dhcp
- wpa-ssid "[YOUR WIFI SSID]"
- wpa-psk "[YOUR WIFI PASSWORD]"
这是设置动态IP,静态IP参考有线的配置。
5. 网络名称
默认是raspberrypi
,单个修不修改都可以,多个需要辨识就修改一下。
要改两个地方,/etc/hostname
和/etc/hosts
。
首先,hostname
直接在里面替换掉就可以,必须是一个单词,不能包含任何标点符号和特殊字符(包括下划线_)。
- pi@raspberrypi:~ $ sudo vi /etc/hostname
其次,hosts
中最后一行,将raspberrypi
替换成与前面一致的单词。
- pi@raspberrypi:~ $ sudo vi /etc/hosts
- 127.0.0.1 localhost
- ::1 localhost ip6-localhost ip6-loopback
- ff02::1 ip6-allnodes
- ff02::2 ip6-allrouters
-
- 127.0.1.1 raspberrypi
配置完成后重启树莓派。
6. 图形桌面
使用RDP(Remote Desktop Protocol,远程桌面协议)登录树莓派,需要安装xrdp
软件。
- pi@raspberrypi:~ $ sudo apt-get install xrdp
xrdp
是一个 守护进程,安装完后和树莓派启动时,xrdp
服务会自动启动。
在Windows中,按住WIN
+R
,弹出运行
窗口, 输入mstsc
,启动远程桌面连接
。
账户信息和登录树莓派是使用的一样,默认帐号pi
,密码raspberry
。
7. 修改密码
- pi@raspberrypi:~ $ sudo passwd pi
- Enter new UNIX password:
- Retype new UNIX password:
- passwd: password updated successfully
- pi@raspberrypi:~ $ sudo passwd root
- Enter new UNIX password:
- Retype new UNIX password:
- passwd: password updated successfully
注意RDP登录的密码也受此影响。
8. 更新系统
update
从更新源中重新同步包索引文件,升级前应始终执行,apt-get
才知道有哪些新版本软件包可用。
- pi@raspberrypi:~ $ sudo apt-get update
upgrade
从更新源中安装当前系统上所有已安装软件的最新版本,耗时较长。
- pi@raspberrypi:~ $ sudo apt-get upgrade
将软件源更改为国内源(网络稳定):为树莓派更换国内镜像源