树莓派

树莓派

远程连接

方法1: ssh + cpolar

  1. 开启ssh

    拔下sd卡,通过读卡器读取,在目录下创建名字为ssh的文件,装回sd卡即可

  2. 树莓派安装cpolar

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    # 下载
    curl -L https://www.cpolar.com/static/downloads/install-release-cpolar.sh | sudo bash

    # 查看版本
    cpolar version

    # token认证,在官网可以找到token
    cpolar authtoken xxxxxxxxxxxxxxxxxx

    # 配置cpolar开机自启动
    sudo systemctl enable cpolar

    # 守护进程方式,启动cpolar
    sudo systemctl start cpolar

    # 查看cpolar守护进程状态, active为启动
    sudo systemctl status cpolar

    # 外网ssh连接,官网找地址
    ssh 用户名@映射的网址 -p 端口号

方法2:无线网络 + 远程桌面连接

  1. 添加无线网络信息

    电脑连接sd卡,创建配置文件wpa_supplicant.conf(这步不知道为什么没有生效,直接通过桌面设置的wifi)

    priority:优先级,数字越大优先级越高

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    country=CN
    ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
    update_config=1
    network={
    ssid="无线网名称"
    psk="密码"
    priority=10
    }

    # 有其他wifi可以继续配置
    network={
    ssid="无线网名称"
    psk="密码"
    priority=10
    }
  2. 树莓派安装xrdp

    1
    sudo apt-get install xrdp
  3. windows电脑打开无线热点,查看连接到的设备ip

  4. 打开windows自带的远程桌面连接工具,输入设备的ip及用户名密码来连接桌面

  5. 也可以用其他shell软件来ssh连接树莓派,如用FinalShell还可以进行文件传输

命令

  1. 关机

    1
    2
    3
    4
    sudo poweroff			关闭电源
    sudo shutdown -h now 立刻关机
    sudo shutdown -r now 立刻重启
    sodo shutdown -h +2 2分钟后关机
  2. 命令别名

    1
    2
    3
    4
    5
    6
    7
    8
    # 打开文件
    vim ~/.bashrc

    # 添加下面代码
    lias ll='ls -l'

    # 更新配置文件
    source ~/.bashrc
  3. 基本命令

    1
    2
    3
    4
    ls    
    pwd
    cd
    mkdir

安装软件/环境

Vim

1
sudo apt-get install vim

Python

树莓派4B自带了python3


树莓派
http://xwww12.github.io/2023/12/12/其他/树莓派/
作者
xw
发布于
2023年12月12日
许可协议