软件包rpm命令#查看系统安装的所有软件包[rootserver ~14:05:05]# rpm -qa|headfirewalld-filesystem-0.6.3-13.el7_9.noarch setup-2.8.71-11.el7.noarch NetworkManager-team-1.18.8-2.el7_9.x86_64 kbd-misc-1.15.5-16.el7_9.noarch selinux-policy-targeted-3.13.1-268.el7_9.2.noarch lshw-B.02.18-17.el7.x86_64 libsepol-2.5-10.el7.x86_64 biosdevname-0.7.3-2.el7.x86_64 info-5.1-5.el7.x86_64 aic94xx-firmware-30-6.el7.noarch#查询系统中是否安装了某软件包[rootserver ~14:06:51]# rpm -q httpdpackage httpd is not installed#安装httpd[rootserver ~14:06:55]# yum install -y httpd#再次查看[rootserver ~14:07:19]# rpm -q httpdhttpd-2.4.6-99.el7.centos.1.x86_64#查看系统中安装过的包的数据信息[rootserver ~14:55:40]# rpm -q httpd -iName:httpd Version:2.4.6 Release:99.el7.centos.1 Architecture: x86_64 Install Date: Mon May1814:07:192026Group:System Environment/Daemons Size:9829328License:ASL2.0Signature:RSA/SHA256, Tue May3023:15:452023, Key ID 24c6a8a7f4a80eb5 Source RPM:httpd-2.4.6-99.el7.centos.1.src.rpm Build Date:Tue May3022:02:562023Build Host:x86-01.bsys.centos.org Relocations:(not relocatable)Packager:CentOS BuildSystemhttp://bugs.centos.orgVendor:CentOS URL:http://httpd.apache.org/ Summary:Apache HTTP Server Description:The Apache HTTP Server is a powerful, efficient, and extensible web server.#查看系统中某个已安装过的包包含哪些文件[rootserver ~15:06:38]# rpm -q openssh-server -l/etc/pam.d/sshd /etc/ssh/sshd_config /etc/sysconfig/sshd /usr/lib/systemd/system/sshd-keygen.service /usr/lib/systemd/system/sshd.service /usr/lib/systemd/system/sshd.socket /usr/lib/systemd/system/sshd.service /usr/lib64/fipscheck/sshd.hmac /usr/libexec/openssh/sftp-server /usr/sbin/sshd /usr/sbin/sshd-keygen /usr/share/man/man5/moduli.5.gz /usr/share/man/man5/sshd_config.5.gz /usr/share/man/man8/sftp-server.8.gz /usr/share/man/man8/sshd.8.gz /var/empty/sshd#查看系统中某个已安装过的包包含哪些配置文件[rootserver ~15:07:47]# rpm -q openssh-server -c/etc/pam.d/sshd /etc/ssh/sshd_config /etc/sysconfig/sshd#下载httpd软件包以及其他依赖的软件包只下载不安装[rootserver ~15:08:25]# yumdownloader httpdLoaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com httpd-2.4.6-99.el7.centos.1.x86_64.rpm|2.7MB 00:01#查看系统中某个软件包文件包含哪些配置文件[rootserver ~15:08:25]# rpm -q -p httpd-2.4.6-99.el7.centos.1.x86_64.rpm -c......# 查询系统中某个软件包组中包涵哪些软件包[rootserver ~15:08:25]# rpm -qg System Environment/Base......#查看软件包所在仓库精确位置[rootserver ~15:10:45]# repoquery --location httpdhttp://mirrors.aliyun.com/centos/7/updates/x86_64/Packages/httpd-2.4.6-99.el7.centos.1.x86_64.rpm#通过wget下载文件要有wget软件包[rootserver ~15:13:31]# wget \http://mirrors.aliyun.com/centos/7/updates/x86_64/Packages/httpd-2.4.6-99.el7.centos.1.x86_64.rpm--2026-05-1815:14:16-- http://mirrors.aliyun.com/centos/7/updates/x86_64/Packages/httpd-2.4.6-99.el7.centos.1.x86_64.rpm Resolving mirrors.aliyun.com(mirrors.aliyun.com)...58.215.109.81,58.215.109.86,58.215.109.83,... Connecting to mirrors.aliyun.com(mirrors.aliyun.com)|58.215.109.81|:80... connected. HTTP request sent, awaiting response...200OK Length:2849200(2.7M)[application/x-rpm]Saving to:httpd-2.4.6-99.el7.centos.1.x86_64.rpm.1100%[]2,849,2001.17MB/sin2.3s2026-05-1815:14:19(1.17MB/s)-httpd-2.4.6-99.el7.centos.1.x86_64.rpm.1saved[2849200/2849200]验证# 查看openssh-server软件安装是否有问题[rootserver ~15:59:13]# rpm -V openssh-server#修改[rootserver ~16:00:26]# sed -i s/PermitRootLogin yes/PermitRootLogin no/g /etc/ssh/sshd_config[rootserver ~16:01:11]# rpm -V openssh-serverS.5....T. c /etc/ssh/sshd_config#移走文件再次查看[rootserver ~16:01:21]# mv /etc/ssh/sshd_config .[rootserver ~16:01:43]# rpm -V openssh-server遗漏 c /etc/ssh/sshd_config#恢复文件位置[rootserver ~16:01:52]# mv sshd_config /etc/ssh/sshd_config安装#查看下载地址[rootserver ~16:02:30]# repoquery --location lrzszhttp://mirrors.aliyun.com/centos/7/os/x86_64/Packages/lrzsz-0.12.20-36.el7.x86_64.rpm#下载软件包[rootserver ~16:04:41]# wget http://mirrors.aliyun.com/centos/7/os/x86_64/Packages/lrzsz-0.12.20-36.el7.x86_64.rpm--2026-05-1816:05:02-- http://mirrors.aliyun.com/centos/7/os/x86_64/Packages/lrzsz-0.12.20-36.el7.x86_64.rpm 正在解析主机 mirrors.aliyun.com(mirrors.aliyun.com)...221.231.47.30,180.97.214.189,117.85.69.33,... 正在连接 mirrors.aliyun.com(mirrors.aliyun.com)|221.231.47.30|:80... 已连接。 已发出 HTTP 请求正在等待回应...200OK 长度79376(78K)[application/x-rpm]正在保存至: “lrzsz-0.12.20-36.el7.x86_64.rpm.1”100%[]79,376502KB/s 用时0.2s2026-05-1816:05:02(502KB/s)- 已保存 “lrzsz-0.12.20-36.el7.x86_64.rpm.1”[79376/79376])#安装[rootserver ~16:05:02]# rpm -i lrzsz-0.12.20-36.el7.x86_64.rpm[rootserver ~16:07:48]# rpm -q lrzszlrzsz-0.12.20-36.el7.x86_64卸载#卸载[rootserver ~16:08:01]# rpm -e lrzsz[rootserver ~16:08:45]# rpm -q lrzsz未安装软件包 lrzsz友好方式安装与卸载#安装[rootserver ~16:08:51]# rpm -ivh lrzsz-0.12.20-36.el7.x86_64.rpm准备中...################################# [100%]正在升级/安装...1:lrzsz-0.12.20-36.el7################################# [100%]#卸载[rootserver ~16:09:30]# rpm -evh lrzsz准备中...################################# [100%]正在清理/删除...1:lrzsz-0.12.20-36.el7################################# [100%[rootserver ~16:09:42]# rpm -e apr apr-util httpd-tools mailcap[rootserver ~16:11:12]# rpm -ivh httpd-2.4.6-99.el7.centos.1.x86_64.rpm错误依赖检测失败 /etc/mime.types 被 httpd-2.4.6-99.el7.centos.1.x86_64 需要 httpd-tools2.4.6-99.el7.centos.1 被 httpd-2.4.6-99.el7.centos.1.x86_64 需要 libapr-1.so.0()(64bit)被 httpd-2.4.6-99.el7.centos.1.x86_64 需要 libaprutil-1.so.0()(64bit)被 httpd-2.4.6-99.el7.centos.1.x86_64 需要#重新安装[rootserver ~16:11:20]# rpm --reinstall -vh lrzsz*警告软件包 lrzsz-0.12.20-36.el7.x86_64 已被加入跳过 lrzsz-0.12.20-36.el7.x86_64 准备中...################################# [100%]正在升级/安装...1:lrzsz-0.12.20-36.el7################################# [100%yumrpm 命令是一个管理软件包的工具不适用于软件包存储库或自动解决来自多个源的依赖项。YumYellowdog Updater Modified旨在成为管理基于RPM的软件安装和更新的更好系统。yum命令允许安装更新删除和获取有关软件包及其依赖项的信息。yum命令#用help帮助查看命令信息[rootserver ~16:23:04]# yum --help已加载插件fastestmirror Usage: yum[options]COMMAND List of Commands: check 检查 RPM 数据库问题 check-update 检查是否有可用的软件包更新......#查看仓库中httpd包信息[rootserver ~16:23:06]# yum info httpd已加载插件fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com 可安装的软件包 名称 httpd 架构 x86_64 版本 2.4.6 发布 99.el7.centos.1 大小 2.7 M 源 updates/7/x86_64 简介 Apache HTTP Server 网址 http://httpd.apache.org/ 协议 ASL2.0描述 The Apache HTTP Server is a powerful, efficient, and extensible:web server.#查询软件包清单[rootserver ~16:24:03]# yum list httpd*已加载插件fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com 可安装的软件包 httpd.x86_642.4.6-99.el7.centos.1 updates httpd-devel.x86_642.4.6-99.el7.centos.1 updates httpd-itk.x86_642.4.7.04-2.el7 epel httpd-manual.noarch2.4.6-99.el7.centos.1 updates httpd-tools.x86_642.4.6-99.el7.centos.1 updates#查看仓库中httpd包有哪些版本[rootserver ~16:25:06]# yum list httpd --showduplicates已加载插件fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com 可安装的软件包 httpd.x86_642.4.6-95.el7.centos base httpd.x86_642.4.6-97.el7.centos updates httpd.x86_642.4.6-97.el7.centos.1 updates httpd.x86_642.4.6-97.el7.centos.2 updates httpd.x86_642.4.6-97.el7.centos.4 updates httpd.x86_642.4.6-97.el7.centos.5 updates httpd.x86_642.4.6-98.el7.centos.6 updates httpd.x86_642.4.6-98.el7.centos.7 updates httpd.x86_642.4.6-99.el7.centos.1 updates#查看简介包含关键字的软件包search[rootserver ~16:27:58]# yum search web server#查看仓库中哪个包能提供相对应文件provides[rootserver ~16:28:05]# yum provides sar......#安装相对应软件包[rootserver ~16:29:10]# yum install -y sysstat#安装软件包install[rootserver ~16:30:11]# yum install -y vsftpd#只下载不按照[rootserver ~16:31:21]# yumdownloader vsftpd#安装系统中vsftpd包localinstall[rootserver ~16:31:54]# yum localinstall ./vsftpd-3.0.2-29.el7_9.x86_64.rpm#软件包降级downgrade降级时需一并降级所依赖的软件包[rootserver ~16:33:06]# yum downgrade -y vsftpd-3.0.2-28.el7#软件包升级update[rootserver ~16:34:37]# yum update vsftpd-3.0.2-29.el7_9#软件包卸载remove[rootserver ~16:35:48]# yum remove -y vsftpdhistory子命令#查看yum历史命令记录[rootserver ~16:36:17]# yum history list#特定yum事务详细信息[rootserver ~16:37:42]# yum history info 2#反向操作第四个事务[rootserver ~16:38:52]# yum history undo 4#重做操作第4个事务[rootserver ~16:40:59]# yum history redo 4软件包组管理# 查看仓库中软件包组清单[rootserver ~16:41:01]# yum grouplist......#查看软件包组中GUI的服务器的信息[rootserver ~16:44:32]# yum groupinfo Server with GUI#安装仓库中软件包组[rootserver ~16:44:47]# yum groupinstall Server with GUI# 卸载仓库中软件包组[rootserver ~16:44:57]# yum groupremove Server with GUIyum 仓库配置#查看yum工具的配置文件[rootserver ~16:45:27]# cat /etc/yum.conf#安装软件包[rootserver ~16:50:17]# yum install -y yum-utils#查看完整配置[rootserver ~16:50:28]# yum-config-manager......main 部分设置全局配置enabled 1仓库默认启用。gpgcheck 1仓库默认启用gpg校验。keepcache 0不保存缓存。cachedir /var/cache/yum缓存文件保存的位置。reposdir /etc/yum.repos.d, /etc/yum/repos.d,yum仓库配置文件。yum管理的软件包存放在yum仓库yum仓库配置文件存放在/etc/yum.repos.d目录。yum仓库管理1、查看yum仓库#查看启用的yum仓库[rootserver ~16:51:04]# yum repolist已加载插件fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com 源标识 源名称 状态 base/7/x86_64 CentOS-710,072docker-ce-stable/7/x86_64 Docker C337epel/x86_64 Extra Pa13,791extras/7/x86_64 CentOS-7526mirrors.aliyun.com_kubernetes_yum_repos_kubernetes-el7-x86_64_ added fr1,022updates/7/x86_64 CentOS-76,173repolist:31,921#查看所有的yum仓库[rootserver ~16:53:48]# yum repolist all2、启用和禁用仓库#启用[rootserver ~16:55:11]# yum-config-manager --enable epel-debuginfo#禁用[rootserver ~16:57:32]# yum-config-manager --disable epel-debuginfo#也可以通过修改配置文件启用禁用仓库默认enabled为1[rootserver ~16:57:52]# vim /etc/yum.repos.d/epel.repo[epel]nameExtra PackagesforEnterprise Linux7-$basearchbaseurlhttp://mirrors.aliyun.com/epel/7/$basearchfailovermethodpriorityenabled1gpgcheck0gpgkeyfile:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7[epel-debuginfo]nameExtra PackagesforEnterprise Linux7-$basearch- Debugbaseurlhttp://mirrors.aliyun.com/epel/7/$basearch/debugfailovermethodpriorityenabled0gpgkeyfile:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7gpgcheck0[epel-source]nameExtra PackagesforEnterprise Linux7-$basearch- Sourcebaseurlhttp://mirrors.aliyun.com/epel/7/SRPMSfailovermethodpriorityenabled03、仓库缓存管理#清除所有缓存[rootserver ~16:59:57]# yum clean all已加载插件fastestmirror 正在清理软件源 base docker-ce-stable epel extras:mirrors.aliyun.com_kubernetes_yum_repos_kubernetes-el7-x86_64_:updates Cleaning up list of fastest mirrors#创建缓存数据[rootserver ~17:01:01]# yum makecache4、添加仓库kubernetes#通过命令添加[rootserver ~17:02:25]# yum-config-manager --add-repohttps://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/#查看[rootserver ~17:04:57]# cat /etc/yum.repos.d/mirrors.aliyun.com_kubernetes_yum_repos_kubernetes-el7-x86_64_.repo[mirrors.aliyun.com_kubernetes_yum_repos_kubernetes-el7-x86_64_]nameadded from: https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/baseurlhttps://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/enabled1#安装 kubectl 包[rootserver ~17:06:26]# yum install kubectl --nogpgcheck5、添加仓库doker-ce#通过修改配置文件[rootserver ~17:06:56]# cat EOF /etc/yum.repos.d/docker-ce.repo[docker-ce-stable]nameDocker CE Stable -$basearchbaseurlhttps://mirrors.aliyun.com/docker-ce/linux/centos/$releasever/$basearch/stableenabled1gpgcheck0EOF#查看版本[rootserver ~17:08:20]# yum list docker-ce已加载插件fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com 可安装的软件包 docker-ce.x86_643:26.1.4-1.el7 docker-ce-stabl源码安装NginxNginx是一个高性能的HTTP和反向代理web服务器。官方地址https://nginx.org#用wget下载压缩包[rootserver ~17:11:03]# wget https://nginx.org/download/nginx-1.24.0.tar.gz#解压[rootserver ~17:11:46]# tar -xf nginx-1.24.0.tar.gz#配置[rootserver ~17:12:20]# cd nginx-1.24.0/[rootserver nginx-1.24.017:12:35]# ./configure --prefix/usr/local/nginx#根据报错来安装依赖软件包[rootserver nginx-1.24.017:13:34]# yum install gcc make pcre-devel zlib-devel......#编译安装[rootserver nginx-1.24.017:14:46]# make make install[rootserver nginx17:16:21]# ls /usr/local/nginx/conf html logs sbin#配置环境变量[rootserver nginx-1.24.017:16:54]# export PATH$PATH:/usr/local/nginx/sbin/#修改配置文件[rootserver nginx-1.24.017:17:36]# vim ~/.bashrc#添加一行exportPATH$PATH:/usr/local/nginx/sbin/#启动服务[rootserver nginx17:18:44]# nginx#用ip验证最后退出服务即可配置Nginx服务[rootserver ~17:22:54]# cp /usr/lib/systemd/system/sshd.service /etc/systemd/system/nginx.service[rootserver ~17:22:58]# vim /etc/systemd/system/nginx.service[Unit]DescriptionNginx server daemon[Service]TypeforkingExecStart/usr/local/nginx/sbin/nginx-c/usr/local/nginx/conf/nginx.confExecReload/usr/local/nginx/sbin/nginx-sreload[Install]WantedBymulti-user.target[rootserver ~17:28:40]# systemctl daemon-reload[rootserver ~17:29:06]# systemctl enable nginx.service --now源码安装cmatrixCmatrix 是一款 Linux 环境下的炫酷屏保软件其效果类似于黑客帝国电影中的代码雨。项目地址https://github.com/abishekvashok/cmatrix#下载[rootserver ~17:29:13]# wget https://laoma.cloud/course-materials/softwares/stage01/cmatrix-1.2.tar.gz--2026-05-1817:32:14-- https://laoma.cloud/course-materials/softwares/stage01/cmatrix-1.2.tar.gz 正在解析主机 laoma.cloud(laoma.cloud)...8.159.134.206 正在连接 laoma.cloud(laoma.cloud)|8.159.134.206|:443... 已连接。 已发出 HTTP 请求正在等待回应...200OK 长度117828(115K)[application/octet-stream]正在保存至: “cmatrix-1.2.tar.gz”100%[]117,828--.-K/s 用时0.02s2026-05-1817:32:14(4.55MB/s)- 已保存 “cmatrix-1.2.tar.gz”[117828/117828])#安装依赖软件包[rootserver ~17:32:14]# yum -y install gcc make autoconf ncurses-devel#解压[rootserver ~17:32:38]# tar -xf cmatrix-1.2.tar.gz#配置软件[rootserver ~17:33:11]# cd cmatrix-1.2/[rootserver cmatrix-1.217:33:30]# ./configure --prefix/usr/local/cmatrix#编译[rootserver cmatrix-1.217:33:42]# make make install#修改环境变量[rootserver cmatrix-1.217:34:06]# export PATH$PATH:/usr/local/cmatrix/bin#执行[rootserver cmatrix-1.217:34:30]# cmatrix