news 2026/4/18 7:05:05

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

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
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本地软件源

版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/4/17 21:35:33

鸿蒙 Electron 与元宇宙融合实战:跨端沉浸式虚拟交互解决方案

鸿蒙Electron与元宇宙融合实战&#xff1a;跨端沉浸式虚拟交互解决方案 元宇宙通过构建与物理世界平行的虚拟空间&#xff0c;实现“沉浸式体验-虚拟协同-虚实联动”的全新交互模式&#xff0c;而鸿蒙Electron凭借跨端协同、端侧实时计算、多设备适配能力&#xff0c;成为元宇…

作者头像 李华
网站建设 2026/4/18 3:24:58

计算机毕业设计springboot基于web的自定义预约系统 基于SpringBoot的Web端灵活预约平台设计与实现 融合SpringBoot的在线可配置预约服务系统开发

计算机毕业设计springboot基于web的自定义预约系统a51diz58 &#xff08;配套有源码 程序 mysql数据库 论文&#xff09; 本套源码可以在文本联xi,先看具体系统功能演示视频领取&#xff0c;可分享源码参考。移动互联网把“随时办”变成常态&#xff0c;却仍面临“排队久、改约…

作者头像 李华
网站建设 2026/4/18 3:25:29

20万以内新能源SUV主动安全系统排行榜:实测满载跑高速,纯电动车型刹车与车道保持表现

随着新能源技术不断进化&#xff0c;20 万元以内的纯电 SUV 市场已经从单纯追求续航和性价比&#xff0c;转向对主动安全系统表现的深度考量。对于日常高速满载出行来说&#xff0c;刹车响应、车道保持稳定性、自适应巡航系统表现等主动安全功能&#xff0c;直接关系到行驶安全…

作者头像 李华
网站建设 2026/4/18 3:24:25

21、Python开发DB2应用程序全攻略

Python开发DB2应用程序全攻略 在Python开发中,与DB2数据库进行交互是一项常见的任务。为了实现高效、便捷的交互,我们可以使用 ibm_db 驱动,它能提供出色的性能和丰富的功能支持。下面将详细介绍如何使用 ibm_db 驱动进行DB2数据库的连接、数据操作等。 1. 环境准备 在…

作者头像 李华
网站建设 2026/4/18 3:25:52

我发现流式处理日志内存涨 后来才知道用流式分片并行解析

&#x1f493; 博客主页&#xff1a;瑕疵的CSDN主页 &#x1f4dd; Gitee主页&#xff1a;瑕疵的gitee主页 ⏩ 文章专栏&#xff1a;《热点资讯》 目录被Node.js支配的痛&#xff0c;谁懂啊&#xff1f; 一、为什么我要和Node.js杠上 二、安装Node.js的血泪史 1. 官网下载的坑…

作者头像 李华