一些关于树莓派的文章https://www.cnblogs.com/emouse/archive/2013/06/07/3124027.html
www.jijigongzuoshi.com/无屏幕和键盘配置树莓派wifi和ssh/

2020.08.29

树莓派关机重启命令:

关机方法任选一行即可
sudo shutdown -h now
sudo halt
sudo poweroff
sudo init 0

重启方法
sudo reboot
shutdown -r now
shutdown -r 18:23:52 #定时重启在18点23分52秒关闭

之前树莓派都是32位,https://www.raspberrypi.org/downloads/raspberry-pi-os/

最新(2020.08.20)32位:https://downloads.raspberrypi.org/raspios_full_armhf_latest(如用迅雷下载,完成文件名尾加.zip

(介绍https://blog.csdn.net/zuoguaishouxiao/article/details/106496323)

2020年5月份,官网https://downloads.raspberrypi.org/raspios_arm64/images/上有64位的:

1.https://downloads.raspberrypi.org/raspios_arm64/images/raspios_arm64-2020-05-28/

2020-05-27-raspios-buster-arm64.zip镜像(下载速度挺快)

8月份有更新:

(注:8月版64位安装后, vncserver是启动不了的,要从32的上面复制一部分文件过来,解决方法参考:https://www.jianshu.com/p/7eff9966c292),不必要就暂不用64位,查错太浪费时间,本是想学人工智能的,结果成维护的了。

2.https://downloads.raspberrypi.org/raspios_arm64/images/raspios_arm64-2020-08-24/

2020-08-20-raspios-buster-arm64.zip

查看自己的linux版本是32位还是64位

三种基本查看方式:

终端窗口输入命令:

  1. file /sbin/init 或者 file /bin/ls
  2. uname -a
    备注:i686表示32位机器,x86_64表示64位机器
  3. getconf LONG_BIT

准备:

1.烧卡格式化:SDCardFormatterv5_WinEN

2.写卡:3-win32diskimager-1.0.0 (写卡之前下载准备好.img或.zip文件)

3.树莓派写卡成功后,在卡上新建一个ssh(文件名小写,内容为空)文件,再拨出卡,插入树莓派.(常忘)

一.连网准备:

1.把树莓派网口连接电脑USB

2.电脑网络共享中心,wlan,,属性,共享,勾选共享,,.

3.ping raspberrypi.local,看树莓派机的IP,以便连接.

如出现:

C:\Users\>ping raspberrypi.local
"Ping 请求找不到主机 raspberrypi.local。请检查该名称,然后重试。"

则可尝试换个USB接口以及换个转换器(许多笔记本电脑没有rj45网口需用转换)

用arp -a,没有显示树莓派IP,在用ping raspberrypi.local,如果能通,则再用arp -a就会显示IP,所以, arp -a没有显示IP,并不意味与树莓派网络没有连通.

如出现下面:

正在 Ping raspberrypi.local [fe80::cbaa:e4b8:ba73:4b6%16] 具有 32 字节的数据:
来自 fe80::cbaa:e4b8:ba73:4b6%16 的回复: 时间=1ms
来自 fe80::cbaa:e4b8:ba73:4b6%16 的回复: 时间<1ms
来自 fe80::cbaa:e4b8:ba73:4b6%16 的回复: 时间<1ms
来自 fe80::cbaa:e4b8:ba73:4b6%16 的回复: 时间<1ms

解决办法:只需加个参数-4,表示强制采用ipv4协议即可:

C:\Users\38016>ping raspberrypi.local正在 Ping raspberrypi.local [fe80::2154:e547:a811:c920%14] 具有 32 字节的数据:
来自 fe80::2154:e547:a811:c920%14 的回复: 时间=1ms
来自 fe80::2154:e547:a811:c920%14 的回复: 时间=1ms
来自 fe80::2154:e547:a811:c920%14 的回复: 时间=1ms
来自 fe80::2154:e547:a811:c920%14 的回复: 时间=1msfe80::2154:e547:a811:c920%14 的 Ping 统计信息:数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失),
往返行程的估计时间(以毫秒为单位):最短 = 1ms,最长 = 1ms,平均 = 1msC:\Users\38016>ping raspberrypi.local -4正在 Ping raspberrypi.local [169.254.36.120] 具有 32 字节的数据:
来自 169.254.36.120 的回复: 字节=32 时间=1ms TTL=64
来自 169.254.36.120 的回复: 字节=32 时间=1ms TTL=64
来自 169.254.36.120 的回复: 字节=32 时间=1ms TTL=64
来自 169.254.36.120 的回复: 字节=32 时间<1ms TTL=64169.254.36.120 的 Ping 统计信息:数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失),
往返行程的估计时间(以毫秒为单位):最短 = 0ms,最长 = 1ms,平均 = 0ms

或者:所连接的IPV6的协议不选,也可:

右击win10右下角网络符号,

打开"网络和Internet"设置

左击"网络和共享中心"

ipv6勾空.(解决看不懂IP地址)

4.单击连网的连接,属性,共享,勾选"允许,,,"

另阅官方文档:Adding the network details to the Raspberry Pi

https://www.raspberrypi.org/documentation/configuration/wireless/wireless-cli.md

如果树莓派ping不通网址或者更新时出现destination host unreachable,则先:

一.输入命令services.msc,进入服务控制面板,找到IPSec服务,禁用,重启,OK。

二.再检查网络硬件故障.

网络不通,则配置vnc的时候更新不成功,出错(开始以为操作失误,几欲重烧录卡),vnc也连不上.通过笔记本的USB口能连上树莓派,但上不了网,

“Destination Host Unreachable目标主机不能到达 ”信息说明对方主机不存在或者没有跟对方建立连接。 网线没接好,或者网卡地、转换器有问题! 这都是可能有的.我今天(20200715)就遇过usb-rj45转换接口不良,还有网线时断时连的问题.

路由表中连到达目标的路由都没有,会出现“Destination Host Unreachable”。

主要在以下三种情形出现:

1、 局域网使用DHCP动态分配IP地址时,DHCP出现故障或者失败 
DHCP失效或者出现故障时,客户机无法分配到IP地址,系统只有自设IP地址,而IP地址的自动设置往往会分配到不同的子网,因此会出现“Destination Host Unreachable”。

2、 子网掩码设置错误 
这种情况一般比较少见,如果子网掩码不是系统自动生成的,则在计算时一定细心。

3、 路由表返回错误信息 
这种情况一般是在“Destination Host Unreachable”前面加上IP地址,说明本地计算机与外部网络连接没有问题,但与某台主机连接存在问题。

"Destination Net Unreachable"这个信息表示对方主机不存在或者没有跟对方建立连接。这里要说明一下"destination host unreachable"和"time out"的区别,如果所经过的路由器的路由表中具有到达目标的路由,而目标因为其它原因不可到达,这时候会出现"time out",如果路由表中连到达目标的路由都没有,那就会出现"destination host unreachable"。

