Centos系统命令如下:

#######查找已安装软件或者通过文件查找所属软件包
[root@centos ~]# rpm -qa | head -1 #查看已安装软件
lockdev-1.0.4-0.28.20111007git.el8.x86_64
[root@centos ~]# rpm -ql lockdev-1.0.4-0.28.20111007git.el8.x86_64 #查看软件安装哪些文件
/run/lock/lockdev
/usr/lib/.build-id
/usr/lib/.build-id/7d
---------省略
[root@centos ~]# which cat
/usr/bin/cat
[root@centos ~]# rpm -qf `which cat` #查看文件属于哪个rpm包,通过查到软件包,重新安装,解决命令被误删除
coreutils-8.30-8.el8.x86_64
#######软件安装卸载方法
[root@centos ~]#rpm -ivh xxx.rpm #安装软件包
[root@centos ~]#rpm -ivh --force xxx.rpm #强制安装,针对已安装软件,强制覆盖安装
[root@centos ~]#rpm -Uvh xxx.rpm #更新软件包
[root@centos ~]#rpm -e xxx  #卸载软件,不需要接rpm后缀,不建议使用这个命令卸载,因为会自动卸载其他依赖包
[root@centos ~]# rpm -e --nodeps xxx #推荐使用此命令卸载,脱离依赖卸载。
[root@centos ~]#yum remove xxx #不建议使用此方法卸载,会卸载依赖
[root@centos ~]# yum install nginx mariadb #使用yum安装多个软件,自动解决软件依赖,前提需要配置好yum源

配置yum源

[root@centos yum.repos.d]# ls /etc/yum.repos.d/ #默认都在此目录下,且已repo结尾才能生效。
appstrem.repo  bak  local.repo  tsinghua.repo
[root@centos yum.repos.d]# cat appstrem.repo 
[aapstream]
name=appstrem 
baseurl=file:////mnt/AppStream/  #仓库地址,不是rpm包路径,写repodata路径,里面含有软件包索引目录。
gpgcheck=0   #验证rpm完整性,本地镜像不需要验证,一般不开启。0关闭,1开启
enabled=1    #表示使用此仓库0关闭,1开启
##############
[baseos]
name=baseos
baseurl=file:///mnt/BaseOS/
gpgcheck=0
enabled=1
[root@centos yum.repos.d]# cat tsinghua.repo 
[tsinghua]
name=tsinghua_OS
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/8/extras/x86_64/os/ #使用互联网源仓库,此为清华源
gpgcheck=0
enabled=1
[root@centos yum.repos.d]# yum repolist all#列出所有,包括禁用
[root@centos yum.repos.d]# yum repolist #查看已配置仓库源是否生效
repo id                                        repo name
aapstream                                      appstrem
baseos                                         baseos
tsinghua                                       tsinghua_OS
[root@centos yum.repos.d]# yum clean all #清除yum缓存的软件包和元数据,非必要,请误用
[root@centos yum.repos.d]# yum list | head -5  #查看仓库源软件包
Last metadata expiration check: 0:12:17 ago on Wed 10 May 2023 10:51:29 AM EDT.
Installed Packages
GConf2.x86_64                                          3.2.6-22.el8                                      @AppStream
ModemManager.x86_64                                    1.10.8-2.el8                                      @anaconda 
ModemManager-glib.x86_64                               1.10.8-2.el8                                      @anaconda 
[root@centos yum.repos.d]# yum list | wc -l #统计仓库源总软件包
6895
####自己下载 RPM 包并制作 YUM 源文件
####先下载好所有rpm包,然后上传到linux系统,例如opt/test目录
####需要使用createrepo工具,没有就使用yum install createrepo 安装
[root@centos ~]# createrepo /opt/test #系统自动打包生产repodata目录
[root@centos ~]# 然后指定添加仓库地址:baseurl=file:///opt/test/