前言
这期呢主要说一说Linux中包软件管理相关命令,这一期的命令虽然只有两个。但 软件包的安装和卸载都是我们平常最常用的,需要熟练掌握。
rpm和yum 是CentOS 主要的包软件管理。
两个命令各有用处,①yum需要互联网,yum会去网上的yum源获取所需的软件包
② rpm 操作相对复杂,需要我们做得更多
rpm rpm包管理器
1、简介
rpm 命令包含了安装、卸载、升级、查询和验证5个基本功能
2、语法格式
rpm [参数选项]
3、参数选项
参数 | 参数说明 |
---|---|
-q | 查询软件包 |
-p | 后面接“.rpm”为后缀的软件包 |
-i | ①与-qp配合使用,表示显示软件包的概要信息 info ②安装软件包 install |
-l | 显示软件包种所有文件列表 |
-R | 显示软件包依赖环境 |
-v | 显示详细信息 |
-h | 用“#” 显示安装进度条 |
-a | 与-q参数搭配使用,用于查询所有的软件包 |
-e | 卸载软件包 |
-f | 查询文件或命令属于哪个软件包 |
-U | 升级软件包 |
4、 实践操作
我们下载一个rpm包telnet-server-0.17-66.el7.x86_64.rpm作为后续实践操作文件
[root@xiezhr test]# wget https://mirrors.aliyun.com/centos/7.9.2009/updates/x86_64/Packages/telnet-server-0.17-66.el7.x86_64.rpm
--2022-08-02 22:47:29-- https://mirrors.aliyun.com/centos/7.9.2009/updates/x86_64/Packages/telnet-server-0.17-66.el7.x86_64.rpm
Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 101.226.26.240, 101.226.26.241, 101.226.26.242, ...
Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|101.226.26.240|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 42148 (41K) [application/octet-stream]
Saving to: ‘telnet-server-0.17-66.el7.x86_64.rpm’
100%[========================================================================================================================================================================>] 42,148 --.-K/s in 0.01s
2022-08-02 22:47:29 (3.70 MB/s) - ‘telnet-server-0.17-66.el7.x86_64.rpm’ saved [42148/42148]
① 查看rpm包信息
[root@xiezhr test]# rpm -qpi telnet-server-0.17-66.el7.x86_64.rpm
Name : telnet-server
Epoch : 1
Version : 0.17
Release : 66.el7
Architecture: x86_64
Install Date: (not installed)
Group : System Environment/Daemons
Size : 56361
License : BSD
Signature : RSA/SHA256, Wed 18 Nov 2020 10:20:43 PM CST, Key ID 24c6a8a7f4a80eb5
Source RPM : telnet-0.17-66.el7.src.rpm
Build Date : Tue 17 Nov 2020 12:44:28 AM CST
Build Host : x86-01.bsys.centos.org
Relocations : (not relocatable)
Packager : CentOS BuildSystem <http://bugs.centos.org>
Vendor : CentOS
URL : http://web.archive.org/web/20070819111735/www.hcs.harvard.edu/~dholland/computers/old-netkit.html
Summary : The server program for the Telnet remote login protocol
Description :
Telnet is a popular protocol for logging into remote systems over the
Internet. The package includes a daemon that supports Telnet remote
logins into the host machine. The daemon is disabled by default.
You may enable the daemon by editing /etc/xinetd.d/telnet
② 查看rpm包内容
[root@xiezhr test]# rpm -qpl telnet-server-0.17-66.el7.x86_64.rpm
/usr/lib/systemd/system/telnet.socket
/usr/lib/systemd/system/telnet@.service
/usr/sbin/in.telnetd
/usr/share/man/man5/issue.net.5.gz
/usr/share/man/man8/in.telnetd.8.gz
/usr/share/man/man8/telnetd.8.gz
③ 查看rpm包的依赖环境
[root@xiezhr test]# rpm -qpR telnet-server-0.17-66.el7.x86_64.rpm
/bin/sh
/bin/sh
/bin/sh
libc.so.6()(64bit)
libc.so.6(GLIBC_2.14)(64bit)
libc.so.6(GLIBC_2.15)(64bit)
libc.so.6(GLIBC_2.16)(64bit)
libc.so.6(GLIBC_2.2.5)(64bit)
libc.so.6(GLIBC_2.3)(64bit)
libc.so.6(GLIBC_2.3.4)(64bit)
libc.so.6(GLIBC_2.4)(64bit)
libc.so.6(GLIBC_2.8)(64bit)
libutil.so.1()(64bit)
libutil.so.1(GLIBC_2.2.5)(64bit)
rpmlib(Co