news 2026/1/23 4:54:17

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/1/18 18:29:27

Python+selenium实现自动化测试

&#x1f345; 点击文末小卡片 &#xff0c;免费获取软件测试全套资料&#xff0c;资料在手&#xff0c;涨薪更快安装selenium打开命令控制符输入&#xff1a;pip install -U selenium火狐浏览器安装firebug&#xff1a;www.firebug.com&#xff0c;调试所有网站语言&#xff0…

作者头像 李华
网站建设 2026/1/20 3:30:25

WAF的API防护功能能抵御接口攻击吗?

WAF的API防护功能专门设计用于识别和拦截针对API接口的各种攻击。通过多层次的检测机制和智能规则匹配&#xff0c;能够有效防范SQL注入、XSS跨站脚本、暴力破解等常见威胁。企业可根据业务需求灵活配置防护策略&#xff0c;确保API接口安全稳定运行。WAF如何识别API攻击行为&a…

作者头像 李华
网站建设 2026/1/19 8:11:57

22、DB2 应用开发入门指南

DB2 应用开发入门指南 1. Python 操作 DB2 数据库练习 在这个练习中,我们将实践编写一个小型 Python 脚本来访问 SAMPLE 数据库中的数据。具体步骤如下: 1. 登录服务器 :以实例所有者的身份登录服务器。在 Linux 上通常是 db2inst1 ,在 Windows 上通常是 db2admin …

作者头像 李华
网站建设 2026/1/22 20:41:36

什么是负载均衡?不就是加台服务器嘛!

你是小阿巴&#xff0c;刚刚开发上线了自己的第一个网站。 前几天只有几个人访问&#xff0c;网站运行得稳稳当当。 你得意地想&#xff1a;做网站也太简单了吧&#xff01; 结果一周后&#xff0c;某知名博主 “鱼蛋” 不小心推广了 你的网站&#xff0c;突然来了 1 万个用户…

作者头像 李华
网站建设 2026/1/21 17:42:56

19、深入了解 DB2 应用程序开发:PHP 与 Perl 的实践指南

深入了解 DB2 应用程序开发:PHP 与 Perl 的实践指南 1. PHP 与 DB2 应用开发基础 在使用 PHP 进行 DB2 应用开发时,首先要掌握基本的数据库连接和资源管理。以下是一个使用 PDO_ODBC 连接到 DB2 数据库并释放连接资源的示例代码: // for PDO_ODBC $dbh = new PDO(odbc:s…

作者头像 李华
网站建设 2026/1/16 18:28:38

LC.1008 | 前序遍历构造二叉搜索树 | 树 | 递归遍历

输入&#xff1a; 一个整数数组 preorder&#xff0c;代表二叉搜索树的先序遍历结果。 要求&#xff1a; 根据给定的先序遍历还原出二叉搜索树&#xff08;BST&#xff09;。 BST 的性质是&#xff1a;对于任意节点&#xff0c;左子树所有节点值 < 当前节点值 < 右子树所…

作者头像 李华