把icmp安全策略关闭 
tcp/IP属性——高级——选项——IP安全机制属性——选择"不使用IPSEC"确定,OK了,一切正常

二.连接树莓派

终端命令方式

ssh pi@169.254.36.120

#ssh连接命令

#pi是用户名

#169.254.36.120是树莓派的IP

此时,如果笔记本电脑以前连接过树莓派,此次再连接,可能会出现如下:

C:\Users\38016>ssh pi@169.254.36.120
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the ECDSA key sent by the remote host is
SHA256:oSdPSyjWut2Pb89FQiyh7QFi2VKM/5LRG43rcT9NvCc.
Please contact your system administrator.
Add correct host key in C:\\Users\\38016/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in C:\\Users\\38016/.ssh/known_hosts:1
ECDSA host key for 169.254.36.120 has changed and you have requested strict checking.
Host key verification failed.

OpenSSH的ssh会把你每个你访问过计算机的公钥(public key)都记录在~/.ssh/known_hosts。当下次访问相同计算机时,OpenSSH会核对公钥。如果公钥不同,OpenSSH会发出警告,如果我们重新安装系统,其公钥信息还在,连接会出现上述情况

解决办法:

  1. 方法一:

    rm -rf ~/.ssh/known_hosts

    优点:干净利索

    缺点:把其他正确的公钥信息也删除,下次链接要全部重新经过认证

  2. 方法二:

    vi ~/.ssh/known_hosts

    删除对应ip的相关rsa信息(本例可知删除53行信息即可)

    优点:其他正确的公钥信息保留

    缺点:还要vi,还要找到对应信息,稍微优点繁琐

  3. 方法三:

    清除旧的公钥信息

    ssh-keygen -R 169.254.36.120

    ssh-keygen -R hostname   从 known_hosts 文件中删除所有属于 hostname 的密钥。(参阅:https://blog.csdn.net/qq_38570571/article/details/79268426)

    优点:快、稳、狠

    缺点:没有缺点

  4. 上面三种情况是非windows系统处理方法,在windows10下,C:\Users\38016\.ssh\known_hosts文件直接改成known_hosts_bak.

C:\Users\38016>ssh-keygen -R 169.254.36.120
# Host 169.254.36.120 found: line 1
C:\Users\38016/.ssh/known_hosts updated.
Original contents retained as C:\Users\38016/.ssh/known_hosts.old

然后再ssh pi@169.254.36.120出现:

C:\Users\38016>ssh pi@169.254.36.120
The authenticity of host '169.254.36.120 (169.254.36.120)' can't be established.
ECDSA key fingerprint is SHA256:oSdPSyjWut2Pb89FQiyh7QFi2VKM/5LRG43rcT9NvCc.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '169.254.36.120' (ECDSA) to the list of known hosts.
Connection closed by 169.254.36.120 port 22

其中要输入" yes"

然后再输入密码raspberry 连接,注意,输入密码时,观察一下,关掉输入法,在英文状态下输入.
C:\Users\38016>ssh pi@169.254.36.120
pi@169.254.36.120's password:

C:\Users\38016>arp -a接口: 192.168.31.78 --- 0xaInternet 地址         物理地址              类型192.168.31.1          XXXXXXXXXX255.255.255.255       ff-ff-ff-ff-ff-ff     静态接口: 169.254.47.121 --- 0x10  (本机lan口)Internet 地址         物理地址              类型169.254.36.120        b8-27-eb-68-7f-e0     动态     #树莓派的IP169.254.255.255       ff-ff-ff-ff-ff-ff     静态224.0.0.22            01-00-5e-00-00-16     静态224.0.0.251           01-00-5e-00-00-fb     静态224.0.0.252           01-00-5e-00-00-fc     静态239.255.255.250       01-00-5e-7f-ff-fa     静态C:\Users\38016>ping raspberrypi.local正在 Ping raspberrypi.local [169.254.36.120] 具有 32 字节的数据:
来自 169.254.36.120 的回复: 字节=32 时间=1ms TTL=64
来自 169.254.36.120 的回复: 字节=32 时间=1ms TTL=64
来自 169.254.36.120 的回复: 字节=32 时间=1ms TTL=64
来自 169.254.36.120 的回复: 字节=32 时间<1ms TTL=64169.254.36.120 的 Ping 统计信息:数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失),
往返行程的估计时间(以毫秒为单位):最短 = 0ms,最长 = 1ms,平均 = 0msC:\Users\38016>ssh pi@169.254.36.120
pi@169.254.36.120's password:   #密码raspberry  盲打.
Linux raspberrypi 4.19.57-v7+ #1244 SMP Thu Jul 4 18:45:25 BST 2019 armv7lThe programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Mon Jul 15 16:17:11 2019SSH is enabled and the default password for the 'pi' user has not been changed.
This is a security risk - please login as the 'pi' user and type 'passwd' to set a new password.pi@raspberrypi:~ $ arp -a
? (169.254.47.121) at 00:e0:4c:68:07:11 [ether] on eth0
? (192.168.137.1) at <incomplete> on eth0
pi@raspberrypi:~ $ exit   #按ctro+d也可注销
注销
Connection to 169.254.36.120 closed.

输入做系统时原来自带已设置的密码raspberry  (盲打)

进去之后,设置一下

三.配置树莓派

sudo raspi-config

可参考

https://blog.csdn.net/weixin_42455305/article/details/80686997

初次使用树莓派系统时,默认用户是pi ,密码为raspberry。
使用root帐号,先设置root密码:
sudo passwd root解锁root账户
sudo passwd --unlock root
用下面命令切换到root管理员
su root

startx
可进入图形化界面

树莓派 raspi-config 设置

参考官方文档:Some basic guides to configuring your Raspberry Pi.

https://www.raspberrypi.org/documentation/configuration/

sudo raspi-config

重点设置一.五.七

树莓派 raspi-config 设置详解

一、简介:raspi-config是Raspberry PI官方Raspbian镜像自带的一个系统配置工具。它都可以做什么呢?让我们来学习一下吧。raspi-config,会在系统首次启动时自动运行,就是那个蓝色背景,灰底黑字的界面。首次自动运行之后,下次就不会自动 运行了,若想手动运行,请以root身份运行:

sudo raspi-config

二、基本词汇:

下面参阅:https://www.jijigongzuoshi.com/%E6%A0%91%E8%8E%93%E6%B4%BE-raspi-config-%E8%AE%BE%E7%BD%AE%E8%AF%A6%E8%A7%A3/

1.change user password  更改用户密码
2.network options网络选项
       hostname 主机名
       wi-fi  wifi
       network interface names  网络接口的名称
3.boot options 启动选项
       desktop/CLI  桌面/ CLI
             console 控制台
             console autologin 控制台登录
              desktop  桌面 
             desktop autologin 桌面登陆
       wait for network at boot 等待开机时的网络
              would you like boot to wait until a network connection is established? 要启动直到网络连接建立吗?
              waiting for network on boot is enabled启动时等待网络启动
       splash screen  启动画面
              would you like to show the splash screen at boot? 你想在开机时显示开机画面吗?
