树莓派的使用笔记
发布时间 :
字数:1.9k
阅读 :
开启ssh
在最新的树莓派系统中,默认是关闭了SSH功能,我们现在将SSH开启!
在boot盘下新建一个文件,名称为SSH,注意没有后缀名!且文件名为大写!
自动连接WiFi
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| # 开机前连接,在boot分区下创建wpa_supplicant.conf nano wpa_supplicant.conf country=CN ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev update_config=1 network={ ssid="WiFi名" psk="WiFi密码" key_mgmt=WPA-PSK priority=1 } # 开机后连接 sudo nano /etc/wpa_supplicant/wpa_supplicant.conf # network={ ssid="WiFi name" psk="12345678" key_mgmt=WPA-PSK priority=5 }
|
修改源
1 2 3 4 5 6 7 8 9
| sudo nano /etc/apt/sources.list # deb http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ buster main non-free contrib deb-src http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ buster main non-free contrib
sudo nano /etc/apt/sources.list.d/raspi.list # deb http://mirrors.tuna.tsinghua.edu.cn/raspberrypi/ buster main ui sudo apt clean && sudo apt autoclean && sudo aptitude update && sudo apt dist-upgrade -y
|
安装桌面监视工具
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| sudo apt-get install conky -y conky -b & # 自定义样式 sudo nano ~/.config/.conkyrc # 运行查看效果 conky -b -c /home/pi/.config/.conkyrc & xcompmgr & cd /etc/xdg/lxsession/LXDE-pi sudo nano autostart # 添加 xcompmgr
# 创建桌面快捷方式 sudo nano /etc/xdg/autostart/conky.desktop [Desktop Entry] Type=Application Name=conky Comment=runs conky NoDisplay=true Exec=conky -b -c /home/pi/.config/.conkyrc NotShowIn=GNOME;KDE;XFCE; # sudo reboot now
|
备注 - stretch 设置自启动
1 2 3 4 5 6 7 8 9 10 11
| sudo nano /usr/bin/conky.sh #!/bin/sh (sleep 10s && conky) & exit 0
[Desktop Entry] Name=conky Type=Application Exec=sh /usr/bin/conky.sh Terminal=false Comment=system monitoring tool.Categories=Utility;
|
安装Mariadb
1 2 3 4 5 6 7 8 9 10 11 12
| sudo apt install mariadb-server mariadb-client -y sudo systemctl start mysql sudo mysql_secure_installation sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf # bind-address = 127.0.0.1 sudo systemctl restart mysql sudo mysql -u root -p USE mysql; UPDATE user SET plugin='mysql_native_password' WHERE User='root'; FLUSH PRIVILEGES; exit; sudo systemctl restart mysql
|
安装NodeJS
1 2 3 4 5 6
| sudo apt purge node nodejs npm curl -sL https://deb.nodesource.com/setup_14.x | sudo bash - sudo apt install nodejs node -v npm -v sudo npm install -g npm nrm n yarn
|
安装Samba
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| sudo apt install samba samba-common-bin sudo smbpasswd -a pi # 配置 sudo nano /etc/samba/smb.conf [pi] path = /data valid users = pi browseable = Yes writeable = Yes writelist = pi create mask = 0777 directory mask = 0777 # 重启服务 sudo systemctl restart smbd
|
挂载磁盘
1 2 3 4 5 6
| sudo fdisk -l sudo mkfs.exfat /dev/sda sudo mount /dev/sda /extra sudo apt-get install fuse-utils ntfs-3g sudo nano /etc/fstab sudo mount -o uid=pi,gid=pi /dev/sdb /backup
|
更新固件
1 2 3 4 5 6
| sudo rpi-update sudo apt-get install ca-certificates #同步时间 sudo apt-get install ntpdate sudo ntpdate -u ntp.ubuntu.com sudo UPDATE_SELF=0 rpi-update
|
安装Dashboard
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| # 安装服务环境 sudo apt install -y git nginx default-jdk
sudo apt install -y -t buster php7.3-fpm php7.3-curl php7.3-gd php7.3-intl php7.3-mbstring php7.3-mysql php7.3-imap php7.3-opcache php7.3-sqlite3 php7.3-xml php7.3-xmlrpc php7.3-zip php7.3-fpm php7.3-cli php7.3-curl php7.3-gd php7.3-cgi
# 配置nginx sudo nano /etc/nginx/sites-available/default
location / { index index.html index.htm index.php default.html default.htm default.php; }
location ~ .*\.php(\/.*)*$ { #fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php7-fpm.sock; fastcgi_index index.php; include fastcgi_params; set $real_script_name $fastcgi_script_name; if ($fastcgi_script_name ~ "(.+?\.php)(/.*)") { set $real_script_name $1; set $path_info $2; } fastcgi_param SCRIPT_FILENAME $document_root$real_script_name; fastcgi_param SCRIPT_NAME $real_script_name; fastcgi_param PATH_INFO $path_info; }
sudo systemctl enable nginx sudo systemctl restart nginx sudo systemctl restart php7.3-fpm
# 重新加载配置信息 sudo nginx reload -s
# cd /var/www/html sudo git clone https://github.com/spoonysonny/pi-dashboard.git dashboard sudo chown -R www-data dashboard
|
安装Tomcat
1
| sudo apt install tomcat9* openssl
|
开启64位内核
1 2 3
| sudo nano /boot/config.txt # arm_64bit=1
|
开启BBR TCP加速
1 2 3 4 5 6 7
| sudo bash -c 'echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf' sudo bash -c 'echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf' sudo sysctl -p sudo reboot sysctl net.ipv4.tcp_available_congestion_control net.ipv4.tcp_available_congestion_control = bbr cubic reno lsmod | grep bbr
|
其他
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
| sudo apt full-upgrade sudo apt install rp-bookshelf sudo apt install mage rpi-update
# 修改swap分区 sudo nano /etc/dphys-swapfile # 修改CONF_SWAPSIZE的值 # 刷新分区 sudo /etc/init.d/dphys-swapfile restart # 查看大小 free -h # 安装屏幕设置 sudo apt-get install screensaver sudo nano /etc/lightdm/lightdm.conf
-------- # 关闭锁频 sudo vi /etc/lightdm/lightdm.conf 取消其中的注释 #xserver-command=X 并修改为 xserver-command=X -s 0 -dpms -s # –设置屏幕保护不启用 dpms 关闭电源节能管理 # 重启树莓派 sudo reboot --------
#鼠标不移动时自动隐藏光标 sudo apt-get install unclutter #开机自动设置 sudo echo "@unclutter -idle 1 -root" >> /etc/xdg/lxsession/LXDE/autostart
# 永久待机禁用休眠 #在/etc/profile.d目录下新建Screen.sh sudo nano /etc/profile.d/Screen.sh #添加执行权限 sudo chmod +x /etc/profile.d/Screen.sh # Screen.sh文件内输入 xset dpms 0 0 0 xset s off ----------------------------- 指令 说明 xset s off 禁用屏幕保护 xset s 3600 3600 设置空闲时间为1小时 xset -dpms 关闭 DPMS xset s off -dpms 禁用 DPMS 并阻止屏幕进入空闲 xset dpms force on 从休眠中自动醒过来 xset dpms force off 立即关闭屏幕 xset dpms force standby 强制屏幕进入待命状态 xset dpms force suspend 强制屏幕进入暂停状态 -------------------------------
# 屏蔽彩虹屏 sudo nano /boot/config.txt # 在config.txt中添加一行disable_splash=1,字面上的意思就是取消启动界面 # 屏蔽开机滚动代码 sudo nano /boot/cmdline.txt # 将console=tty1修改成console=tty3(是将开机的滚动代码指向tty3,从而开机时的tty1没有代码。2016年9月以后的raspbian镜像tty1无需更改成tty3),并添加一句loglevel=3 dwc_otg.lpm_enable=0 console=serial0,115200 console=tty3 root=PARTUUID=cd48578f-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait quiet init=/usr/lib/raspi-config/init_resize.sh splash plymouth.ignore-serial-consoles logo.nologo loglevel=3 # 更换启动主题背景图片 /usr/share/plymouth/themes/pix/splash.png # 将选中图片重命名为splash.png 替换即可
# 安装VSCode # https://packagecloud.io/headmelted/codebuilds curl -s https://packagecloud.io/install/repositories/headmelted/codebuilds/script.deb.sh | sudo bash sudo apt-get install code-oss=1.29.0-1539702238
# Python3.6.4编译安装 sudo apt-get install build-essential tk-dev libncurses5-dev libncursesw5-dev libreadline6-dev libdb5.3-dev libgdbm-dev libsqlite3-dev sqlite3 libssl-dev bzip2 libbz2-dev libexpat1-dev liblzma-dev zlib1g-dev # 下载源码包 https://www.python.org/ftp/python/ wget Python-3.6.4.tgzhttps://www.python.org/ftp/python/3.6.4/Python-3.6.4.tgz tar zxvf Python-3.6.4.tgz # 编译安装 cd Python-3.6.4 sudo ./configure –-with-ssl sudo make sudo make install #查看安装 sudo ls -al /usr/local/bin/python* #查看Python版本 python3 --version #找到匹配的python3.6 whereis python3.6 #查询Python3.6的位置 which python3.6 #把3链接移到3.5.3上。也可以直接rm删除 sudo mv /usr/bin/python3 /usr/bin/python3.5.3 #建立软连接 sudo ln -s /usr/local/bin/python3.6 /usr/bin/python3 sudo rm /usr/bin/lsb_release
# 解除root限制 sudo passwd --unlock root # 安装中文字体 sudo apt-get install fonts-wqy-zenhei fonts-wqy-microhei
# 安装Python3.8.3 sudo apt-get install -y build-essential tk-dev libncurses5-dev libncursesw5-dev libreadline6-dev libdb5.3-dev libgdbm-dev libsqlite3-dev libssl-dev libbz2-dev libexpat1-dev liblzma-dev zlib1g-dev libssl-dev libnspr4-dev libnss3-dev expat apt-get install libxml2-dev libxslt1-dev libjpeg-dev zlib1g-dev wget https://www.python.org/ftp/python/3.8.3/Python-3.8.3.tar.xz sudo tar xf Python-3.8.3.tar.xz -C /usr/local/src/ cd /usr/local/src/Python-3.8.3/ sudo ./configure --prefix=/usr/local/python38 --enable-optimizations && sudo make -j 4 && sudo make install sudo ./configure --prefix=/usr/local/python38 && sudo make && sudo make install sudo ln -s /usr/local/python38/bin/python3.8 /usr/bin/python38 sudo ln -s /usr/local/python38/bin/pip /usr/bin/pip38 sudo python38 -m pip install --upgrade pip pip38 install wheel beautifulsoup4 bs4 certifi chardet Click emoji Flask Flask-Dropzone Flask-Login Flask-SocketIO idna itsdangerous Jinja2 lxml MarkupSafe psutil pymongo PyMySQL python-engineio python-socketio redis requests selenium six soupsieve urllib3 Werkzeug xmltodict youtube-dl pysocks telethon lxml Pillow pip38 install scrapy ln -s /usr/local/python38/bin/scrapy /usr/bin/scrapy
# 修改pip源 sudo nano /etc/pip.conf [global] timeout = 6000 index-url = https://pypi.tuna.tsinghua.edu.cn/simple extra-index-url=https://www.piwheels.org/simple/ [install] use-mirrors = true mirrors = https://pypi.tuna.tsinghua.edu.cn/simple trusted-host = mirrors.aliyun.com
# 开发工具 sudo apt install git gcc g++ make cmake build-essential #jpeg png tiff 等图像格式工具包 sudo apt-get install libjpeg-dev libtiff5-dev libjasper-dev libpng-dev #视频格式工具包 sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev sudo apt-get install libxvidcore-dev libx264-dev #GUI库 sudo apt-get install libfontconfig1-dev libcairo2-dev sudo apt-get install libgdk-pixbuf2.0-dev libpango1.0-dev sudo apt-get install libgtk2.0-dev libgtk-3-dev #数值优化函数包 sudo apt-get install libatlas-base-dev gfortran #header files and a static library for Python sudo apt-get install python3-dev
# 搭建Dart环境 wget https://storage.googleapis.com/dart-archive/channels/stable/release/2.6.0/sdk/dartsdk-linux-arm-release.zip unzip dartsdk-linux-arm-release.zip ./dart-sdk/bin/dart --version
|
从stretch 升级的到buster
1 2 3
| grep -rl stretch /etc/apt/ | sudo xargs sed -i 's/stretch/buster/g' sudo apt update && sudo apt dist-upgrade -y sudo reboot now
|
转载请注明来源,欢迎对文章中的引用来源进行考证,欢迎指出任何有错误或不够清晰的表达。可以在下面评论区评论,也可以邮件至 nathanwriting@126.com
文章标题:树莓派的使用笔记
字数:1.9k
本文作者:Nathaniel
发布时间:2020-03-27, 00:16:31
最后更新:2023-11-06, 22:59:18
原始链接:http://example.com/2020/03/27/using-raspberry/
版权声明: "署名-非商用-相同方式共享 4.0" 转载请保留原文链接及作者。