更新apt源
# 切换阿里镜像源
cat <<EOF > /etc/apt/sources.list
deb https://mirrors.aliyun.com/ubuntu/ noble main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ noble main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ noble-security main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ noble-security main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ noble-updates main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ noble-updates main restricted universe multiverse
# deb https://mirrors.aliyun.com/ubuntu/ noble-proposed main restricted universe multiverse
# deb-src https://mirrors.aliyun.com/ubuntu/ noble-proposed main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ noble-backports main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ noble-backports main restricted universe multiverse
EOF
# 进行更全面的升级,可能会删除一些不再需要的软件包,以解决软件包之间的依赖关系冲突。
apt dist-upgrade
# 自动删除那些现在不再被任何已安装软件包所依赖的软件包。
apt autoremove
# 清理掉那些已经不能从软件源中下载的过时软件包文件。
apt autoclean
设置静态ip
cat <<EOF > /etc/netplan/50-cloud-init.yaml
network:
version: 2
ethernets:
enp0s3:
dhcp4: false
addresses:
- 192.12.0.10/24
routes:
- to: default
via: 192.12.0.1
nameservers:
addresses: [192.12.0.1]
EOF
# 使配置生效
netplan apply
# 禁用ipv6
cat <<EOF >> /etc/sysctl.conf
net.ipv6.conf.all.disable_ipv6=1
net.ipv6.conf.default.disable_ipv6=1
net.ipv6.conf.lo.disable_ipv6=1
EOF
# 使配置生效
sysctl -p
设置默认启动
# 设置默认启动到文本模式
systemctl set-default multi-user.target
# 设置默认启动到图形界面
systemctl set-default graphical.target
# 为了优化启动时间,我们这里将默认启动设置为文本模式,也就是平常使用的终端模式
关闭snap更新
# 暂停所有snap服务更新
snap refresh --hold
# ansp应用在 24 小时内不检查更新
snap refresh --hold=24h
# 恢复所有应用的自动更新
snap refresh --unhold