Ubuntu系统如何配置apt远程源

  • 查看Unbuntu版本和Codename:

    复制代码
    qv123@localhost:~$ lsb_release -a
    No LSB modules are available.
    Distributor ID: Ubuntu
    Description:    Ubuntu 22.04.3 LTS
    Release:    22.04
    Codename:   jammy              # 不同的版本apt源语句中就换不同的关键字
  • 备份文件:

    复制代码
    cp /etc/apt/sources.list /opt/sources.list.bak
  • 编辑 /etc/apt/sources.list 文件:(root用户才可以使用哦eof)

    复制代码
    # Unbuntu20.4版本,20.4版本在安装的时候指定好Mirrors addresses再重启网络并且执行sudo apt-get clean && sudo apt-get upgrade && sudo apt-get update命令就可以正常使用apt命令,不必再配置yum源
    #添加阿里源
    cat << eof > /etc/apt/sources.list
    deb http://mirrors.aliyun.com/ubuntu focal main restricted
    deb http://mirrors.aliyun.com/ubuntu focal-updates main restricted
    deb http://mirrors.aliyun.com/ubuntu focal universe
    deb http://mirrors.aliyun.com/ubuntu focal-updates universe
    deb http://mirrors.aliyun.com/ubuntu focal multiverse
    deb http://mirrors.aliyun.com/ubuntu focal-updates multiverse
    deb http://mirrors.aliyun.com/ubuntu focal-backports main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu focal-security main restricted
    deb http://mirrors.aliyun.com/ubuntu focal-security universe
    deb http://mirrors.aliyun.com/ubuntu focal-security multiverse
    eof
    
    # Unbuntu22.4版,22.4版本在安装的时候指定好Mirrors addresses再重启网络并且执行sudo apt-get clean && sudo apt-get upgrade && sudo apt-get update命令就可以正常使用apt命令,不必再配置yum源
    #添加阿里源
    cat << eof > /etc/apt/sources.list
    deb http://mirrors.aliyun.com/ubuntu jammy main restricted
    deb http://mirrors.aliyun.com/ubuntu jammy-updates main restricted
    deb http://mirrors.aliyun.com/ubuntu jammy universe
    deb http://mirrors.aliyun.com/ubuntu jammy-updates universe
    deb http://mirrors.aliyun.com/ubuntu jammy multiverse
    deb http://mirrors.aliyun.com/ubuntu jammy-updates multiverse
    deb http://mirrors.aliyun.com/ubuntu jammy-backports main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu jammy-security main restricted
    deb http://mirrors.aliyun.com/ubuntu jammy-security universe
    deb http://mirrors.aliyun.com/ubuntu jammy-security multiverse
    eof
  • 重启网络:

    复制代码
    sudo systemctl restart systemd-networkd
  • 更新软件包列表:在终端中运行以下命令以使更改生效:

    复制代码
    sudo apt-get clean && sudo apt-get upgrade && sudo apt-get update
  • 测试:

    复制代码
    sudo apt install -y nginx
相关推荐
MicrosoftCloud15 小时前
性能排查 01|free 显示内存用了 90% 就是快满了吗?buff/cache 与 available 一次讲清
linux·运维·内存·free·buff/cache
灯澜忆梦15 小时前
【docker】#1 | Docker 初识
运维·docker·容器
风寄巴山秋15 小时前
OpenBMC:Web 页面功能异常排查
运维·服务器·前端·架构
xiaoye-duck15 小时前
《Linux 网络编程》深入理解 epoll(下):epoll 实战开发与 LT/ET 触发模式深度剖析
linux·网络
成为你的宁宁16 小时前
【Ubuntu 18.04安装Gitlab】
ubuntu·gitlab
小白的码BUG之路16 小时前
Jenkins -- 连接gitee
运维·gitee·jenkins
峥无16 小时前
Linux线程深度剖析:轻量级进程、虚拟内存分页、进程线程资源对比
linux·运维·mmap
骑着蜗牛撵大象32716 小时前
穿越 Docker 内核迷雾:镜像分层的叠加态与卷挂载的空间穿梭
运维·docker·容器·联合文件系统·卷挂载·镜像分层·存储驱动
honsor16 小时前
以太网温湿度传感器:RJ45直连机房的环境监控新方案
运维·网络·数据库·物联网·安全·云计算·github
zxcvb15316 小时前
规定备份信息的备份方式:从策略制定到自动化落地的实践思考
运维·oracle·自动化