zoukankan      html  css  js  c++  java
  • 树莓派常用命令

     

    刷系统

    格式化

    这样就ok了

     

    开启ssh

    刷完系统在boot盘跟目录创建文件ssh就可以了小写不需要后缀

    汉化

    sudo raspi-config
    
    

    选4

    再选1

    然后把 4个前面是 zh_cn的 用(空格选中)

    然后

    ok

    选zh_CN utf_8

    重启

    sudo reboot
    

    上传文件权限不够

    sudo chmod 777 /etc/init.d/h

    树莓派4设置u盘为系统

    https://www.quarkbook.com/?p=638
    
    流程
    分别把sd卡和u盘都装系统
    
    运行
    sudo blkid
    查看U盘的PARTUUID和sd卡的PARTUUID
    
    /dev/mmcblk0p1: LABEL="RASPI" UUID="B8F2-1311" TYPE="vfat" PARTUUID="34bb5735-01"
    /dev/sda1: LABEL_FATBOOT="boot" LABEL="boot" UUID="3FFE-CDCA" TYPE="vfat" PARTUUID="698e33bd-01"
    /dev/sda2: LABEL="rootfs" UUID="3122c401-b3c6-4d27-8e0d-6708a7613aed" TYPE="ext4" PARTUUID="698e33bd-02"
    /dev/mmcblk0: PTUUID="34bb5735" PTTYPE="dos"
    其中/dev/mmcblk0p1和2为SD卡,以及sda1和2为U盘或者SSD分区。
    重点需要的是sda2中的PTUUID
    
    
    把sd卡的
    /boot/cmdline.txt
    PARTUUID="2e903552-02"
    替换为
    PARTUUID=”698e33bd-02″
    
    把u盘的
    /etc/fstab
    PARTUUID="698e33bd-02"
    替换为
    PARTUUID=”2e903552-02"
    

    创建ap

    sudo create_ap --no-virt wlan0 eth0 123111 12345678
    sudo create_ap --no-virt  有网络的网卡 wifi网卡 wifi名 wifi密码
    
    
    sudo create_ap --no-virt wlan0 eth0 123111 12345678 --dhcp-dns 192.168.99.99
    sudo create_ap --no-virt wlan0 eth0 123111 12345678 --dhcp-dns 设置dnsip
    
    
    参数解释:
    wlan0:无线网卡名称
    eth0:有线网卡名称
    wifiname:WIFI名称
    wifipass:WIFI密码
    

    关机

    安全关机:
    sudo shutdown -h now
    
    sudo halt
    
    sudo poweroff
    
    sudo init 0
    上面四行代码都可以,执行一行都可以安全关机
    

    重启

    重启方法:
    sudo reboot
    
    shutdown -r now
    

    启动vnc

    vncserver
    

    默认用户名和密码

    pi
    raspberry
    

    改密码

    sudo passwd pi
    
    
    sudo passwd root
    
    
    

    执行php

    php 文件名
    

    执行jar文件

    执行命令:java -jar 需要运行的jar名称.jar
    
    java -jar /home/pi/项目/10.jar
    java -jar /home/pi/ck.jar
    
    

    网卡

    wifi网卡
    wlan0
    查看网卡
    ifconfig -a
    
    
    重启网卡
    sudo ifconfig wlan0 down 
    sudo ifconfig wlan0 up
    
    
    重启网络
    sudo /etc/init.d/networking restart
    
    
    网卡配置教程
    https://blog.csdn.net/mountzf/article/details/52035499
    
    

    创建虚拟网卡

    我们向eth0中添加一块虚拟网卡:
    第一种方法:快递创建删除虚拟网卡
    sudo ifconfig eth0:0 192.168.99.99 up
    以上的命令就可以在eth0网卡上创建一个叫eth0:0的虚拟网卡,他的地址是:192.168.1.63
    如果不想要这个虚拟网卡了,可以使用如下命令删除:
    sudo ifconfig eth0:0 down
    重启服务器或者网络后,虚拟网卡就没有了.
    hzhsan:但是发现添加的虚拟网卡和原网卡物理地址是一样的。
    
    多种方法
    https://www.cnblogs.com/henglinux/p/9571517.html
    
    
    
    source-directory /etc/network/interfaces.d
    auto eth0:0
    iface eth0:0 inet static
    address 192.168.99.99
    netmask 255.255.255.0
    
    
    
    https://blog.csdn.net/wenwenxiong/article/details/50331809
    
    
    
    

    解压zip

    unzip xx.zip -d /home/pi
    
    
    把xx.zip解压到/home/pi目录里面
    

    更新

    sudo apt-get update
    sudo apt-get upgrade
    
    
    sudo apt-get update && sudo apt-get dist-upgrade
    
    
    
    
    

    卸载

    如果用apt-get install装的,那就用apt-get remove删除。
    如果pacman -S 装的,就用pacman -R删除
    
    
    要cd到安装目录
     如果自己编译make && make install装的,
     就得看makefile里面有没有写uninstall方法,
     有的话可以用make uninstall。
     没有的话看makefile里面install方法复制到了哪些文件夹,删之
     
     清楚变量环境
     unset  LUA_PATH
    
    
    sudo apt-get install dnsmasq
    
    sudo apt-get remove dnsmasq
    
    
    安装
    sudo apt-get install isc-dhcp-server
    卸载
    sudo apt-get remove isc-dhcp-server
    
    sudo apt-get install hostapd
    
    sudo apt-get remove iproute2
    iproute2
    hostapd
    procps
     util-linux
     iw haveged -y
     
     
     sudo apt-get install 
     iproute2
     
     启动 配送上的ap
    sudo create_ap --config /etc/create_ap.conf
    
    
    

    安装需要的工具

    lua安装

    lua安装参考教程

    https://github.com/luarocks/luarocks/wiki/Installation-instructions-for-Unix#next-steps

    先卸载系统安装的lua

    
    apt-get remove lua5.1
    
    
    sudo apt install build-essential libreadline-dev
    
    
    
    curl -R -O http://www.lua.org/ftp/lua-5.3.4.tar.gz
    tar -zxf lua-5.3.4.tar.gz
    cd lua-5.3.4
    make linux test
    sudo make install
    
    
    
    
    把
    /home/pi/lua-5.3.4/scr
    复制到
    /usr/include/lua
    没有lua文件夹就新建一个
    改文件名为5.1
    就这样/usr/include/lua/5.1
    
    
    
    cd /home/pi
    

    安装luasocket

    https://blog.csdn.net/songyulong8888/article/details/80363444

    wget https://luarocks.org/releases/luarocks-3.2.0.tar.gz
    tar zxpf luarocks-3.2.0.tar.gz
    cd luarocks-3.2.0
    ./configure
    
    
    
    源码下载编译、安装,luasocket需要在luarocks-3.2.0里面
    git clone https://github.com/diegonehab/luasocket.git
    cd luasocket
    make
    make install-both
    make test
    
    #如果显示如下信息,恭喜你安装成功了!
    
    
    
    
    lua test/hello.lua
    Hello from LuaSocket 3.0-rc1 and MIME 1.0.3!
    
    # luasocket makefile 
    #
    # see src/makefile for description of how to customize the build
    #
    # Targets:
    #   install            install system independent support
    #   install-unix           also install unix-only support
    #   install-both       install for lua51 lua52 lua53
    #   install-both-unix      also install unix-only
    #   print              print the build settings
    
    
    

    树莓派上安装php

    搜索

    find / -name '*phpize*'

    先更新 不能安装就需要先改源

    安装php
    sudo apt-get install php
    打印版本
    php -v
    不知道是啥
    sudo apt install php7.3-dev
    
    
    
    这个也不知道是什么
    
    安装redis为php添加上redis扩展。
    如果权限不够产生问题请自己加上代码sudo!
    如:sudo git clone https://github.com/phpredis/phpredis.git
    
    git clone https://github.com/phpredis/phpredis.git
    cd phpredis 
    /usr/bin/phpize7.3 (不同php版本的情况下phpize版本不同)
    ./configure --with-php-config=/usr/bin/php-config7.3 (这里边也需要根据情况指定php-config的版本,且和phpize的版本保持一致。)
    make && make install
    
    
    
    
    创建软件连接
    
    ln -s /usr/local/include/lua.h /usr/include/lua/lua.h
    cp /usr/local/lib/liblua.a /usr/lib/liblua.a
    
    
    编译phplua
    
    wget http://pecl.php.net/get/lua-2.0.3.tgz
    
    tar xvf lua-2.0.3.tgz
    
    cd lua-2.0.3
    
    /usr/bin/phpize
    
    ./configure -with-php-config=/usr/bin/php-config
    
    make
    
    sudo make install
    
    
    
    
    /etc/php/7.3/apache2和/etc/php/7.3/cli
    里面的php.ini最后一行加上
    extension=/usr/lib/php/20180731/lua.so
    保存
    
    然后测试
    
    
    
    <?php
    $lua = new Lua();
    $lua->eval(<<<CODE
        function dummy(foo, bar)
            print(foo, ",", bar)
        end
    CODE
    );
    $lua->call("dummy", array("Lua", "打印1
    "));
    $lua->dummy("Lua", "打印2
    "); // __call()
    var_dump($lua->call(array("table", "concat"), array(array(1=>1, 2=>2, 3=>3), "-")));
    ?>
    
    
    
    
    
    
    
    
    
    不知道怎么弄的反正参考这三个文档
    https://www.cnblogs.com/ly570/p/11173774.html
    
    https://blog.csdn.net/scy1028/article/details/80773979
    
    
    https://www.cnblogs.com/tinywan/p/6813646.html
    
    
    
    
    
    
    
    
    
    
    

    https://blog.csdn.net/stpeace/article/details/78787176

    安装phplua扩展

    https://www.cnblogs.com/ly570/p/11173774.html

    https://blog.csdn.net/scy1028/article/details/80773979

    php 的lua扩展库安装准备:

    卸载jdk11
    sudo apt-get purge openjdk-11-jre-headless
    sudo apt-get purge openjdk-9-jre-headless
    sudo apt-get purge openjdk-8-jre-headless
    sudo apt-get remove openjdk-9-jre-headless
    sudo apt-get remove --purge openjdk-9-jdk
    
    
    sudo apt-get purge java-9-openjdk-armhf
    
    
    sudo apt-get install openjdk-8-jre-headless
    sudo apt-get install openjdk-8-jre
    
    
    
    
    
    tar xvf rxtx.2.1.7r2.java8.tar.gz
    
    cd rxtx-2.1-7r2-Java8
    ./configure
    
    make
    
    sudo make install
    
    
    

    安装ap需要的程序

    2是自定义

    https://www.cnblogs.com/visionsl/p/8042315.html

    安装hostapd和dhcpd
    
    sudo apt-get install -y hostapd 
    sudo apt-get install -y isc-dhcp-server
    sudo apt-get install dhcpd
    开机不需要启动这两个服务,建议把它们关掉:
    sudo update-rc.d -f hostapd remove
    
    配置hostapd和dhcpd
    
    
    新建文件/etc/hostapd/hostapd.conf 
    并写入下面内容
    interface=wlan0
    ssid=000
    hw_mode=g
    channel=10
    macaddr_acl=0
    auth_algs=3
    wpa=2
    wpa_passphrase=12345678
    wpa_key_mgmt=WPA-PSK
    wpa_pairwise=TKIP CCMP
    rsn_pairwise=TKIP CCMP
    
    在文件/etc/dhcp/dhcpd.conf最后加入
    并写入下面内容
    subnet 192.168.0.0 netmask 255.255.255.0{
      range 192.168.0.2 192.168.0.10;
      option routers 192.168.0.1;
      option domain-name-servers 192.168.0.1,180.76.76.76,8.8.8.8;
    }
    
    新建/home/pi/logs目录
    新建/home/pi/logs/ap-start.sh文件
    并写入下面内容
    把ppp0改为eth0
    
    
    #!/bin/bash
    # 开启内核IP转发
    bash -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
    # 开启防火墙NAT转发(如果本机使用eth0上网,则把ppp0改为eth0)
    iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
    # 关闭NetworkManager对无线网卡的控制(这句实测中nm参数无效, 但似乎不影响使用)
    nmcli nm wifi off
    # 设置并启动无线网卡
    ifconfig wlan0 192.168.0.1 netmask 255.255.255.0
    # 解锁无线设备,可以用rfkill list查看解锁结果.
    rfkill unblock wlan
    # 睡眠6秒,待rfkill解锁生效
    sleep 6s
    # 启动dhcpd和hostapd,如果hostapd无法启动请查看日志hostapd.log,查看这两个进程ps -ef|egrep "dhcpd|hostapd"
    nohup hostapd /etc/hostapd/hostapd.conf >/home/pi/logs/hostapd.log 2>&1 &
    dhcpd wlan0 -pf /var/run/dhcpd.pid
    ps -ef|head -n1 && ps -ef|egrep "dhcpd|hostapd"
    
    
    
    新建/home/pi/logs/ap-stop.sh
    并写入下面内容
    #!/bin/bash
    killall hostapd dhcpd
    bash -c "echo 0 > /proc/sys/net/ipv4/ip_forward"
    ifconfig wlan0 down
    
    
    
    给2个脚本增加执行的权限
    chmod +x /home/pi/logs/ap-*.sh
    
    
    启动ap   会提示第7行无效
    sudo /home/pi/logs/ap-start.sh
    
    停止ap
    sudo /home/pi/logs/ap-stop.sh
    
    
    
    
    
    
    
    三以上的方法
    git clone https://github.com/oblique/create_ap.git
    cd create_ap/
    sudo make install
    
    sudo apt-get install util-linux procps hostapd iproute2 iw haveged dnsmasq -y
    
    hostapd
    
    
    
    
    

    创建ap

    sudo create_ap --no-virt wlan0 eth0 123111 12345678
    
    参数解释:
    wlan0:无线网卡名称
    eth0:有线网卡名称
    wifiname:WIFI名称
    wifipass:WIFI密码
    
    http://www.wware.org/wide/evt/assistools/createap.html
    
    sudo create_ap wlan0 eth0 123111 12345678 -d
    设置说明
    https://cnzhx.net/blog/use-create_ap-to-create-ap-easily-on-linux/
    
    
    
    配置ap
    /etc/create_ap.conf
    
    
    启动 配送上的ap
    sudo create_ap --config /etc/create_ap.conf
    
    将其加入系统服务(systemd)让其随系统自动启动
    sudo systemctl enable create_ap.service
    
    
    
    dhcp-mac=set:client_is_a_pi,B8:27:EB:*:*:*
    dhcp-reply-delay=tag:client_is_a_pi,2
    
    
    
    

    ap需要 安装 create_ap dnsmasq hostapd

    https://www.jianshu.com/p/9852b60d9b34

    https://www.jianshu.com/p/1fca72a710d5

    这个比较全面

    pi 3的才可以

    https://www.cnblogs.com/visionsl/p/8042315.html

    树莓派上安装yum

    sudo apt-get install -y isc-dhcp-server
    
    

    树莓派3的设置办法:

    git clone https://github.com/oblique/create_ap.git
    

    如果未装git, 就先装上它

    sudo apt-get install git
    
    

    git下来后安装

    cd create_ap/
    sudo make install
    
    

    安装依赖包

    sudo apt-get install util-linux procps hostapd iproute2 iw haveged dnsmasq -y
    
    

    试试创建热点

    sudo ifdown wlan0
    sudo create_ap wlan0 eth0
    
    

    如果不成功

    试加一个参数

    sudo create_ap --no-virt wlan0 eth0
    
    

    如果想一句命令包含你创建的SSID和密码, 可以这样

    sudo create_ap --no-virt wlan0 eth0 000 11111111
    
    

     

    python第三方库

    切换py版本
    安装
    sudo apt-get install python3
    删除编译链
    sudo rm /usr/bin/python
    切换编译连接
    sudo ln -s /usr/bin/python3.7 /usr/bin/python
    sudo ln -s /usr/bin/python2.7 /usr/bin/python
    查看版本
    python --version
    
    py安装第三方库
    apt-get update
    先安装pip
    sudo apt-get install pip
    之后用到
    https://pypi.org/project/thread6/
    搜索要安装的库
    然后 pip install 目录/文件名
    安装就好了
    pip install /home/pi/Downloads/thread6-0.2.0.tar.gz
    
    
    
    

    https://blog.csdn.net/u011957515/article/details/53374604

    的安装,树莓派的Linux有一种直接复制的方式。

    步骤:

    (1)下载好需要的python扩展库

    (2)从树莓派文件管理目录找到如下位置:

    /usr/lib/python2.7/dist-package

    py版本切换

    https://blog.csdn.net/qq_40584960/article/details/86081779

    串口

    https://blog.csdn.net/weixin_43330072/article/details/99331511
    
    
    
    

    novnc webvnc

    删除
    sudo apt-get purge vncserver xrdp
    
    安装
    sudo apt-get install tightvncserver xrdp
    
    xrdp安装失败就更换源
    
    安装完成后
    启动vnc
    vncserver :1
    会让你设置密码看着设置就好
    
    查看端口
    netstat -tnl
    
    有监听5901的端口就ok
    
    cd noVNC
    sudo ./utils/launch.sh --vnc localhost:5901
    
    浏览器打开
    http://192.168.0.103:6080/vnc.html
    
    
    
    

    查看系统版本信息

    cat /etc/os-release
  • 相关阅读:
    hdu7047 /2021“MINIEYE杯”中国大学生算法设计超级联赛(7) 1004 Link with Balls
    hdu7115 Vertex Deletion
    CF1552B B. Running for Gold
    hdu7055 /2021“MINIEYE杯”中国大学生算法设计超级联赛(7) 1012 Yiwen with Sqc
    hdu7050 /2021“MINIEYE杯”中国大学生算法设计超级联赛(7) 1007 Link with Limit
    CF 1560E E. Polycarp and String Transformation(思维)
    CF 1542C C. Strange Function
    STL 算法 std::distance
    STL 算法 std::accumulate
    std::get<C++11多线程库~线程管理>(08):转移线程所有权(2)
  • 原文地址:https://www.cnblogs.com/qq547176052/p/13499139.html
Copyright © 2011-2022 走看看