Ubuntu
web | des |
---|---|
iso官方下载,ubuntu 中国,各种镜像 | |
docs,office docs | Ubuntu服务器入门指南 |
sh
# 列出可更新
apt list --upgradable
# 更新
apt upgrade -y
源文件
/etc/apt/sources.list
提供不同类型的源
文件中能够配置不同类型的软件源,主要包含以下几种:
- 主服务器(Main):包含由 Ubuntu 官方维护和支持的自由、开源软件包,这些软件包经过了严格的测试和质量保证。
- 受限(Restricted):包含一些受版权限制的软件包,通常是硬件驱动程序等,这些软件包虽然受版权限制,但对于某些硬件的正常使用是必需的。
- 宇宙(Universe):由社区维护的自由、开源软件包,涵盖了更广泛的软件种类,但官方的支持和测试相对较少。
- 多宇宙(Multiverse):包含一些受版权或法律限制的软件包,这些软件包可能涉及专利、许可证等问题。
阿里云源
sh
# amd64 22.04
sed -e 's|cn.archive.ubuntu.com/ubuntu|mirrors.aliyun.com|g' -i.bak /etc/apt/sources.list
# arm64 22.4
sed -e 's|ports.ubuntu.com|mirrors.aliyun.com|g' -i.bak /etc/apt/sources.list
sh
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://mirrors.aliyun.com/ubuntu/ jammy main restricted
# deb-src http://mirrors.aliyun.com/ubuntu/ jammy main restricted
## Major bug fix updates produced after the final release of the
## distribution.
deb http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted
# deb-src http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://mirrors.aliyun.com/ubuntu/ jammy universe
# deb-src http://mirrors.aliyun.com/ubuntu/ jammy universe
deb http://mirrors.aliyun.com/ubuntu/ jammy-updates universe
# deb-src http://mirrors.aliyun.com/ubuntu/ jammy-updates universe
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://mirrors.aliyun.com/ubuntu/ jammy multiverse
# deb-src http://mirrors.aliyun.com/ubuntu/ jammy multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-updates multiverse
# deb-src http://mirrors.aliyun.com/ubuntu/ jammy-updates multiverse
## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse
# deb-src http://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu/ jammy-security main restricted
# deb-src http://security.ubuntu.com/ubuntu/ jammy-security main restricted
deb http://security.ubuntu.com/ubuntu/ jammy-security universe
# deb-src http://security.ubuntu.com/ubuntu/ jammy-security universe
deb http://security.ubuntu.com/ubuntu/ jammy-security multiverse
# deb-src http://security.ubuntu.com/ubuntu/ jammy-security multiverse
网络设置
vim /etc/netplan/01-netcfg.yaml
sh
network:
version: 2
renderer: networkd
ethernets:
enp0s3:
dhcp4: true #随机网址
enp0s8:
dhcp4: false
addresses:
- 192.168.10.100/24 # 固定网址
enp0s9:
dhcp4: false
addresses:
- 192.168.20.60/24 # IP + 子网掩码
routes:
- to: default
via: 192.168.20.1 # 网关
nameservers:
addresses: [8.8.8.8, 1.1.1.1] # DNS 服务器(可选)
重启网络
sh
sudo systemctl restart systemd-networkd
# 如果你使用的是 NetworkManager
sudo systemctl restart NetworkManager
# 或者
sudo netplan try # 测试配置(确认后自动应用,超时回滚)
sudo netplan apply # 立即生效
允许root远程登录
sh
# 设置 root 用户密码
# Ubuntu 默认禁用 root 账户,需先为其设置密码:
# 输入两次密码后完成设置,可通过 su - root 验证切换是否成功。
sudo passwd root
# 编辑 /etc/ssh/sshd_config 文件:
sudo nano /etc/ssh/sshd_config
#找到
#PermitRootLogin prohibit-password
# prohibit-password:允许root用户登录,但禁止使用密码认证(仅允许密钥认证或其它非密码方式)
# yes:允许root用户登录,且不限制认证方式(密码、密钥等均可)。
# no:完全禁止root登录(最安全,但需通过普通用户切换)。
# without-password:同 prohibit-password(旧版别名)。
# forced-commands-only:仅允许root执行预定义命令(用于自动化任务)。
PermitRootLogin prohibit-password
PermitRootLogin yes
# 若需密码登录(非推荐),取消注释并设置,注意提前给root设置密码
PasswordAuthentication yes
systemctl restart sshd
arm芯片安装
镜像推荐
在安装的时候需要配置
镜像站 | 地址 | 备注 |
---|---|---|
清华 TUNA | https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ | 国内高速 |
阿里云 | https://mirrors.aliyun.com/ubuntu-ports/ | 企业级稳定性 |
官方国际源 | http://ports.ubuntu.com/ubuntu-ports/ | 无国内加速 |
使用方法
(1) 修改 sources.list
(ARM 设备)
备份原有配置:
shsudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
编辑软件源文件:
shsudo nano /etc/apt/sources.list
替换为以下内容(以 Ubuntu 24.04 LTS ARM64 为例):
shdeb http://cn.ports.ubuntu.com/ubuntu-ports/ noble main restricted universe multiverse deb http://cn.ports.ubuntu.com/ubuntu-ports/ nobles-updates main restricted universe multiverse deb http://cn.ports.ubuntu.com/ubuntu-ports/ noble-backports main restricted universe multiverse deb http://cn.ports.ubuntu.com/ubuntu-ports/ noble-security main restricted universe multiverse
更新软件包列表:
shsudo apt update