1. 圖形界面 (桌面版)
如果你刷的是 Ubuntu Desktop 24.04:
-
打開 Software & Updates(軟件和更新)。
-
在 Ubuntu Software 標簽里找到 Download from 下拉菜單。
-
默認只有 Main server 和 Server for China,如果想要更多選擇:
sudo apt install software-properties-gtk
安裝后再打開 → 選擇 Other… → Select Best Server 或手動挑鏡像站。
-
關閉后點 Reload,等價于執行
sudo apt update
。
2. 命令行方式 (推薦,最穩定)
直接修改源列表文件:
sudo nano /etc/apt/sources.list
替換為 清華源 (TUNA):
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ noble main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ noble-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ noble-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ noble-security main restricted universe multiverse
替換為 阿里源:
deb http://mirrors.aliyun.com/ubuntu/ noble main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ noble-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ noble-backports main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ noble-security main restricted universe multiverse
替換為 官方源:
deb http://archive.ubuntu.com/ubuntu/ noble main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ noble-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ noble-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu/ noble-security main restricted universe multiverse
保存退出,然后:
sudo apt clean
sudo apt update
3. 自動化腳本 (一鍵換源)
如果想開機后馬上自動換成國內源,可以寫 systemd 腳本。
- 創建腳本:
sudo nano /usr/local/bin/change-sources.sh
內容:
#!/bin/bash
SOURCE_FILE="/etc/apt/sources.list"
cat > $SOURCE_FILE <<EOF
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ noble main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ noble-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ noble-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ noble-security main restricted universe multiverse
EOFapt clean
apt update
- 給權限:
sudo chmod +x /usr/local/bin/change-sources.sh
- 創建 systemd 服務:
sudo nano /etc/systemd/system/change-sources.service
內容:
[Unit]
Description=Change APT sources to TUNA mirror at boot
After=network-online.target
Wants=network-online.target[Service]
Type=oneshot
ExecStart=/usr/local/bin/change-sources.sh[Install]
WantedBy=multi-user.target
- 啟用:
sudo systemctl daemon-reload
sudo systemctl enable change-sources.service
這樣以后 每次開機都會自動把源改好并更新。
? 總結:
- 桌面用戶:可以用 Software & Updates GUI 改源。
- 推薦方法:直接手動改
/etc/apt/sources.list
,換成清華/阿里/中科大鏡像。 - 完全自動化:寫 systemd 腳本,開機時自動換源 +
apt update
。
在樹莓派(Raspberry Pi OS 或 Ubuntu 24.04 for Raspberry Pi)上使能 SSH 有兩種常見辦法:
🔌 方法一:無顯示器(Headless 模式,推薦)
-
把系統鏡像寫入 TF/SD 卡后,不要直接插樹莓派,先把 SD 卡插回電腦。
-
打開 boot 分區(Windows 下會自動顯示為一個盤符)。
-
在
boot
根目錄里,新建一個名為ssh
的空文件(沒有擴展名)。-
Windows:右鍵新建 → 文本文檔 → 命名為
ssh
→ 刪除.txt
。 -
Linux/macOS:
cd /media/$USER/boot touch ssh
-
-
把 SD 卡插回樹莓派并啟動,SSH 服務會自動啟用。
-
在同一局域網電腦上,用下面命令登錄:
ssh ubuntu@raspberrypi.local # 或者用樹莓派的 IP 地址 ssh ubuntu@192.168.x.x
Ubuntu 默認用戶名是
ubuntu
,密碼是ubuntu
(首次登錄會要求你修改密碼)。
Raspberry Pi OS 默認用戶名是pi
,密碼是raspberry
。
🖥? 方法二:有顯示器和鍵盤時
-
開機后進入系統。
-
運行配置工具:
-
Raspberry Pi OS:
sudo raspi-config
進入
Interface Options → SSH → Enable
。 -
Ubuntu (24.04):
先安裝 OpenSSH:sudo apt update sudo apt install openssh-server -y
然后啟用服務:
sudo systemctl enable ssh sudo systemctl start ssh sudo systemctl status ssh
顯示
active (running)
就成功了。
-
🧪 測試
在另一臺電腦上執行:
ssh 用戶名@樹莓派_IP
例如:
ssh ubuntu@192.168.1.100
? 總結:
- 沒顯示器 → 在
boot
分區新建ssh
文件。 - 有顯示器 → 安裝
openssh-server
并用systemctl enable/start ssh
。