安装版本
- 镜像下载地址 https://ubuntu.com/download/raspberry-pi
ubuntu-20.04.1-preinstalled-server-arm64+raspi
- 下载后的文件名
ubuntu-20.04.1-preinstalled-server-arm64+raspi.img.xz
- 解压
ubuntu-20.04.1-preinstalled-server-arm64+raspi.img.xz
变为ubuntu-20.04.1-preinstalled-server-arm64+raspi.img
安装ubuntu系统
查看地址
diskutil list
格式化u盘
diskutil partitionDisk <地址> MBR FAT32 UNTITLED 0b
- 例子
diskutil partitionDisk /dev/disk2 MBR FAT32 UNTITLED 0b
卸载
diskutil unmountDisk <地址>
- 例子
diskutil unmountDisk /dev/disk2
烧录
sudo dd bs=4m if=<镜像地址> of=<地址>
# 等待几分钟
- 例子
sudo dd bs=4m if=/Downloads/ubuntu-20.04.1-preinstalled-server-arm64+raspi.img of=/dev/disk2
启动ssh
- 烧录好的u盘 创建名为
ssh
无后缀的文件 放入u盘中
连接ssh
ssh ubuntu@ip
- 密码
ubuntu
设置root密码
sudo passwd root
切换root
su root
修改源
树莓派 本镜像仅包含 arm64 armhf ppc64el riscv64 s390x 架构的软件包
修改源
nano /etc/apt/sources.list
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ focal main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ focal main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ focal-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ focal-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ focal-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ focal-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ focal-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ focal-security main restricted universe multiverse
# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ focal-proposed main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ focal-proposed main restricted universe multiverse
更新
sudo apt-get update
sudo apt-get upgraded
Java环境
root@ubuntu:/# java
Command 'java' not found, but can be installed with:
apt install openjdk-11-jre-headless # version 11.0.8+10-0ubuntu1~20.04, or
apt install default-jre # version 2:1.11-72
apt install openjdk-8-jre-headless # version 8u265-b01-0ubuntu2~20.04
apt install openjdk-13-jre-headless # version 13.0.3+3-1ubuntu2
apt install openjdk-14-jre-headless # version 14.0.1+7-1ubuntu1
安装 选择
apt install openjdk-8-jre-headless
错误提示
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
libfreetype6 : Depends: libpng12-0 (>= 1.2.13-4) but it is not installable
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
- 解决方式
apt --fix-broken install
安装防火墙
sudo apt-get install ufw
- 启动
sudo ufw enable
系统启动时自动开启sudo ufw default deny
- 状态
sudo ufw status
- 开端口
sudo ufw allow 22