经验首页 前端设计 程序设计 Java相关 移动开发 数据库/运维 软件/图像 大数据/云计算 其他经验
当前位置:技术经验 » 数据库/运维 » Linux/Shell » 查看文章
树莓派全面配置
来源:cnblogs  作者:天逸流水  时间:2021/5/24 10:46:09  对本文有异议

树莓派操作

默认的用户名: pi,默认的密码是: raspberry

默认的用户名: root,密码: raspberry

在内存卡boot盘中新建一个ssh的空文件,为了打开ssh功能。

在内存卡boot盘中新建一个wpa_supplicant.conf文本文件,写入wifi配置:

  1. country=CN
  2. ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
  3. update_config=1
  4. network={
  5. ssid="你的无线网名称"
  6. psk="你的无线网密码"
  7. key_mgmt=WPA-PSK
  8. priority=1
  9. }

在树莓派系统内文件位于/etc/wpa_supplicant/wpa_supplicant.conf

初始设置

换清华源、安装基础命令

  1. # 编辑 `/etc/apt/sources.list` 文件,删除原文件所有内容,用以下内容取代:
  2. deb http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ buster main non-free contrib rpi
  3. deb-src http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ buster main non-free contrib rpi
  4. # 编辑 `/etc/apt/sources.list.d/raspi.list` 文件,删除原文件所有内容,用以下内容取代:
  5. deb http://mirrors.tuna.tsinghua.edu.cn/raspberrypi/ buster main ui
  6. sudo apt-get update
  7. sudo apt-get upgrade
  8. sudo apt-get install vim
  9. sudo apt-get install screen

给pip3换成阿里源(自己测试感觉是阿里的源比较全和稳)

  1. # pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple pip -U
  2. # pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/sipmle
  3. # pip config set install.trusted-host pypi.tuna.tsinghua.edu.cn
  4. # 上面的不要看
  5. # 这个命令是本机pip安装时查找的源的位置
  6. pip config list -v
  7. # 打开pip.conf文件,没有就创建目录和文件
  8. ~/.pip/pip.conf
  9. # 添加以下内容
  10. [global]
  11. index-url = https://mirrors.aliyun.com/pypi/simple/
  12. [install]
  13. trusted-host=mirrors.aliyun.com
  14. python -m pip install --upgrade pip

查看

  1. uname -a
  2. cat /etc/os-release

注意

GPU内存不能拉到812M以上,否则会进不了系统。如果进不去了可以通过SD卡插USB修改config文件。

wiringPi

系统自带的一般是2.5.0版本,需要更新到2.5.2版本才能使用gpio readall命令

  1. # 如果没有自带wiringpi
  2. sudo apt-get install wiringpi
  3. # 更新wiringPi
  4. wget https://project-downloads.drogon.net/wiringpi-latest.deb
  5. sudo dpkg -i wiringpi-latest.deb

安装node.js并换源

参考网址:https://github.com/nodesource/distributions/blob/master/README.md

  1. # 先删除自带的低版本nodejs
  2. sudo apt-get remove nodejs
  3. sudo passwd root
  4. # Using Debian, as root
  5. curl -sL https://deb.nodesource.com/setup_14.x | bash -
  6. apt-get install -y nodejs
  7. npm config set registry https://registry.npm.taobao.org

安装防火墙

  1. # 安装
  2. sudo apt- get install ufw
  3. # 启动
  4. sudo ufw enable
  5. # 查看状态
  6. sudo ufw status
  7. # 开启
  8. sudo ufw allow 22

配置静态IP地址

  1. sudo vim /etc/dhcpcd.conf
  2. # 最后添加以下内容,按照自己的路由器配置来
  3. interface wlan0
  4. static ip_address=192.168.1.2/24
  5. static routers=192.168.1.1
  6. static domain_name_servers=114.114.114.114

树莓派系统设置

  1. sudo raspi-config
  2. # 树莓派配置文件 config.txt 官方说明文档:https://www.raspberrypi.org/documentation/configuration/config-txt.md
  3. # VNC开启
  4. 第五行

调整CPU频率

  1. Raspberry Pi OS
  2. sudo nano /boot/config.txt
  3. Ubuntu OS
  4. sudo nano /boot/firmware/config.txt
  5. 超頻
  6. over_voltage=6
  7. arm_freq=2000
  8. gpu_freq=700
  9. 超頻MAX
  10. over_voltage=6
  11. arm_freq=2147
  12. gpu_freq=750
  13. CPU最高頻率
  14. sudo cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq
  15. CPU最低頻率
  16. sudo cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq
  17. CPU目前頻率
  18. sudo cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq

查看温度

  1. # 查看温度一次
  2. vcgencmd measure_temp
  3. # 每2秒刷新温度
  4. watch -n2 vcgencmd measure_temp

搭建文件服务器

  1. sudo apt-get install samba
  2. sudo vim /etc/samba/smb.conf
  3. # 末尾添加
  4. [sun]
  5. comment = sun Storage
  6. path = /home/pi/sun
  7. read only = no
  8. create mask = 0777
  9. directory mask = 0777
  10. guest ok = yes
  11. browseable = yes
  12. # 重启
  13. sudo samba restart
  14. # 开机自启动
  15. sudo update-rc.d samba defaults

安装docker

  1. $ curl -fsSL https://get.docker.com -o get-docker.sh
  2. $ sudo sh get-docker.sh --mirror Aliyun
  3. # 将当前用户加入docker组:
  4. sudo usermod -aG docker $USER

安装Nginx

  1. # 安装nginx依赖包
  2. sudo apt-get install gcc
  3. # 安装PCRE库
  4. sudo apt-get install libpcre3 libpcre3-dev
  5. # 安装zlib库
  6. sudo apt-get install zlib1g zlib1g-dev
  7. # 安装OpenSSL库
  8. sudo apt-get install libssl-dev
  9. tar -zxvf nginx-1.18.0.tar.gz
  10. ./configure --prefix=/usr/local/nginx
  11. make
  12. make install
  13. # 项目路径 /usr/local/nginx

原文链接:http://www.cnblogs.com/sunshen/p/14778734.html

 友情链接:直通硅谷  点职佳  北美留学生论坛

本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728

W3xue 的所有内容仅供测试,对任何法律问题及风险不承担任何责任。通过使用本站内容随之而来的风险与本站无关。
关于我们  |  意见建议  |  捐助我们  |  报错有奖  |  广告合作、友情链接(目前9元/月)请联系QQ:27243702 沸活量
皖ICP备17017327号-2 皖公网安备34020702000426号