ubuntu一键换源脚本
时间: 2023-11-03 10:59:44 浏览: 138
这里提供一个方便使用的Ubuntu一键换源脚本:
```shell
#!/bin/bash
# 备份原来的源列表文件
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
# 选择一个合适的国内源,比如清华大学源
sudo echo "deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ $(lsb_release -cs) main restricted universe multiverse" > /etc/apt/sources.list
sudo echo "deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ $(lsb_release -cs)-updates main restricted universe multiverse" >> /etc/apt/sources.list
sudo echo "deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ $(lsb_release -cs)-backports main restricted universe multiverse" >> /etc/apt/sources.list
sudo echo "deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ $(lsb_release -cs)-security main restricted universe multiverse" >> /etc/apt/sources.list
# 更新软件列表
sudo apt-get update
# 更新软件包
sudo apt-get upgrade -y
```
阅读全文