Skip to content

Instantly share code, notes, and snippets.

@johnnymillergh
Last active September 6, 2025 03:11
Show Gist options
  • Save johnnymillergh/434469089a5f4c0a0b0cfbd64dc1c9d3 to your computer and use it in GitHub Desktop.
Save johnnymillergh/434469089a5f4c0a0b0cfbd64dc1c9d3 to your computer and use it in GitHub Desktop.
OS Initialization

Raspberry Pi OS Initialization

These steps were validated on Raspberry Pi 4B. (Thu 6 Oct 15:05:21 HKT 2022)

         _,met$$$$$gg.           pi@raspberrypi4b
      ,g$$$$$$$$$$$$$$$P.        OS: Debian 11 bullseye
    ,g$$P""       """Y$$.".      Kernel: aarch64 Linux 5.15.61-v8+
   ,$$P'              `$$$.      Uptime: 20m
  ',$$P       ,ggs.     `$$b:    Packages: 1427
  `d$$'     ,$P"'   .    $$$     Shell: zsh 5.8
   $$P      d$'     ,    $$P     Disk: 4.4G / 33G (14%)
   $$:      $$.   -    ,d$$'     CPU: BCM2835 @ 4x 1.8GHz
   $$\;      Y$b._   _,d$P'      GPU:
   Y$$.    `.`"Y$$$$P"'          RAM: 834MiB / 7636MiB
   `$$b      "-.__
    `Y$$
     `Y$$.
       `$$b.
         `Y$$b.
            `"Y$b._
                `""""

References:

  1. What about aarch64?

    The repository at piwheels.org does not currently support the 64-bit version of the Raspberry Pi OS (currently in beta). We have plans to support it in future, but this requires a significant amount of work, and then rebuilding all wheels on the new architecture. Read more on the blog and issue #220.

Table of Contents

[TOC]

Wi-Fi and SSH Configuration for Headless

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=US

network={
     ssid="wifi-name"
     psk="wifi-password"
     key_mgmt=WPA-PSK
}

Update Raspberry Pi Configuration

$ sudo raspi-config
  • File system expansion, to make sure the SD card is writable
  • GPU ram, 256 mb +
  • Hostname

After updating, reboot Raspberry Pi immediately.

Docker Installation

Install Docker Engine on Debian

Set up the repository

  1. Update the apt package index and install packages to allow apt to use a repository over HTTPS:

    $ sudo apt-get update
    
    $ sudo apt-get install \
        ca-certificates \
        curl \
        gnupg \
        lsb-release
  2. Add Docker’s official GPG key:

    $ curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
  3. Use the following command to set up the stable repository. To add the nightly or test repository, add the word nightly or test (or both) after the word stable in the commands below. Learn about nightly and test channels.

    $ echo \
      "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian \
      $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

Install Docker Engine

This procedure works for Debian on x86_64 / amd64, armhf, arm64, and Raspbian.

  1. Update the apt package index, and install the latest version of Docker Engine and containerd, or go to the next step to install a specific version:

     $ sudo apt-get update
     $ sudo apt-get install docker-ce docker-ce-cli containerd.io
    

    Got multiple Docker repositories?

    If you have multiple Docker repositories enabled, installing or updating without specifying a version in the apt-get install or apt-get update command always installs the highest possible version, which may not be appropriate for your stability needs.

  2. To install a specific version of Docker Engine, list the available versions in the repo, then select and install:

    a. List the versions available in your repo:

    $ apt-cache madison docker-ce
    
      docker-ce | 5:18.09.1~3-0~debian-stretch | https://download.docker.com/linux/debian stretch/stable amd64 Packages
      docker-ce | 5:18.09.0~3-0~debian-stretch | https://download.docker.com/linux/debian stretch/stable amd64 Packages
      docker-ce | 18.06.1~ce~3-0~debian        | https://download.docker.com/linux/debian stretch/stable amd64 Packages
      docker-ce | 18.06.0~ce~3-0~debian        | https://download.docker.com/linux/debian stretch/stable amd64 Packages

    b. Install a specific version using the version string from the second column, for example, 5:18.09.1~3-0~debian-stretch .

    $ sudo apt-get install docker-ce=<VERSION_STRING> docker-ce-cli=<VERSION_STRING> containerd.io
    
  3. Verify that Docker Engine is installed correctly by running the hello-world image.

    $ sudo docker run hello-world
    

    This command downloads a test image and runs it in a container. When the container runs, it prints a message and exits.

Docker Engine is installed and running. The docker group is created but no users are added to it. You need to use sudo to run Docker commands. Continue to Linux postinstall to allow non-privileged users to run Docker commands and for other optional configuration steps.