4.localisation options  定位选项
       change locale 改变现场
       change timezone 更改时区
       change keyboard layout 更改键盘布局
       change wi-fi country  改变Wi-Fi国家
5.interfacing options 接口选项
       camera 照相机
       ssh
       vnc
       spi
       i2c
       serial 串行
       1-wire
       remote GPIO
6.overclock 超频
7.advanced options 高级选项
       expand filesystem扩展文件系统 
       overscan过扫描
       memory split 内存分
       audio音频
       resolution分辨率
       GL Driver GL驱动
8.update 更新
9.about raspi-config 关于raspi配置
select 选择 finish 完成

四.设置软件源

可参看:树莓派最新最快更新源2020.06.06https://blog.csdn.net/ahmcwt/article/details/106596934

1.修改sources.list

备份 sources.list.bak

pi@raspberrypi:~$ sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak

编辑sources.list  文件

#nano说明:nano是一个字符终端的文本编辑器,有点像DOS下的editor程序。它比vi/vim要简单得多,比较适合Linux初学者使用。某些Linux发行版的默认编辑器就是nano (-w --nowrap 不要自动换行)
参阅详解linux中nano命令:https://blog.csdn.net/a4132447/article/details/95531532

用法
光标控制

  • 移动光标:使用用方向键移动。
  • 选择文字:按住鼠标左键拖到。

复制、剪贴和粘贴

  • 复制一整行:Alt+6
  • 剪贴一整行:Ctrl+K

粘贴:Ctrl+U
如果需要复制/剪贴多行或者一行中的一部分,先将光标移动到需要复制/剪贴的文本的开头,按Ctrl+6(或者Alt+A)做标记,然后移动光标到 待复制/剪贴的文本末尾。这时选定的文本会反白,用Alt+6来复制,Ctrl+K来剪贴。若在选择文本过程中要取消,只需要再按一次Ctrl+6。

搜索
按Ctrl+W,然后输入你要搜索的关键字,回车确定。这将会定位到第一个匹配的文本,接着可以用Alt+W来定位到下一个匹配的文本。

翻页

  • Ctrl+Y到上一页
  • Ctrl+V到下一页

保存
使用Ctrl+O来保存所做的修改

退出
按Ctrl+X

/etc/apt/sources.list内容为:

deb http://raspbian.raspberrypi.org/raspbian/ buster main contrib non-free rpi
# Uncomment line below then 'apt-get update' to enable 'apt-get source'
#deb-src http://raspbian.raspberrypi.org/raspbian/ buster main contrib non-free rpi

sudo  nano  /etc/apt/sources.list        #此处的间隔要打两个空格,否则复制到终端右键粘贴时会连在一块了.  此问题在博客发布之后就没有了.在编辑阶段有问题.

内容修改如下:

deb http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ buster main contrib non-free rpi
deb-src http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ buster main contrib non-free rpi

然后ctrl+o,回车,ctrl+x退出.
备份前原有内容为(也可以用,但慢):

deb http://raspbian.raspberrypi.org/raspbian/ buster main contrib non-free rpi

deb-src http://raspbian.raspberrypi.org/raspbian/ buster main contrib non-free rpi

