Linux软件包管理
Linux软件包管理
😄 Written by Zak Zhu
目录
参考
- 马哥linux视频
- RHCE培训(rh133-unit2)
RPM
RPM -- Redhat Package Manager
rpm包
-
命名格式
PackageName-Version-Release.Arch.rpm
e.g. vim-enhanced-7.2.411-1.8.el6.x86_64.rpm
-
组成部分
- Files Archive: Binaries, Documentation, “Default” Config
- Summary, Description, Changelog
- Instructions: Dependencies, Pre/Post Install/Uninstall
- Signature
-
获取途径
-
系统镜像
-
Fedora EPEL
-
大厂开源镜像网站
e.g.1 mirrors.163.com
e,g,2 mirrors.aliyun.com
-
RPMFIND网站(rpmfind.net)
-
rpm命令
*安装
rpm -ivh PACKAGE_FILE ...
# Options:
-i, --install
-v, --verbose
-h # print hash marks as package installs
--replacepkgs # reinstall
--nodeps # ignore dependencies
--force
--test
*卸载
rpm -e PACKAGE_NAME ...
# Options:
-e, --erase
查询
针对已安装包的查询
-
查询所有已安装包
rpm -qa # Options: -q, --query -a, --all
-
*查询已安装包的详细信息
rpm -qi PACKAGE_NAME # Options: -q, --query -i, --info
-
查询已安装包生成的文件
rpm -ql PACKAGE_NAME # Options: -q, --query -l, --list
-
查询已安装包的配置文件
rpm -qc PACKAGE_NAME # Options: -q, --query -c, --configfiles
-
查询已安装包的帮助文档
rpm -qd PACKAGE_NAME # Options: -q, --query -d, --docfiles
-
查询该文件是哪个已安装包生成的
rpm -qf /PATH/TO/SOMEFILE # Options: -q, --query -f, --file
针对未安装包的查询
rpm -qp [QUERY_OPTIONS] /PATH/TO/PACKAGE_FILE
# Options:
-q, --query
-p, --package
# Query options:
--scripts # 安全起见, 建议安装前查看下软件包里的脚本
-i, --info
校验
-
导入密钥
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
-
查看密钥
rpm -qa gpg-pubkey
-
安装前校验
rpm -K /PATH/TO/PACKAGE_FILE
-
安装后校验
rpm -V PACKAGE_NAME
- S file Size differs
- M Mode differs (includes permissions and file type)
- 5 digest (formerly MD5 sum) differs
- D Device major/minor number mismatch
- L readLink(2) path mismatch
- U User ownership differs
- G Group ownership differs
- T mTime differs
- P caPabilities differ
YUM
YUM -- Yellowdog Updater Modified
yum命令
Yum support glob!
yum仓库相关命令
# 列出所有yum仓库
yum repolist all
# 清理所有yum仓库的所有缓存
yum clean all --enablerepo='*' # If you want to also clean any disabled repositories you need to use --enablerepo=’*’ option.
查询某文件来自哪个包
yum provides /PATH/TO/SOMEFILE
e.g. yum provides *bin/tree
列出软件包的命令
# 列出包
yum list [ all | installed | availale ]
# 列出包组
yum grouplist
显示软件包的信息
# 显示包信息
yum info PACKAGE_NAME
# 显示包组信息
yum groupinfo "PACKAGE_GROUP_NAME"
安装软件包的命令
# 安装包
yum install <PACKAGE_NAME | /PATH/TO/PACKAGE_FILE>
# 重新安装包
yum reinstall PACKAGE_NAME
# 安装包组
yum groupinstall "PACKAGE_GROUP_NAME"
三个开发相关的包组:
- Server Platform Development
- Development Tools
- Desktop Platform Development
卸载软件包的命令
# 卸载包
yum remove PACKAGE_NAME
# 卸载包组
yum groupremove "PACKAGE_GROUP_NAME"
升级或降级软件包
# 检查可升级的包
yum check-update
# 升级包
yum update foo-1.2
# 降级包
yum downgrade foo-1.1