Upgrade Docker Engine

To upgrade Docker Engine, first run sudo apt-get update, then follow the installation instructions, choosing the new version you want to install.

Add current user to docker group

$ sudo gpasswd -a $USER docker

$ newgrp docker

Poitainer CE Installation

Portainer Official Docker Image

$ docker run \
  --name portainer \
  -p 8000:8000 \
  -p 9000:9000 \
  --restart "always" \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -v ~/docker-file-mapping/portainer-ce:/data \
  -d portainer/portainer-ce:2.15.1-alpine

Network for China

Docker Hub - v2rayA

$ docker run -d \
     --restart=always \
     --privileged \
     --network=host \
     --name v2raya \
     -v /lib/modules:/lib/modules:ro \
     -v /etc/resolv.conf:/etc/resolv.conf \
     -v /etc/v2raya:/etc/v2raya \
     mzz2017/v2raya:1.5.4

Installation

$ sudo apt install proxychains -y

Configuration

$ sudo nano /etc/proxychains.conf
socks4     127.0.0.1 20170

Proxychains Validation

$ proxychains curl http://google.com

If you can access Google, the output should be like,

ProxyChains-3.1 (http://proxychains.sf.net)
|DNS-request| google.com
|S-chain|-<>-127.0.0.1:20170-<><>-4.2.2.2:53-<><>-OK
|DNS-response| google.com is 142.250.206.174
|S-chain|-<>-127.0.0.1:20170-<><>-142.250.206.174:80-<><>-OK
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.google.com/">here</A>.
</BODY></HTML>

ZSH + Oh My Zsh + Powerlevel10k

Install Zsh

Install zsh

$ sudo apt update && sudo apt upgrade -y
$ sudo apt install zsh -y

Set zsh as default

$ chsh -s $(which zsh)

Validate zsh

$ echo $0

Install On My Zsh

https://segmentfault.com/a/1190000040307253

# curl
$ sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

# wget
$ sh -c "$(wget https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"

Install Powerlevel10k

$ git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k

# gitee.com
$ git clone --depth=1 https://gitee.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k

Set oh-my-zsh theme

$ nano ~/.zshrc
ZSH_THEME="powerlevel10k/powerlevel10k"

Install font

# Download fontface into current directory
$ proxychains wget https://github.com/ryanoasis/nerd-fonts/raw/master/patched-fonts/Hack/Regular/HackNerdFontMono-Regular.ttf

# Copy to system font directory
$ sudo cp Hack\ Regular\ Nerd\ Font\ Complete.ttf /usr/share/fonts/truetype

Configure Oh My Zsh Plugins

Install plugins:

$ git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

$ git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
plugins=(
git
history
common-aliases
zsh-autosuggestions
zsh-syntax-highlighting
)

zsh oh-my-zsh 插件推荐

zsh-autosuggestions

zsh-syntax-highlighting

Configure Gateway (router) and DNS

Modify /etc/dhcpcd.conf

$ sudo nano /etc/dhcpcd.conf

With

static routers=192.168.31.51
static domain_name_servers=192.168.31.51

And then restart service

$ sudo service dhcpcd restart

Enter the following into the terminal:

$ sudo apt update
$ sudo apt install snapd

You will also need to reboot your device. This can be accomplished from the terminal (and from the desktop), but make sure you save any open documents first:

$ sudo reboot

After this, install the core snap in order to get the latest snapd.

$ sudo snap install core
core 16-2.45.2 from Canonical✓ installed

And then make snap zsh aware.

I can't use snap packages, even if installed

Modify oh-my-zsh profile

$ nano ~/.zshrc

Add this below,

# Make snapd zsh aware
emulate sh -c "source /etc/profile"

Morikko commented on Jan 31

I followed the answer here: https://stackoverflow.com/a/50958615/7186064I just commented the line. Now, I have no more messages and nextcloud works.

$ sudo nano /etc/ld.so.preload

And then,

# /usr/lib/arm-linux-gnueabihf/libarmmem-${PLATAFORM}.so

Necessary Softwares

  1. Visual Studio Code installation with apt
  2. PyCharm
  3. SDKMAN
  4. Node.js installation with apt
  5. tldr installation with apt

Install Python on Raspberry Pi

sh-python-installer

Command '('lsb_release', '-a')' returned non-zero exit status 1

https://stackoverflow.com/a/66474609/9728243

I had this same problem with python 3.6 and python 3.7 on Raspberry Pi, but I thing it shall work anywhere.

The only thing that works like a charm was to move the lsb_release to a backup file.

 sudo mv /usr/bin/lsb_release /usr/bin/lsb_release_back

The complete doc can be found here: [readthedocs.io].[1]https://neoctobers.readthedocs.io/en/latest/rpi/install_python3.html

Check link

$ ls -l /usr/bin | grep python

Modify link

# ln -snf TARGET LINK_NAME
$ sudo ln -snf /usr/bin/python3.7 /usr/bin/python3

If you end up using pip to install OpenCV on your Raspberry Pi, rest assured, you’re using the optimized version.

Install prerequisites on your Raspberry Pi

The Raspberry Pi requires that you install a few system packages before you get started:

$ sudo apt-get install libhdf5-dev libhdf5-serial-dev libhdf5-103
$ sudo apt-get install libqtgui4 libqtwebkit4 libqt4-test python3-pyqt5
$ sudo apt-get install libatlas-base-dev
$ sudo apt-get install libjasper-dev

Change Access Permissions

If following error (UNPROTECTED PRIVATE KEY) occurs,

$ git clone [email protected]:johnnymillergh/home_guardian.git -b develop
Cloning into 'home_guardian'...
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0644 for '/home/pi/.ssh/id_ed25519' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Load key "/home/pi/.ssh/id_ed25519": bad permissions
[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Fix the issue by following command,

# Fix file permission for GitHub SSH keypair
$ chmod 400 ~/.ssh/id_ed25519 ~/.ssh/id_ed25519.pub

WSL Ubuntu Initialization

These steps were validated on WSL2 Ubuntu. (Fri Sep 5 12:33:37 PM CST 2025)

                          ./+o+-       johnny@DL-PC-024
                  yyyyy- -yyyyyy+      OS: Ubuntu 22.04 jammy(on the Windows Subsystem for Linux)
               ://+//////-yyyyyyo      Kernel: x86_64 Linux 6.6.87.2-microsoft-standard-WSL2
           .++ .:/++++++/-.+sss/`      Uptime: 1h 39m
         .:++o:  /++++++++/:--:/-      Packages: 787
        o:+o+:++.`..```.-/oo+++++/     Shell: zsh 5.8.1
       .:+o:+o/.          `+sssoo+/    Resolution: 3000x1920
  .++/+:+oo+o:`             /sssooo.   WM: Weston WM
 /+++//+:`oo+o               /::--:.   GTK Theme: Adwaita [GTK3]
 \+/+o+++`o++o               ++////.   Disk: 630G / 1.8T (38%)
  .++.o+++oo+:`             /dddhhh.   CPU: 12th Gen Intel Core i5-12500 @ 12x 2.995GHz
       .+.o+oo:.          `oddhhhh+    RAM: 3521MiB / 15839MiB
        \+.++o+o``-````.:ohdhhhhh+
         `:o+++ `ohhhhhhhhyo++os:
           .o:`.syhhhhhhh/.oo++o`
               /osyyyyyyo++ooo+++/
                   ````` +oo+++o\:
                          `oo++.

Table of Contents

[TOC]

Docker Installation

Install Docker Engine on Ubuntu

  1. Set up Docker's apt repository.

    # Add Docker's official GPG key:
    $ sudo apt-get update
    $ sudo apt-get install ca-certificates curl
    $ sudo install -m 0755 -d /etc/apt/keyrings
    $ sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
    $ sudo chmod a+r /etc/apt/keyrings/docker.asc
    
    # Add the repository to Apt sources:
    $ echo \
      "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
      $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | \
      sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
    $ sudo apt-get update
  2. Install the Docker packages.

    $ sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
  3. Verify that the installation is successful by running the hello-world image.

    $ sudo docker run hello-world

To upgrade Docker Engine, follow step 2 of the installation instructions, choosing the new version you want to install.

Add current user to docker group

$ sudo gpasswd -a $USER docker

$ newgrp docker

Poitainer CE Installation

Portainer Official Docker Image

$ docker run \
  --name portainer \
  -p 8000:8000 \
  -p 9000:9000 \
  --restart "always" \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -v ~/docker-file-mapping/portainer-ce:/data \
  -d portainer/portainer-ce:2.15.1-alpine

ZSH + Oh My Zsh + Powerlevel10k

Install Zsh

Install zsh

$ sudo apt update && sudo apt upgrade -y
$ sudo apt install zsh -y

Set zsh as default

$ chsh -s $(which zsh)

Validate zsh

$ echo $0

Install On My Zsh

https://segmentfault.com/a/1190000040307253

# curl
$ sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

# wget
$ sh -c "$(wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"

Install Powerlevel10k

$ git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k

# gitee.com
$ git clone --depth=1 https://gitee.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k

Set oh-my-zsh theme

$ nano ~/.zshrc
ZSH_THEME="powerlevel10k/powerlevel10k"

Install font

# Download fontface into current directory
$ proxychains wget https://github.com/ryanoasis/nerd-fonts/raw/master/patched-fonts/Hack/Regular/HackNerdFontMono-Regular.ttf

# Copy to system font directory
$ sudo cp Hack\ Regular\ Nerd\ Font\ Complete.ttf /usr/share/fonts/truetype

Configure Oh My Zsh Plugins

Install plugins:

$ git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

$ git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

$ git clone https://github.com/Pilaton/OhMyZsh-full-autoupdate.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/ohmyzsh-full-autoupdate

$ git clone --depth 1 -- https://github.com/marlonrichert/zsh-autocomplete.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autocomplete

.zshrc example:

# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
  source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi

# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH

# Path to your oh-my-zsh installation.
export ZSH="$HOME/.oh-my-zsh"

# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
ZSH_THEME="powerlevel10k/powerlevel10k"

# Set list of themes to pick from when loading at random
# Setting this variable when ZSH_THEME=random will cause zsh to load
# a theme from this variable instead of looking in $ZSH/themes/
# If set to an empty array, this variable will have no effect.
# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )

# Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true"

# Uncomment the following line to use hyphen-insensitive completion.
# Case-sensitive completion must be off. _ and - will be interchangeable.
# HYPHEN_INSENSITIVE="true"

# Uncomment one of the following lines to change the auto-update behavior
# zstyle ':omz:update' mode disabled  # disable automatic updates
# zstyle ':omz:update' mode auto      # update automatically without asking
# zstyle ':omz:update' mode reminder  # just remind me to update when it's time

# Uncomment the following line to change how often to auto-update (in days).
# zstyle ':omz:update' frequency 13

# Uncomment the following line if pasting URLs and other text is messed up.
# DISABLE_MAGIC_FUNCTIONS="true"

# Uncomment the following line to disable colors in ls.
# DISABLE_LS_COLORS="true"

# Uncomment the following line to disable auto-setting terminal title.
# DISABLE_AUTO_TITLE="true"

# Uncomment the following line to enable command auto-correction.
# ENABLE_CORRECTION="true"

# Uncomment the following line to display red dots whilst waiting for completion.
# You can also set it to another string to have that shown instead of the default red dots.
# e.g. COMPLETION_WAITING_DOTS="%F{yellow}waiting...%f"
# Caution: this setting can cause issues with multiline prompts in zsh < 5.7.1 (see #5765)
# COMPLETION_WAITING_DOTS="true"

# Uncomment the following line if you want to disable marking untracked files
# under VCS as dirty. This makes repository status check for large repositories
# much, much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true"

# Uncomment the following line if you want to change the command execution time
# stamp shown in the history command output.
# You can set one of the optional three formats:
# "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# or set a custom format using the strftime function format specifications,
# see 'man strftime' for details.
HIST_STAMPS="yyyy-mm-dd"

# Would you like to use another custom folder than $ZSH/custom?
# ZSH_CUSTOM=/path/to/new-custom-folder

# Which plugins would you like to load?
# Standard plugins can be found in $ZSH/plugins/
# Custom plugins may be added to $ZSH_CUSTOM/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(
git
history
common-aliases
zsh-autocomplete
zsh-autosuggestions
zsh-syntax-highlighting
ohmyzsh-full-autoupdate
)

source $ZSH/oh-my-zsh.sh

# User configuration

# export MANPATH="/usr/local/man:$MANPATH"

# You may need to manually set your language environment
# export LANG=en_US.UTF-8

# Preferred editor for local and remote sessions
# if [[ -n $SSH_CONNECTION ]]; then
#   export EDITOR='vim'
# else
#   export EDITOR='mvim'
# fi

# Compilation flags
# export ARCHFLAGS="-arch x86_64"

# Set personal aliases, overriding those provided by oh-my-zsh libs,
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
# For a full list of active aliases, run `alias`.
#
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"

# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh

# Configuration for WSL using v2rayN proxy
#export host_ip=$(ip route | grep default | awk '{print $3}')
#export socks_port=10808
#export http_port=10809
#export HTTPS_PROXY="https://${host_ip}:${http_port}";
#export HTTP_PROXY="http://${host_ip}:${http_port}";
#export ALL_PROXY="socks5://${host_ip}:${socks_port}";

alias pycharm-ubuntu="~/ProgramFiles/pycharm/bin/pycharm"

# Created by `pipx` on 2025-08-22 08:18:55
export PATH="$PATH:/home/johnny/.local/bin"

Check link

$ ls -l /usr/bin | grep python

Modify link

# ln -snf TARGET LINK_NAME
$ sudo ln -snf /usr/bin/python3.7 /usr/bin/python3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment