当前位置: 首页 > news >正文

linux操作系统 包管理工具 包括国产操作系统

各系统的包管理工具介绍

现阶段多种操作系统、多种不同版本,相继有好几个包管理工具,就RHEL/Centos就有rpm、yum、dnf三种,Ubuntu有dpdk、apt、apt-get等,还有一些跨发行版本,以及通用软件管理方式pip、pip3,除了这些常见的操作系统,国产操作系统又用到了哪些包管理工具呢。

openouler系统是基于RHEL/CentOS生态构建,从openEuler20.03LTS开始版本开始默认使用dnf工具,取代老版本的yum软件管理工具。

银河麒麟kylinos因版本不同,所用的包管理工具也不同,如果是桌面版本的操作系统,大多是基于ubuntu系统开发,因此延用dpdk和apt等工具;如果是服务器版本的操作系统,是基于CentOS/openEuler技术开发,包管理工具使用yum、dnf等

中标麒麟neokylin是早期版本基于CentOS/openEuler开发,随着centos的停更,新版本逐渐转向openouler系统开发,如v7/v10版本,这些都已经默认使用dnf。

那这么多操作系统,不同发现版使用的包管理工具也不同。但是系统都有默认的包管理工具,并且都是linux操作系统,通过命令查看确认使用的是rpm系还是Deb系。

#查询系统版本的路径基本都差不多 ls /etc/*release #看看有哪些文件,基本都显示系统版本,os-release显示的更详细 cat /etc/os-release #ID="kylin" + VERSION_ID="V10" + UBUNTU_CODENAME=... → 是 Ubuntu 基础 → 用 apt #ID="kylin" + VERSION_ID="V10" + PLATFORM_ID="platform:el8" 或类似 RHEL 字样 → 是 RPM 基础 → 用 yum/dnf #或者查询默认有没有api或者rpm判断 which apt && echo "使用 apt (Deb系)" || echo "可能不是 Deb 系" which rpm && echo "使用 rpm (RPM系)" || echo "可能不是 RPM 系"

按照这中方式确定系统是用那中包管理工具。

Ubuntu/Dabian Deb系

sudo apt update sudo apt install nginx sudo dpkg -i package.deb #不推荐,不自动解决依赖。

RHEL/CentOS RPM系

# CentOS 7 sudo yum install httpd # CentOS 8+/Rocky Linux sudo dnf install httpd # 直接安装 RPM(不推荐,除非你知道依赖已满足) sudo rpm -ivh package.rpm

国产信创系统就看是基于哪种操作系统研发的,一般常规也就分deb系和rpm系。

python pip

除了上述操作系统默认的包管理工具以外,还有各种通用的软件管理工具,也可以在linux系统中使用。这里介绍python脚本语言常用的模块安装工具pip/pip3,新版的ansible服务也可以通过pip3安装。

包管理工具的基本使用

RHEL/CentOS RPM系

常用yum和dnf,yum和dnf的使用基本一致,常用的yum方式和dnf没区别。dnf可从epel源中安装。rpm工具无法解析依赖,不常用。

dnf安装依赖包比yum解析依赖更快、更精准,支持多版本和模块化管理。

全局配置文件/etc/yum.conf在dnf中仍然适用,.repo文件无需修改。

dnf默认是/etc/dnf/dnf.conf。

Deb系Linux发行版

Deb系Linux发行版(如Debian、Ubuntu、Linux Mint、Kylin桌面版 等)中,软件包以.deb 格式分发,主要使用两类包管理工具,dbk和apt-get ,dbkg不解决依赖关系,apt是apt-get的简化版本,能够解析.deb包的依赖关系并完成安装。

全局配置文件:/etc/apt/apt.conf,一般没有这个文件,常规配置是在/etc/apt.conf.d/目录下。通过apt-config dump可查看当前配置参数。

软件源列表配置文件:/etc/apt/sources.list

扩展源列表文件:/etc/apt/sources.list.d/

配置国内软件源

配置yum软件源

目前国产化替代的浪潮中,建议国内软件源加速器使用华为,华为在推进国产化替代中,有着无可替代的作用和决心,是完全可以信赖的公司。当前目前支持最好的还是阿里云,后续配置推荐阿里云软件源。

仓库文件目录: /etc/yum.repo.d/

