The following notes are under the official Raspbian system.

Raspberry Pi 4 Model B
Raspberry Pi 4 Model B

Shutdown

Make sure you are shutting your Raspberry Pi down properly before powering it off. Type sudo halt and wait for the Pi to signal it is ready to be powered off by flashing the activity LED. This will protect your sd card as well (ref).

GPIO Reference

Use terminal command pinout to output a reference.

Raspberry Pi Model B GPIO Reference
Raspberry Pi Model B GPIO Reference

Enable SSH

The SSH server for Raspberry Pi by default isn't enabled. But it is quite easy to enable it:

  1. Launch Raspberry Pi Configuration from the Preferences menu
  2. Navigate to the Interfaces tab
  3. Select Enabled next to SSH
  4. Click OK

Alternatively, raspi-config can be used in the terminal:

  1. Enter sudo raspi-config in a terminal window
  2. Select Interfacing Options
  3. Navigate to and select SSH
  4. Choose Yes
  5. Select Ok
  6. Choose Finish

Alternatively, use systemctl to start the service

sudo systemctl enable ssh
sudo systemctl start ssh

When enabling SSH on a Pi that may be connected to the internet, you should change its default password to ensure that it remains secure.

Official SSH Documentation

Enable ROOT SSH Connection

After enabling the SSH server, you can connect to your Pi via SSH:

ssh pi@<ip-address> # default password: raspberry

sudo passwd root # change default root password

sudo passwd --unlock root # unlock root user

sudo sed -i "s/^#PermitRootLogin.*/PermitRootLogin yes/g" /etc/ssh/sshd_config # enable SSH login for root user 

sudo systemctl restart ssh # restart SSH server

sudo cp ~/.bashrc /root/.bashrc # copy the same bash configuration from current user to root

After figuring the SSH, we can also use SFTP tools such as FileZilla to manage the files on the Raspberry Pi from other devices.

Monitor CPU Temperature

There are several way to get the temperature of CPU:

/opt/vc/bin/vcgencmd measure_temp
cat /sys/class/thermal/thermal_zone0/temp
# divide the result by 10000, Celsius

To continuously monitor the temperature of the CPU, save the first command into a file name monitor-temp.sh .

Create Python file monitor-temp.py by issuing following command:

import os
import time

def measure_temp():
        temp = os.popen("vcgencmd measure_temp").readline()
        return (temp.replace("temp=",""))

while True:
        print(measure_temp())
        time.sleep(1)
Use nano monitor-temp.py to create Python file, use Ctl+X and then Y to save that file
This script issues the command /opt/vc/bin/vcgencmd measure_temp every second and print the formatted temperature in the console.

Now by running python monitor-temp.py you can monitor the CPU Temperature every second. Further, we can also use this feature to turn on the cooling fan when CPU temperature is too high, details:

Temperature Controlled Fan for Raspberry Pi 4
The latest Raspberry Pi 4 comes with an option of 4G ram. This truly makes the Raspberry Pi a workable personal portable computer. However, the temperature could go pretty high when it is implementing intensive tasks. The simplest solution would be adding a fan to cool it down, but it makes no sense…

Change apt Sources in Mainland China

The official apt source the Raspbian uses can be extremely slow in mainland China, follow this guide to change the sources for apt:

Raspbian | 镜像站使用帮助 | 清华大学开源软件镜像站 | Tsinghua Open Source Mirror
清华大学开源软件镜像站,致力于为国内和校内用户提供高质量的开源软件镜像、Linux镜像源服务,帮助用户更方便地获取开源软件。本镜像站由清华大学TUNA团队负责维护。
Remember to backup two lists before editing them. Use sudo cp <original-file-path> <backup-file-path> to backup files.

Install Chinese Keyboards

sudo apt install ibus ibus-clutter ibus-gtk ibus-gtk3 ibus-qt4 im-config -s ibus
sudo apt install ibus-pinyin ibus-sunpinyin

Then go to Preferences -> iBus Preferences, add keyboards from there.

Install Autojump

sudo apt install autojump

On Debian-based distros, manual activation is required. Add the following line to ~/.bashrc(for Bash) or ~/.zshrc (if you use zsh):

. /usr/share/autojump/autojump.sh
~/.bashrc