UbuntuServer24.04设置国内镜像软件源-最小化安装没有vim指令
简介
最小化安装完,因为官网的更新源不稳定,不能执行更新及安装命令,
0. sudo apt update 一直报连不上。
- 服务器版最小化安装,不能界面操作
- 最小化安装没有vim命令,不能直接修改ubuntu.sources
- 最小化安装也没有nano,gedit一类的命令
- 还好有echo,touch指令可以使用
新的改变
sources.list 文件由原来的 /etc/apt/ 目录更改到了 /etc/apt/sources.list.d/ 目录中的 ubuntu.sources文件
备份原始的ubuntu.sources文件(可选)
cd /etc/apt/sources.list.d/
# 备份一下,或用mv命令也可
sudo cp ubuntu.sources ubuntu.sources.bak
新增国内源的ubuntu.sources文件
# 先找个方便的目录进行操作
cd ~
# 第一句和后面的略有不同,下面的这个新文件直接写
echo "#清华源" > ubuntu.sources
# 从这句开始是追加新的行到原来就存在的文件中
echo "Enabled: yes" >> ubuntu.sources
echo "Types: deb" >> ubuntu.sources
echo "URIs: http://mirrors.tuna.tsinghua.edu.cn/ubuntu/" >> ubuntu.sources
echo "Suites: noble noble-updates noble-security" >> ubuntu.sources
echo "Components: main restricted universe multiverse" >> ubuntu.sources
echo "Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg" >> ubuntu.sources
# 将生成好的文件复制到指定的目录下
sudo cp ubuntu.sources /etc/apt/sources.list.d/
更新并安装软件
# 更新源
sudo apt update
# 先安装vim命令,方便后续修改文件
sudo apt install vim
# 更新系统(可选)
sudo apt upgrade
# 安装其他软件
其他源
更新上述ubuntu.sources中的指定部分即可
#腾讯源
URIs: http://mirrors.tencent.com/ubuntu/
#清华源
URIs: http://mirrors.tuna.tsinghua.edu.cn/ubuntu/
#阿里源
URIs: http://mirrors.aliyun.com/ubuntu/
设置东八区:
sudo timedatectl set-timezone Asia/Shanghai
通过 timedatectl 命令来验证:
timedatectl