【Raspberry Pi】树莓派玩耍

Posted by 西维蜀黍 on 2020-01-29, Last Modified on 2021-09-21

查看树莓派系统的位数

安装软件的时候想查看树莓派系统是32位还是64位就出现了以下的操作,具体命令及作用如下:

getconf LONG_BIT        # 查看系统位数
uname -a            # kernel 版本
/opt/vc/bin/vcgencmd  version   # firmware版本
strings /boot/start.elf  |  grep VC_BUILD_ID    # firmware版本
cat /proc/version       # kernel
cat /etc/os-release     # OS版本资讯
cat /etc/issue          # Linux distro 版本
cat /etc/debian_version     # Debian版本编号

虽然树莓派3b的硬件支持64位的系统,但是官方的系统还是32位的,主要应该是为了兼容之前的硬件。

Error

Error1 - cannot currently show the desktop vnc

$ sudo raspi-config

Advanced Options > Resolution, select the appropriate resolution.

升级系统

检查版本

You can check the release of Raspbian, simply reading the content of the os-release file.

$ cat /etc/os-release

升级次版本

First, update your system’s package list by entering the following command:

$ sudo apt update

Next, upgrade all your installed packages to their latest versions with the following command:

$ sudo apt full-upgrade

Note that full-upgrade is used in preference to a simple upgrade, as it also picks up any dependency changes that may have been made.

Generally speaking, doing this regularly will keep your installation up to date for the particular major Raspberry Pi OS release you are using (e.g. Stretch). It will not update from one major release to another, for example, Stretch to Buster.

升级主版本

Warning: Upgrading an existing Stretch image is possible, but is not guaranteed to work in every circumstance and we do not recommend it. If you do wish to try upgrading a Stretch image to Buster, we strongly suggest making a backup first — we can accept no responsibility for loss of data from a failed update.

To upgrade, first modify the files /etc/apt/sources.list and /etc/apt/sources.list.d/raspi.list. In both files, change every occurrence of the word stretch to buster. (Both files will require sudo to edit.)

Then open a terminal window and execute:

$ sudo apt update
$ sudo apt -y dist-upgrade

Answer ‘yes’ to any prompts. There may also be a point at which the install pauses while a page of information is shown on the screen – hold the space key to scroll through all of this and then press q to continue.

Finally, if you are not using PulseAudio for anything other than Bluetooth audio, remove it from the image by entering:

$ sudo apt -y purge "pulseaudio*"

If moving to a new Pi model (for example the Pi 3B+), you may also need to update the kernel and the firmware using the instructions above.

Installation

Install Python 3.8

Before installing Python 3.8 there are some dependencies that we need to install. Use the following command to install the required dependencies.

$ 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 libffi-dev tar wget vim
$ wget https://www.python.org/ftp/python/3.8.7/Python-3.8.7.tgz

Install Python 3.8

Now we will extract and install Python from the source.

$ sudo tar zxf Python-3.8.7.tgz
$ cd Python-3.8.7/
$ sudo ./configure --enable-optimizations
$ sudo make -j 4
$ sudo make altinstall

Check Python version

Now Python is installed you can check the version using the following command.

$ python3.8 -V

Make Python 3.8 as the default version

If you want to use python 3.8 as a default version you can create an alias.echo "alias python=/usr/local/bin/python3.8" >> ~/.bashrc

Then source the .bashrc file.

$ source ~/.bashrc

Check Python Version

After creating an alias check the python version again.

$ python -V 
Python 3.8.0

Now you have successfully installed Python 3.8 on Raspberry Pi.

Clean up

Now you can clean up using the archive

$ sudo rm -rf Python-3.8.0.tgz sudo rm -rf Python-3.8.0

docker using the convenience script

$ sudo apt-get update && sudo apt-get upgrade

$ curl -fsSL https://get.docker.com -o get-docker.sh
$ sudo sh get-docker.sh

$ sudo usermod -aG docker ${USER}
$ newgrp - docker

$ docker version

$ docker run hello-world

Terminal

$ sudo apt install htop git iperf3 net-tools tree curl wget git vim speedtest-cli

oh-my-zsh

$ sudo apt install zsh 
$ zsh --version
$ chsh -s $(which zsh)
$ sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
# zsh-autosuggestions
$ cd ~/.oh-my-zsh/custom/plugins
$ git clone https://github.com/zsh-users/zsh-autosuggestions

# zsh-syntax-highlighting
$ git clone https://github.com/zsh-users/zsh-syntax-highlighting.git

$ vim ~/.zshrc
source ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh
source ~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

Reference