mkdir -p /etc/yum.repos.d.bak mv /etc/yum.repos.d/*.repo /etc/yum.repos.d.bak/ #华为云软件源 https://mirrors.huaweicloud.com/home #阿里云软件源 https://developer.aliyun.com/mirror #centos7 wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo yum clean all && yum makecache #centos8 wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo yum clean all && yum makecache

也可以自动切换当前默认的配置为国内软件源

codename=$(lsb_release -cs) sudo sed -i "s|http://[a-z0-9\.]*\.archive\.ubuntu\.com|https://mirrors.aliyun.com|g" /etc/apt/sources.list sudo apt update

清理并重新加载缓存

dnf clean all #或者yum clean all dnf makecache #或者yum makecache

验证

yum repolist dnf repolist

配置apt软件源

仓库文件目录:/etc/apt/sources.list,配置国内apt软件源,用阿里云。

#先备份 sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak #编辑/etc/sources.list sudo tee /etc/apt/sources.list <<'EOF' deb https://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse deb https://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse deb https://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse deb https://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse deb-src https://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse deb-src https://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse deb-src https://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse deb-src https://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse EOF #更新软件源 sudo apt update #验证测试 apt policy

其他操作系统对应软件源可从阿里云官网查看:

ubuntu国内软件源列表

ubuntu每年都跟新一个稳定版,不同版本的软件源路径如下,

Ubuntu 18.04版本

deb https://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse deb-src https://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse deb https://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse deb-src https://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse deb https://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse deb-src https://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse # deb https://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse # deb-src https://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse deb https://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse deb-src https://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

Ubuntu 20.04版本

deb https://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse deb-src https://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse deb https://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse deb-src https://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse deb https://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse deb-src https://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse # deb https://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse # deb-src https://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse deb https://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse deb-src https://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse

Ubuntu 22.04版本

deb https://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse deb-src https://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse deb https://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse deb-src https://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse deb https://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse deb-src https://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse # deb https://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse # deb-src https://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse deb https://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse deb-src https://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse

最新系统Ubuntu 2404

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

往期推荐:来自于个人公众号发布路途-在路上博客

部署局域网内部yum服务器

局域网内部配置ubuntu apt本地软件源

http://www.jsqmd.com/news/93456/

相关文章:

  • 2025年工业阀门品牌年度排名:开维喜阀门厂售后服务体系哪家 - 工业品牌热点
  • 毕设分享 stm32 wifi远程可视化与农业灌溉系统(源码+硬件+论文)
  • LeetCode 分类刷题:100. 相同的树
  • C# 串口调试助手
  • AutoGPT镜像上线促销:限时赠送免费Token额度
  • 18、GTK+开发全面指南
  • 2025气体探测器厂家实力排行榜:东莞领军企业以智能传感技术领跑,七类高危气体检测设备深度解析 - 品牌企业推荐师(官方)
  • AutoGPT任务规划算法拆解:从目标到子任务的生成逻辑
  • Selenium自动化测试:如何搭建自动化测试环境,搭建环境过程应该注意的问题?
  • 2025年B2B投放KPI指南:SEO+SEM整合营销与社媒营销的ROI与转化追踪
  • LobeChat能否实现对话置顶?重要会话管理技巧
  • 22、DB2 应用开发入门指南
  • AutoGPT错误日志分析技巧:快速定位问题根源
  • Qwen3-14B支持Function Calling,打通业务系统壁垒
  • 基于28DR+VU13P的宽带高速信号处理板
  • 我发现WebAssembly流处理图像内存涨,后来才知道用SharedArrayBuffer零拷贝解决
  • 5分钟教你轻松搭建Web自动化测试框架
  • Qwen3-14B商用级大模型实战:基于Dify部署智能客服系统
  • 大模型压缩技术全解析:从剪枝到量化,程序员必学收藏指南
  • 2025 英国留学机构十大推荐(附核心战绩与特色) - 品牌推荐排行榜
  • LobeChat是否支持Subresource Integrity?前端资源完整性校验
  • 从入门到高薪:零基础开启网络安全职业的11条路径与薪资图谱
  • 2025 年 12 月复印机租赁服务权威推荐榜:彩色/高速/多功能/便携式/激光办公设备,灵活高效办公解决方案精选 - 品牌企业推荐师(官方)
  • 0基础转网安:从考证、实战到拿下第一份offer的完整指南
  • 【必藏】AI时代,大多数人不需要拼天赋,只需掌握大模型技术!
  • “网络安全学什么?” 零基础小白入门宝典:核心知识+实战资源一网打尽
  • Linux swap分区设置对Qwen3-32B内存溢出的影响
  • AI大模型怎么学?程序员新手收藏这篇就够了
  • 毕设分享 深度学习遮挡下的人脸识别(源码+论文)
  • vLLM镜像实测:连续批处理让Qwen推理效率翻倍