Raspberry Pi 4B Ubuntu 22.04 Desktop
家里缺一台 Linux 环境的桌面电脑,用树莓派跑一下 Ubuntu 桌面系统,效果还可以(毕竟4核4G)。
步骤简要记录一下:
镜像下载
https://ubuntu.com/download/raspberry-pi
镜像解压
# zsh, 使能 extract 插件
extract ubuntu-22.04.1-preinstalled-desktop-arm64+raspi.img.xz
镜像烧录
可以使用 rpi-imager 替代,这里采用了个人比较熟悉的方式。
sudo dd if=ubuntu-22.04.1-preinstalled-desktop-arm64+raspi.img of=/dev/mmcblk0 bs=200M; sudo sync; sudo sync; sudo sync;
初次启动
- 插卡到树莓派上,连接键盘、鼠标显示器,上电
- 根据指引进行初始配置,设置用户名、密码、键盘布局、配置 WIFI 等
- 建议选择英文环境
- 整个初始化配置的过程大概 5 - 10 分钟
- 开机后 SD 卡容量自动扩展
更新
sudo apt update
sudo apt upgrade
一些个性化设置
sudo 免输入密码
# 注意将 USERNAME 替换成实际用户名
sudo su
cat << 'EOF' > /etc/sudoers.d/USERNAME
USERNAME ALL=(ALL) NOPASSWD:ALL
EOF
proxy
sudo apt install shadowsocks-libev privoxy
wget https://github.com/shadowsocks/v2ray-plugin/releases/download/v1.3.2/v2ray-plugin-linux-arm64-v1.3.2.tar.gz
tar xzf v2ray-plugin-linux-arm64-v1.3.2.tar.gz
sudo mv v2ray-plugin-linux-arm64 /usr/local/bin/v2ray-plugin
# ss 按需增加配置到 /etc/shadowsocks-libev
sudo systemctl enable --now shadowsocks-libev-local@someconfig
# privoxy /etc/privoxy/config 找到 forward-socks5t 按需修改
forward-socks5t / 127.0.0.1:1080 .
apt proxy,走 privoxy 8118 端口,加速
sudo su
cat << 'EOF' > /etc/apt/apt.conf.d/proxy.conf
Acquire {
HTTP::proxy "http://127.0.0.1:8118";
HTTPS::proxy "http://127.0.0.1:8118";
}
EOF
sshd
sudo apt install openssh-server
- 配置 ~/.ssh/authorized_keys
- 禁能密码登陆
PasswordAuthentication no
- 禁止 root 用户登陆
PermitRootLogin no
oh-my-zsh
sudo apt install curl zsh git
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
# Set `ZSH_THEME="powerlevel10k/powerlevel10k"` in `~/.zshrc`
# 增加一个 `~/.zprofile` 文件,解决 `~/.profile` 不加载问题
cat << 'EOF' > ~/.zprofile
emulate sh
. ~/.profile
emulate zsh
EOF
# 使能 zsh
chsh -s $(which zsh)
p10k configure
openocd-rules
使得普通用户也可以操作 usb 设备
wget https://raw.githubusercontent.com/arduino/OpenOCD/master/contrib/60-openocd.rules
sudo cp 60-openocd.rules /etc/udev/rules.d/60-openocd.rules
sudo udevadm control --reload
Sublime Text 4
https://www.sublimetext.com/download_thanks?target=arm-deb
wget https://download.sublimetext.com/sublime-text_build-4143_arm64.deb
dpkg -i sublime-text_build-4143_arm64.deb
VSCode
https://code.visualstudio.com/download#
wget https://az764295.vo.msecnd.net/stable/e8a3071ea4344d9d48ef8a4df2c097372b0c5161/code_1.74.2-1671532382_arm64.deb
dpkg -i code_1.74.2-1671532382_arm64.deb
python3-pip
sudo apt instal python3-pip