注:之前(08.20版32位)曾作如下修改: (参考清华源网站帮助:https://mirror.tuna.tsinghua.edu.cn/help/debian/,这个是对于debian的)

# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster main contrib non-free                                           # deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ buster main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-updates main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-updates main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-backports main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-backports main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian-security buster/updates main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security buster/updates main contrib non-free
# 下面是原有的
deb http://raspbian.raspberrypi.org/raspbian/ buster main contrib non-free rpi
# Uncomment line below then 'apt-get update' to enable 'apt-get source'
#deb-src http://raspbian.raspberrypi.org/raspbian/ buster main contrib non-free rpi

 用上面这些多行源,sudo apt-get update时出问题了,提示没有公钥之类的问题:

pi@raspberrypi:~ $ sudo apt-get update
Hit:1 http://mirrors.tuna.tsinghua.edu.cn/raspberrypi buster InRelease
Get:2 https://mirrors.tuna.tsinghua.edu.cn/debian buster InRelease [122 kB]
Err:2 https://mirrors.tuna.tsinghua.edu.cn/debian buster InRelease
  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 04EE7237B7D453EC NO_PUBKEY 648ACFD622F3D138 NO_PUBKEY EF0F382A1A7B6500 NO_PUBKEY DCC9EFBF77E11517
Get:3 https://mirrors.tuna.tsinghua.edu.cn/debian buster-updates InRelease [51.9 kB]
Get:4 https://mirrors.tuna.tsinghua.edu.cn/debian buster-backports InRelease [46.7 kB]
Err:3 https://mirrors.tuna.tsinghua.edu.cn/debian buster-updates InRelease
  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 04EE7237B7D453EC NO_PUBKEY 648ACFD622F3D138
Err:4 https://mirrors.tuna.tsinghua.edu.cn/debian buster-backports InRelease
  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 04EE7237B7D453EC NO_PUBKEY 648ACFD622F3D138
Get:5 https://mirrors.tuna.tsinghua.edu.cn/debian-security buster/updates InRelease [65.4 kB]
Err:5 https://mirrors.tuna.tsinghua.edu.cn/debian-security buster/updates InRelease
  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY AA8E81B4331F7F50 NO_PUBKEY 112695A0E562B32A
Reading package lists... Done
W: GPG error: https://mirrors.tuna.tsinghua.edu.cn/debian buster InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 04EE7237B7D453EC NO_PUBKEY 648ACFD622F3D138 NO_PUBKEY EF0F382A1A7B6500 NO_PUBKEY DCC9EFBF77E11517
E: The repository 'https://mirrors.tuna.tsinghua.edu.cn/debian buster InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: GPG error: https://mirrors.tuna.tsinghua.edu.cn/debian buster-updates InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 04EE7237B7D453EC NO_PUBKEY 648ACFD622F3D138
E: The repository 'https://mirrors.tuna.tsinghua.edu.cn/debian buster-updates InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: GPG error: https://mirrors.tuna.tsinghua.edu.cn/debian buster-backports InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 04EE7237B7D453EC NO_PUBKEY 648ACFD622F3D138
E: The repository 'https://mirrors.tuna.tsinghua.edu.cn/debian buster-backports InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: GPG error: https://mirrors.tuna.tsinghua.edu.cn/debian-security buster/updates InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY AA8E81B4331F7F50 NO_PUBKEY 112695A0E562B32A
E: The repository 'https://mirrors.tuna.tsinghua.edu.cn/debian-security buster/updates InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
pi@raspberrypi:~ $

再查公钥相关问题,一堆解决套路.但没去处理公钥问题,只是再次修改了源,然后,就没有那个公钥问题了.方向不要搞错.

sudo nano /etc/apt/sources.list 修改如下:

deb http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ buster main contrib non-free rpi
deb-src http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ buster main contrib non-free rpi

2.修改raspi.list

先备份:sudo  cp /etc/apt/sources.list.d/raspi.list   /etc/apt/sources.list.d/raspi.list.bak

sudo nano /etc/apt/sources.list.d/raspi.list

原内容为:
deb http://archive.raspberrypi.org/debian/ buster main
# Uncomment line below then 'apt-get update' to enable 'apt-get source'
#deb-src http://archive.raspberrypi.org/debian/ buster main

用#注释掉原文件内容,用以下内容取代:用#注释掉原文件内容,用以下内容取代:
deb http://mirrors.tuna.tsinghua.edu.cn/raspberrypi/ buster main ui
deb-src http://mirrors.tuna.tsinghua.edu.cn/raspberrypi/ buster main ui

3、修改 pip 源
后面要开发一些 python 项目,先将 pip 源更换成国内。

mkdir ~/.pip
sudo nano ~/.pip/pip.conf

~ 表示代码主目录,也就是当前登录用户的用户目录。
比如:这里登录用户是pi
cd ~
~ 代表的就是 /home/pi/
总之cd ~再pwd就知道了,pwd表示当前目录.

在文件中写入下面3行,保存退出

[global]
trusted-host=mirrors.aliyun.com
index-url=https://mirrors.aliyun.com/pypi/simple/

安装中文字体
sudo apt-get install ttf-wqy-zenhei ttf-wqy-microhei

安装过程中提示是fonts-wqy-zenhei
注意,选中 'fonts-wqy-zenhei' 而非 'ttf-wqy-zenhei'
注意,选中 'fonts-wqy-microhei' 而非 'ttf-wqy-microhei'

修改如下:

sudo apt-get install fonts-wqy-zenhei fonts-wqy-microhei

pip更新:

pip --default-timeout=100 install -U pip

更新包,解决超时:
pip install --default-timeout=100 -i https://pypi.tuna.tsinghua.edu.cn/simple tensorflow-gpu==1.13.1

注:有线连接时,vcn连接的有线IP,vcnserver必须手动启动,vnc才能连上.

而树莓派不必重新启动,而用vnc连无线IP时,只需填梅莓IP地址,不必带端口号,也能vnc直接连接.如果带有端口号写的不对,则也会出现拒绝连接.

另一法:pi@raspberrypi:~$ sudo vi /etc/apt/sources.list

deb http://mirrors.aliyun.com/raspbian/raspbian/ buster main non-free contrib rpi
deb-src http://mirrors.aliyun.com/raspbian/raspbian/ wheezy main non-free contrib rpi

deb http://mirrors.ustc.edu.cn/raspbian/raspbian/ buster main non-free contrib rpi
deb-src http://mirrors.ustc.edu.cn/raspbian/raspbian/ buster main non-free contrib rpi

deb http://mirrors.aliyun.com/raspbian/raspbian/ buster main non-free contrib rpi
deb-src http://mirrors.aliyun.com/raspbian/raspbian/ buster main non-free contrib rpi

deb http://mirrordirector.raspbian.org/raspbian/ buster main contrib non-free rpi
# Uncomment line below then 'apt-get update' to enable 'apt-get source'
#deb-src http://archive.raspbian.org/raspbian/ buster main contrib non-free rpi

然后使用 Ctrl+O 回车后保存文件,Ctrl+X 退出编辑器。

pi@raspberrypi:~$ sudo apt-get update && sudo apt-get upgrade -y       #更新系统软件 并 更新已安装的包

删除默认的vi编辑器 sudo apt-get remove vim-common
然后重新安装vim sudo apt-get install vim

Setup Options

1 Expand Filesystem
扩展文件系统(默认镜像写入SD卡后,根分区不会使用剩余的SD卡空间,造成空间浪费,运行此选项后会把根分区扩展到整个SD卡,最大效率使用SD卡)按回车即可。

启动时进入的环境选择

树莓派3B 设置Linux下程序自启动1 参考:https://blog.csdn.net/Leo_Luo1/article/details/78837592
树莓派3B Linux下设置程序自启动2 参考:https://blog.csdn.net/Leo_Luo1/article/details/78838019

Change Locale

语言和区域设置,建议不要改,默认英文就好,因为你要是改为中文,以后使用putty等工具连接PI时,还会遇到一些乱码问题,如果想使用  中文,建议只安装中文字体,这样在图形界面下浏览WEB页面时就能显示中文了。确实想改中文,进入这个选项后按Page Down键把滚动移动到屏幕底部,用空格键选中zh-CN GB2312,zh-CN GB18030,zh-CN UTF-8,然后按回车,然后默认语言选中zh-cn然后回车,记住啊,最好选安装了中文字体再进行这步,安装中文字体的方法:

sudo apt-get update

sudo apt-get install ttf-wqy-zenhei ttf-wqy-microhei

I2 Change Timezone

设置时区,如果设置不进行设置,PI的时间就显示不正常。选择Asia(亚洲)再选择Chongqing(重庆)即可。

I3 Change Keyboard Layout

改变键盘布局,还是不要管它了,按键不对的时候再选吧,一般没事。

键盘布局设置  参考:https://blog.csdn.net/Leo_Luo1/article/details/78795129
【1】sudo raspi-config
【2】进入国际化配置选项
【3】修改键盘布局
【4】选择PC104标准键盘
【5】选择美国标准English(US)
【6】选择键盘默认布局

5 Enable Camera

启动PI的摄像头模块,如果想启用,选择Enable,禁用选择Disable就行了

6 Add to Rastrack

把你的PI的地理位置添加到一个全世界开启此选项的地图,建议还是不要开了,免得被跟踪。

7 Overclock
超频,建议不要更改,更改后会失去保修,本文不对更改后造成的PI的损毁不负责,更改选项后的后果自负。
  None 不超频,运行在700Mhz,核心频率250Mhz,内存频率400Mhz,不增加电压
  Modest 适度超频,运行在800Mhz,核心频率250Mhz,内存频率400Mhz,不增加电压
  Medium 中度超频,运行在900Mhz,核心频率250Mhz,内存频率450Mhz,增加电压2
  High 高度超频,运行在950Mhz,核心频率250Mhz,内存频率450Mhz,增加电压6

Turbo 终极超频,运行在1000Mhz,核心频率500Mhz,内存频率600Mhz,增加电压6

8 Advanced Options
高级设置

A1 Overscan

是否让屏幕内容全屏显示

A2 Hostname 在网上邻居或者路由器能看到的主机名称
  A3 Memory Split 内存分配,选择给GPU多少内存
  A4 SSH 是否运行SSH登录,建议开户此选项,以后操作PI方便,有网络就行,不用开屏幕了。
  A5 SPI 是否默认启动SPI内核驱动,新手就不用管了。
  A6 Audio 选择声音默认输出到模拟口还是HDMI口
    0 Auto 自动选择
    1 Force 3.5mm ('headphone') jack强制输出到3.5mm模拟口
    2 Force HDMI 强制输出到HDMI

A7 Update 把raspi-config这个工具自动升级到最新版本


要点配置:

1 选择第5项 Interfacing Options
因为后面要用到,所以先在这里将全部 Enable,如果用不着,可以按需选择来打开。建议将 SSH、VNC 都 Enable,方便远程控制。后续就不需要接显示器与键鼠了。

2 选择第7项 Advanced Options

执行 A1 Expand Filesystem
扩展TF卡容量,烧录完的 TF 卡分成了3个区:boot、系统以及空闲空间,容量有很大部分都未分配,执行一下该过程可以将所有的容量都分配出来给系统,可被用户使用。可以通过df -l命令来查看当前占用的空间

执行A3 Memory Split
分配显存,默认分配128MB,对于用到摄像头、opencv、图形化界面、家庭影院等的用户,可以改成256MB,有助于提高流畅性(性能限制,只能稍微快一点),如果做下载机、文件服务器等不需要界面的,可以保持默认或者改成64MB都是 OK 的。
树莓派3的内存只有1G,为方便后续使用,在此分配 256MB 给显存,对于树莓派4的用户,有4G的内存,分个512MB~1024MB都是OK的。
转自:https://blog.csdn.net/qq_29225913/article/details/100939347


第一次开机初始化设置

重启方法
sudo reboot
shutdown -r now

关机
sudo poweroff


在用64位系统,启动后出现下面:

vnc连接不成功:

查https://boke112.com/bkwd/4935.html,疑因防火墙,暂停之,

问题依旧.

忆及初始ssh pi@169.254.36.120有问题,处理方式或有瑕疵,

现在ssh pi@raspberrypi又出现类似问题

改文件,在windows10下,C:\Users\38016\.ssh\known_hosts文件直接改成known_hosts_bak.处理之后

出来一新地址,169.254.63.42,

rm -rf ~/.ssh/known_hosts 这个方法也没有改善状况.

解决办法:参阅:https://blog.csdn.net/liuhuayeyu/article/details/103074197

"终于找到了忽略的关键:VNC客户端首次与VNC服务器建立连接时会保存服务器发来的公钥指纹,之后与同一台服务器(这个同一台是用IP地址来标识的)建立连接时,就不会重新接收同一个服务器的公钥指纹了,默认使用已保存的指纹进行验证。

重装之前,笔记本使用VNC Viewer连接过台机,就保存了那个时候台机VNC Server发来的指纹。

然后台机重装系统后,也重装了VNC Server,其公钥指纹也发生了变化。

但是客户端还是默认使用旧的指纹去与跟服务器握手,然额服务器已经不认识它了,就说你是谁啊,反手就是一瓜子。

另一方面客户端保存的服务器公钥指纹是写在注册表里的,所以后来即便重装了客户端的VNC Viewer,其旧的指纹还是在,所以它还是屡教不改,用旧的信物去握手,又被踢回来了。

所以解决方法就来了:

关于用64位的树莓派,实际本身存在问题,不能启动vncserver.

解决方法参见:https://www.jianshu.com/p/7eff9966c292

下面的这个解决方法可能是适于32位版本的,在64位上,没有试验成功.

------------------------------------------------------------------------------------------------------------------------------------------------------------------

1、打开笔记本上的注册表,Win+R打开运行框,输入regedit打开注册表编辑器,找到VNC Viewer保存服务器指纹的表项:

计算机\HKEY_CURRENT_USER\Software\RealVNC\vncviewer\KnownHosts。(这个是网上搜的)

2、然后将已保存的VNC Server服务器(这里IP地址开头的)项均右键删除,只保留一ab项即可。

3、删除之后需要重启笔记本,修改的注册表才会生效。

4、重启之后,世界和平~

接收保存新的公钥指纹,输入VNC Server的验证密码,成功连接远程桌面。"

--------------------------------------------------------------------------------------------------------------------------------------------------------------------

上面的这个解决方法可能是适于32位版本的,在64位上,没有试验成功.

关于用64位的树莓派,实际本身存在问题,不能启动vncserver.解决方法参见:https://www.jianshu.com/p/7eff9966c292


通过VNC或直连显示器,初次进入系统,会有个欢迎界面,选择 next 进入初始化配置
第一步:选择国家,选中国就好了,将下方“Use US Keyboard”选上,建议同时选上使用英语。在这里要点名一下了,树莓派居然还将 Taiwan 放置在国家选项里,这种低级错误是很不应该的。

第二步:修改树莓派的密码,默认密码是 raspberry,这步根据个人口味来写。
第三步:Set up Screen,直接next就好
第四步:连接wifi,有就连,没有就跳过,问题不大。
第五步:update,跳过就好,服务器连不上,连上也很慢,确实很慢很慢!!有梯子请便。
第六步:重启

20200713安装64位系统后apt-get update有提示E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

设置分辨率:

在"开始",菜单找配置.

-------------------------------------------------

五.配置树莓派网络

(一)有线网络连接,插线就好,简单,略.

(二)无线网络连接

两种方法:

1.进入树莓派桌面之后,点击桌面右上角网络图标,找到WIFE信号,输入密码连接。

2.修改两个文件

(1)在ssh成功访问树莓派之后,在命令行输入下面这条指令

要在命令模式下配置无线网络,只需要编辑这一个文件:

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

回车,进入编辑界面,如下图示:

上图是已经配置好的。

在文件最后一行添加以下配置

network={
    ssid="无线网络名称"
    psk="无线网络密码"
}
将上面内容中的名称和密码替换为你自己的无线名称和密码。

上面文本的目的是设置连接无线网络的名称与密码,此处无线网络名称是“Xiaomi_66E5”,密码是“mima1234”

根据需要修改,然后ctrl+x,选择YES,保存退出.以后树莓派开机之后就可以自动连接无线网络。

无线网络名称,可以在树莓派的配置工具sudo raspi-config里面填写,也可以象上面这样编辑文件填写.

无线网络名称可以自动查找:(参考:https://blog.csdn.net/u010013028/article/details/106340105)

设备型号3b+1、搜索附近的wifi
sudo iwlist wlan0 scan | grep ESSID2、sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
在文件结尾添加network={ssid="wifi名称"psk="wifi密码"
}

注意:配置wifi密码

配置明文密码存在安全性问题,树莓派支持将密码配置为ASCII表示形式(如上例中的引号所示)或预加密的32字节十六进制数字。预加密可以使用树莓派自带的工具wpa_passphrase生成.参考https://blog.csdn.net/u010013028/article/details/106340105

sudo iwlist wlan0 scan | grep ESSID:

无线网络名称和密码在系统配置里填比较直观一些:sudo raspi-config



输入无线路由的ID,登录密码.确定.Finish.

可以查看文件里的无线网登录设置:sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

树莓派的IP地址是在/etc/dhcpcd.conf里设置

https://www.jianshu.com/p/bd918ef98a4d

(2).修改第2个文件

配置完成无线网络连接后,还想要实现静态地址,也是同样编辑一个文件即可:

sudo nano /etc/dhcpcd.conf

然后在文件最后一行后面添加下面内容:

interface wlan0
     static ip_address=192.168.31.11/24
     static routers=192.168.31.1
     static domain_name_servers=192.168.31.1
其中interface字段后跟的是网卡名称,这个例子中我用的是无线网卡,用有线的需要替换为eth0。剩下的三个字段分别指ip地址、网关地址、dns服务器地址。

需要修改 /etc/dhcpcd.conf ,也就是 DHCP 的配置文件。

sudo nano /etc/dhcpcd.conf

在文件结尾加入以下内容:(这部分没实践测试)

interface wlan0  #指定接口
static ip_address=192.168.1.141/24 #IP根据需要更改,/24的意思是子网掩码为 255.255.255.0
static routers=192.168.1.1 #网关
static domain_name_servers=192.168.1.1 10.18.0.1 # DNS

需要注意的是,改的IP必须和路由器在同一网段,且网关相同
手动静态IP要注意不能跟路由器 DHCP 所自动分配的 IP 冲突,否则树莓派就有可能无法正常联网。

当前树莓派B3上的/etc/dhcpcd.conf内容是:

interface enxb827eb687fe0   #enxb827eb687fe0是树莓派上有线网卡的名
inform 192.168.137.204      #设置有线网卡的IP
static routers=192.168.137.1
#static routers=192.168.137.2noipv6
static domain_name_servers=192.168.31.1  #设置域名服务器,

换另一个type-c转rj45,在笔记本电脑上arp -a,可以看到树莓派的ip,但ping不通,未选择共享,此时图标上出现红色X号,


之后,在wlan上选共享,并选这个以太网6:

则红色X号消失,在笔记本电脑上arp -a可以看到树莓派IP,也能vnc连上.

总之,以太网上是不需要选共享的:

上网正常.

注意:在wlan上选共享之后,则有线连接树莓派的那个usb转rj45的IP自动调整为尾号为1,而不能是其它,如是别的则ping不通.
sudo nano /etc/dhcpcd.conf文件里的路由IP(192.168.137.1)是自动加的.

谁与树莓派相连,则谁的IP设为尾号1(如本例192.168.137.1,前面的与树莓派的一致在同一网段)


六.VNC 连接树莓派:

1.pc上安装vnc viewer

下载网址:https://www.realvnc.com/en/connect/download/viewer/

下载链接:https://www.realvnc.com/download/file/viewer.files/VNC-Viewer-6.20.529-Windows.exe下载速度很快.

2.安装vnc viewer之后连接

之前配置树莓派时,已开启vnc

连接发现,竟然也登录不了,

提示:The connection was refused by the computer

树莓派的地址之前也是这样三位四段,后面没加端口号也能访问,这次不行了.

终端看一下,树莓派的vncserver有没有启动,运行一下,看看有什么信息,结果如下:

pi@raspberrypi:~ $ vncserver
VNC(R) Server 6.7.2 (r42622) ARMv6 (May 13 2020 19:34:20)
Copyright (C) 2002-2020 RealVNC Ltd.
RealVNC and VNC are trademarks of RealVNC Ltd and are protected by trademark
registrations and/or pending trademark applications in the European Union,
United States of America and other jurisdictions.
Protected by UK patent 2481870; US patent 8760366; EU patent 2652951.
See https://www.realvnc.com for information on VNC.
For third party acknowledgements see:
https://www.realvnc.com/docs/6/foss.html
OS: Raspbian GNU/Linux 10, Linux 5.4.51, armv7l

Generating private key... done
On some distributions (in particular Red Hat), you may get a better experience
by running vncserver-virtual in conjunction with the system Xorg server, rather
than the old version built-in to Xvnc. More desktop environments and
applications will likely be compatible. For more information on this alternative
implementation, please see: https://www.realvnc.com/doclink/kb-546

Running applications in /etc/vnc/xstartup

VNC Server catchphrase: "Boris invest vampire. Helena Sandra edition."
             signature: 5e-98-53-76-8d-82-76-ac

Log file is /home/pi/.vnc/raspberrypi:1.log
New desktop is raspberrypi:1 (192.168.137.124:1)
pi@raspberrypi:~ $

提示新桌面是-----重点是冒号后面有个1:92.168.137.124:1

修改树莓派vnc server的地址:

连接地址修改为192.168.137.124:1之后,可以登录了:

 

七.连接树莓派疑难杂症小结:

正常连接过程:

1.ssh pi@raspberrypi

sudo nano /etc/dhcpcd.conf  #设置树莓派IP

interface enxb827eb687fe0   #enxb827eb687fe0是树莓派上有线网卡的名
inform 192.168.137.204      #设置有线网卡的IP
static routers=192.168.137.1
noipv6
static domain_name_servers=192.168.31.1  #设置域名服务器,

常现杂症处理过程:

2.设置笔记本电脑的wlan,共享,则有线连接的IP自动调整为192.176.137.1,在此之前有线连接IP可能会被自动分配了其它地址,不用管它,只需设好无线的共享,则其IP自会调整.

笔记本上:
arp -a

如果没看到树莓派的IP,则双击VNC的有线连接一次,虽然仍可能连不上,但,此时,再arp -a,可能就会看到树莓派的IP了,但有可能仍ping不通,连不上.

3.打开笔记本电脑的"服务":A.左下角放大镜处搜索"服务"两个字,然后选择"以管理员身份运行",找到"IPsec Policy Agent",然后停止它,这时有可能就能ping通树莓派,并且vnc也能连上了.
如果不能,则再把wlan的共享取消,确定,然后再选中,确定.如此搞一次,则应该是能连上的了.(此时,服务项里那个IPsec应该是启动状态).

好了,如果中途再有连不的情况,就把这后两条搞一遍吧.

另:"服务"的启动方法:(当然,目的是IPsec,,)
1.如上,左下角放大镜处搜索"服务"...
2.开始--windows管理工具---服务.
3.WIN+r,运行services.msc,拖动右边滚动条到约三分之一处,"IP转换配置服务"挨下边的一条即是.

至此,关于连接,算是基本掌握套路了.2020.07.18更


参考:

https://www.raspberrypi.org/documentation/configuration/wireless/wireless-cli.md

如果
        
笔记本通过无线上网,设置wlan属性,共享,在家庭网络连接中,如果有多个有线网卡图标,则选一下所连树莓的有线网卡(可以采用插拔网线的方式看连的是哪一个)

能连上树莓派,但树莓派上不了网.

pi@raspberrypi:~ $ ping www.baidu.com
ping: www.baidu.com: Temporary failure in name resolution
pi@raspberrypi:~ $ cat /etc/resolv.conf
# Generated by resolvconf
domain mshome.net
nameserver 192.168.137.1
pi@raspberrypi:~ $ 

sudo nano /etc/resolv.conf

nameserver 114.114.114.114
nameserver 8.8.8.8

8.8.8.8是谷歌的dns,

Google DNS非常简单,两个非常简单易记的IP地址:“8.8.8.8”和“8.8.4.4”。用户只要在系统的网络设置中选择这两个地址为DNS服务器即可。Linux下设置:
echo nameserver 8.8.8.8 > /etc/resolv.conf
echo nameserver 8.8.4.4 > /etc/resolv.conf
这两行命令直接将8.8.8.8与8.8.4.4写入Linux的DNS客户端解析文件resolv.conf里。

ctrl+o   回车  ctrl+x

但ping还是到不了主机

于是:
禁用有线网卡,之后,再启用,自动分配的ip变了,树莓派的IP也变了,

ping raspberrypi.local正在 Ping raspberrypi.local [192.168.137.204] 具有 32 字节的数据:
来自 192.168.137.204 的回复: 字节=32 时间<1ms TTL=64
来自 192.168.137.204 的回复: 字节=32 时间<1ms TTL=64

重新登录之后,树莓派能登录互联网了.
sudo nano /etc/resolv.conf

# Generated by resolvconf
domain mshome.net
nameserver 192.168.137.1

 /etc/resolv.conf里的内容为自动生成,IP笔记本电脑有线网卡的IP,

之前树莓派连不上互联网,主要是因为树莓的IP与笔记本电脑的有线网卡IP不在同一网段,

这是笔记本电脑的有线网卡IP配置.

正在 Ping raspberrypi.local [192.168.137.204] 具有 32 字节的数据:
来自 192.168.137.204 的回复: 字节=32 时间<1ms TTL=64

得知IP,建立VNC连接.win10有线连接树莓派,莓可上网,OK.

小结,如果连不上网,硬件检查,网卡禁用再重启.

打开树莓派无线网卡,重新启动,

sudo nano /etc/resolv.conf

  GNU nano 3.2                    /etc/resolv.conf                              # Generated by resolvconf
domain mshome.net
nameserver 192.168.137.1
nameserver 192.168.31.1

可见自动加了一行,nameserver 192.168.31.1

有线、无线上网都OK。
拔掉有线,sudo nano /etc/resolv.conf,则有线的那一样自动了。

树莓派上网正常。

更换64位的树莓派系统,按上述操作,能连网之后,sudo apt-get update不成功的解决办法:

sudo apt-get update不成功的原因主要是源,

用系统原来的源,提示有问题:

Err:4 http://deb.debian.org/debian-security/buster/updates main Release404  Not Found [IP: 151.101.76.204 80]
...
...
E: The repository 'http://deb.debian.org/debian-security/buster/updates main Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.

之后换用两行的换源方式,也有问题:一系列提示.

后来看到一文debian10 buster入坑指北-修改更新源,参考清华源上的说明,换了多行的源,并且也作了其推荐的命令操作.

解决步骤:

1.参考清华源说明:https://mirror.tuna.tsinghua.edu.cn/help/debian/

 sudo apt install apt-transport-https ca-certificates  #安装支持https源

2.备份/etc/apt/sources.list
   cp /etc/apt/sources.list  /etc/apt/sources.list.bak    
                                                                  cp -R, -r, --recursive          复制目录及目录内的所有项目                                                                                                                    cp -s, --symbolic-link          只创建符号链接而不是复制文件
                                                                  cp -S, --suffix=后缀            自行指定备份文件的<后缀>
                                                                  cp --target-directory=目录  将所有参数指定的<来源>文件/目录复制至<目录>
                                                                  cp -u, --update     只在<来源>文件比目的地文件新,或目的地文件不存在时才进行复制
                                                                  cp  --help     display this help and exit
                                                                  cp --version  output version information and exit

    (或者sudo mv /etc/apt/sources.list /etc/apt/sources.list.bak   #把原文件改名.)

3.sudo nano sources.list
   粘贴从https://mirror.tuna.tsinghua.edu.cn/help/debian/复制过来的源(可用右键,Paste)

# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ buster main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-updates main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-updates main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-backports main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-backports main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian-security buster/updates main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security buster/updates main contrib non-free

最后可以先sudo apt update,再sudo apt-get update成功,sudo apt-get upgrade成功.

cat /etc/apt/sources.list  #显示文件内容源...       

也可换成如下源试试:

deb http://deb.debian.org/debian buster main
deb http://security.debian.org/debian-security buster/updates main
deb http://deb.debian.org/debian buster-updates main

在没有编辑软件 的时候,也可用通过tee命令追加的方式添加源:

pi@raspberrypi:/ $ sudo tee abc123.list >/dev/null <<EOF
> deb http://deb.debian.org/debian buster main
> deb http://security.debian.org/debian-security buster/updates main
> deb http://deb.debian.org/debian buster-updates main
> EOF

cat:该文本输出命令用于显示文本的全部内容,并全部打印输出

EOF:文本结束符,即“end of file”,表示文件内容的结束

sudo tee abc123.list >/dev/null <<EOF  #用于创建或追加内容至abc123.list文件内

cat abc123.list   #显示内容
sudo rm abc123.list   #删除文件

如遇权限不足问题,可用su root

安装小企鹅输入法(包含五笔):

apt-get -y install fcitx-table-wbpy

-----------------------------------------------

树莓派启用root账户

树莓派使用的linux是debian系统,所以树莓派启用root和debian是相同的。

debian里root账户默认没有密码,但账户锁定。

当需要root权限时,

直接执行

sudo su

即可切换为root用户。

树莓派默认用户是pi,密码为raspberry。

重新开启root账号,可由pi用户登录后,在命令行下执行

sudo passwd root

修改root的密码。

执行此命令后系统会提示输入两遍的root密码,输入你想设的密码即可,然后在执行

sudo passwd -u root 

开启root账号。

如果上面执行完出现”password expiry information changed.“的提示

是因为新版本ssh默认关闭root登陆,可以修改一下ssh的配置文件

sudo nano /etc/ssh/sshd_config

【Ctrl+W】快捷键,搜索【PermitRootLogin without-password】,修改【PermitRootLogin without-password】为【PermitRootLogin yes】。
【Ctrl+O】快捷键,保存。
再按一次回车,然后【Ctrl+X】快捷键退出。
最后用

reboot 

命令重启,这样就可以解锁root账户。

----------------------------

使用pi用户登录,执行下面命令(此命令是给root账户设置密码的,当切换到root管理员后,此命令无效)

sudo passwd root

输入新密码.

su pi #切回pi

三.图像化连接:两种方法,win10的远程连接和vnc的连接

第一种:用win10远程连接

1.sudo apt-get install xrdp

在此之前先sudo raspi-config设置好,sudo apt-get update

2.用win10自带的远程桌面连接,

只需要树莓派的ip,然后如下图用户名pi,密码(自知),OK

第二种,笔记本电脑安装vnc viewer,树莓派上开始配置的时间开启vnc即可.

1.修改sources.list    (用清华源)

sudo nano /etc/apt/sources.list    #用nano编辑修改sources.list

例:阿里云配置方法https://developer.aliyun.com/mirror/raspbian?spm=a2c6h.13651102.0.0.3e221b11mbfPgj

编辑 /etc/apt/sources.list 文件,删除原文件所有内容,用以下内容取代:

deb https://mirrors.aliyun.com/raspbian/raspbian/ buster main non-free contrib
deb-src https://mirrors.aliyun.com/raspbian/raspbian/ buster main non-free contrib

目前在用的,比较好的源: (2020.09.1,下面这个多源方案,已不适合)

2020.7.17

deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ buster main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-updates main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-updates main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-backports main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-backports main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian-security buster/updates main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security buster/updates main contrib non-free

中科大deb http://mirrors.ustc.edu.cn/raspbian/raspbian/ stretch main contrib non-free rpi

清华deb https://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ stretch main contrib non-free rpi

大连东软deb http://mirrors.neusoft.edu.cn/raspbian/raspbian/ stretch main contrib non-free rpi

重庆大学deb http://mirrors.cqu.edu.cn/raspbian/raspbian/ stretch main contrib non-free rpi

浙江大学deb http://mirrors.zju.edu.cn/raspbian/raspbian/ stretch main contrib non-free rpi

阿里云deb http://mirrors.aliyun.com/raspbian/raspbian/ stretch main contrib non-free rpi

搜狐deb http://mirrors.sohu.com/raspbian/raspbian/ stretch main contrib non-free rpi

树莓派写卡后连接诸多问题及方法相关推荐

  1. 树莓派第一次开机自动连接WIFI(不用显示屏方法)

    当我们把树莓派系统镜像烧录到SD卡之后,我们在windows看到的TF卡变成了空间很小的名为boot的盘,我们在此目录下新建一个名为wpa_supplicant.conf空白文件,并在其中加入以下代码 ...

  2. cuid卡写入后锁死_荣耀手机NFC升级了:公交、门禁、支付、饭卡、加密卡还能写卡...

    2019年双十一期间,入手了荣耀magic2手机,其实去年用过一次,今年换了多次还是特别喜欢,主要是麒麟980旗舰CPU,全面滑屏特有面子. 入手的第一时间,自己就启用了手机的钱包功能,手机钱包除了小 ...

  3. 解决cuid卡写数据后,无法读取。以及救卡方法

    最近入手了几张cuid卡,用来复制校园卡的.但在写数据的时候发现的一系列问题.下面说一下我的解决方法.链接在评论区. 设备:pn532,手机 软件:上位机,M1T,以及手机上的mifare class ...

  4. 晶振虚焊导致TI 28335 DSP 烧写FLASH后,连接仿真器时正常工作,拔掉仿真器却不能启动运行...

    遇到个诡异的问题,28335的DSP,之前程序调试一切正常,但是烧写FLASH后,拔掉仿真器却始终部工作. 解决思路: 1) 检查配置文件貌似没什么问题,复制到其他工程,在开发板上拔掉仿真器启动正常. ...

  5. fat32 linux 打包工具_一个方便的用于创建树莓派 SD 卡镜像的程序 | Linux 中国

    开始在 Mac 上使用 Raspberry Pi Imager.-- James Farrell(作者) 有多种购买树莓派的方法,根据你的购买渠道的不同,可能附带或不附带操作系统.要在树莓派上安装操作 ...

  6. 树莓派sd卡格式化_利用树莓派和移动硬盘搭建下载机,常见视频网站都可下载...

    前言 一直想搭建一个下载机,查了很多资料,觉得树莓派+移动硬盘应该是最好的选择.树莓派是比较小众的东西,它可不是什么吃的,它是一台完整的微型电脑.对于树莓派,下载只是很小的一个功能. 树莓派 终于下手 ...

  7. 树莓派系统烧录,连接电脑,电脑远程桌面控制树莓派(树莓派无屏幕,校园网)

    1.系统烧录 本人初学树莓派,没买屏幕,在学校里,用的是校园网,没有路由器,所以没办法直接通过网线连接树莓派和路由器,好让电脑能远程桌面控制树莓派,所以只能用迂回的方法,先让电脑通过ssh连接树莓派, ...

  8. 防复制防破解小区门禁梯控升级非联网CPU卡脱机写卡门禁梯控一卡通系统92HID623CPU V5.00操作说明之设备与楼栋单元设置

    防复制防破解小区门禁梯控升级非联网CPU卡脱机写卡门禁梯控一卡通系统92HID623CPU V5.00操作说明之设备与楼栋单元设置的基本操作 CPU卡门禁一体机 1.运行软件 双击桌面的快捷图标:yk ...

  9. socket 长链接linux,手把手教你写 Socket 长连接

    原标题:手把手教你写 Socket 长连接 8点43分打卡 就是真爱 本文转载自公众号 玉刚说,由玉刚说写作平台[1]提供写作赞助 原作者:水晶虾饺[2] 版权声明:本文版权归微信公众号玉刚说所有,未 ...

最新文章

  1. SVO: 视觉SLAM中特征点法与直接法结合
  2. Android下资源图片的加密和解密
  3. cvCalcBackProject的例子
  4. 企业架构(四)——联邦企业架构(FEA)
  5. DeepLearning.AI第一部分第三周、 浅层神经网络(Shallow neural networks)
  6. Java 8的8个新功能
  7. WinSock I/O 模型 -- OVERLAPPED I/O 模型
  8. iwpriv工具通过ioctl动态获取相应无线网卡驱动的private_args所有扩展参数
  9. Effective Modern C++ 第四章,C++智能指针
  10. 百度邀您来听一场云存储的大戏!
  11. 一些SharePoint 2007开发的在线课程
  12. mysql查阅建立的库_mysql 怎么查看创建的数据库和表
  13. 分享PMP真题回忆,出征软考高级项目管理师
  14. android获取wifi的SSID
  15. 转-Tensorflow之GPU和CPU
  16. 代码统计工具CLOC
  17. 写作小技能:知识工作者的全套手艺
  18. Redis和MongoDB的区别(面试受用)
  19. [Linux] Linux不分区硬盘挂载
  20. fbx sdk android,Autodesk FBX SDK Program 中文 (一)

热门文章

  1. outer apply的用法
  2. JavaScript - V8
  3. html登陆成功自动跳转,点击登录,登陆成功,自动跳转到起始页面,这要怎么做?...
  4. ksoftirqid进程CPU100%排查
  5. 一款基于企业微信的固定资产管理软件
  6. 在 tsx 中使用 react 的 ref 属性
  7. NLP算法之一(朴素贝叶斯理论部分)
  8. iOS 审核总被拒?如何提升 iOS 审核通过率!
  9. 计算机网络合集(除应用层之外)
  10. 023 A转置矩阵=A的性质(三大性质)