1、rpm
程序包管理:
用法: rpm [选项...] 查询/验证软件包选项: -a, --all 查询/验证所有软件包 -f, --file 查询/验证文件属于的软件包 -g, --group 查询/验证组中的软件包 -p, --package 查询/验证一个软件包 查询选项(用 -q 或 --query): -c, --configfiles 列出所有配置文件 -d, --docfiles 列出所有程序文档 --dump 转储基本文件信息 -l, --list 列出软件包中的文件 --queryformat=QUERYFORMAT 使用这种格式打印信息 -s, --state 显示列出文件的状态 验证选项(用 -V 或 --verify): --nofiledigest 不验证文件摘要 --nofiles 不验证软件包中文件 --nodeps 不验证包依赖 --noscript 不执行验证脚本 安装/升级/擦除选项: -e, --erase=<package>+ 清除 (卸载) 软件包 --force --replacepkgs --replacefiles 的缩写 -F, --freshen=<packagefile>+ 如果软件包已经安装,升级软件包 -h, --hash 软件包安装的时候列出哈希标记 (和 -v 一起使用效果更好) -i, --install 安装软件包 --nodeps 不验证软件包依赖 --noorder 不对软件包安装重新排序以满足依赖关系 --noscripts 不执行软件包脚本 --oldpackage 更新到软件包的旧版本(带 --force 自动完成这一功能) --test 不真正安装,只是判断下是否能安装 -U, --upgrade=<packagefile>+ 升级软件包 -v, --verbose 提供更多的详细信息输出 --version 打印使用的 rpm 版本号
安装:
[root@localhost Packages]# rpm -ivh zip-3.0-10.el7.x86_64.rpm Preparing... ################################# [100%] Updating / installing... 1:zip-3.0-10.el7 ################################# [100%] [root@localhost Packages]#
卸载:
[root@localhost Packages]# rpm -e zip-3.0-10.el7.x86_64 [root@localhost Packages]#
查询:
-qa: 查询本机已经安装的所有程序包;
[root@localhost Packages]# rpm -qa zip zip-3.0-10.el7.x86_64 [root@localhost Packages]#
-qf /PATH/TO/SOMEFILE: 查询此处的文件由哪个程序包安装生成;
[root@localhost Packages]# rpm -qf /etc/fstab setup-2.8.71-5.el7.noarch [root@localhost Packages]#
-qi: 查询指定的程序包的相关信息;
[root@localhost Packages]# rpm -qi zip-3.0-10.el7.x86_64 Name : zip Version : 3.0 Release : 10.el7 Architecture: x86_64 Install Date: Mon 14 Sep 2015 04:04:21 PM CST Group : Applications/Archiving Size : 815037 License : BSD Signature : RSA/SHA256, Fri 04 Jul 2014 01:53:58 PM CST, Key ID 24c6a8a7f4a80eb5 Source RPM : zip-3.0-10.el7.src.rpm Build Date : Tue 10 Jun 2014 10:37:07 AM CST Build Host : worker1.bsys.centos.org Relocations : (not relocatable) Packager : CentOS BuildSystem <http://bugs.centos.org> Vendor : CentOS URL : http://www.info-zip.org/Zip.html Summary : A file compression and packaging utility compatible with PKZIP Description : The zip program is a compression and file packaging utility. Zip is analogous to a combination of the UNIX tar and compress commands and is compatible with PKZIP (a compression and file packaging utility for MS-DOS systems). Install the zip package if you need to compress files using the zip program. [root@localhost Packages]#
-ql: 查询程序包安装生成的所有文件的列表;
[root@localhost Packages]# rpm -ql zip-3.0-10.el7.x86_64 /usr/bin/zip /usr/bin/zipcloak /usr/bin/zipnote /usr/bin/zipsplit /usr/share/doc/zip-3.0 /usr/share/doc/zip-3.0/CHANGES /usr/share/doc/zip-3.0/LICENSE /usr/share/doc/zip-3.0/README /usr/share/doc/zip-3.0/README.CR /usr/share/doc/zip-3.0/TODO /usr/share/doc/zip-3.0/WHATSNEW /usr/share/doc/zip-3.0/WHERE /usr/share/doc/zip-3.0/algorith.txt /usr/share/man/man1/zip.1.gz /usr/share/man/man1/zipcloak.1.gz /usr/share/man/man1/zipnote.1.gz /usr/share/man/man1/zipsplit.1.gz [root@localhost Packages]#
校验:
rpm {-V|--verify} [select-options] [verify-options] 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
2、yum
Yellowdog Updater Modified
用法: yum [选项] COMMAND List of Commands: check 检查 RPM 数据库问题 check-update 检查是否有可用的软件包更新 clean 删除缓存数据 deplist 列出软件包的依赖关系 distribution-synchronization 已同步软件包到最新可用版本 downgrade 降级软件包 erase 从系统中移除一个或多个软件包 groups 显示或使用、组信息 help 显示用法提示 info 显示关于软件包或组的详细信息 install 向系统中安装一个或多个软件包 remove 卸载 list 列出一个或一组软件包 makecache 创建元数据缓存 provides 查找提供指定内容的软件包 reinstall 覆盖安装软件包 repolist 显示已配置的源 search 在软件包详细信息中搜索指定字符串 shell 运行交互式的 yum shell update 更新系统中的一个或多个软件包 upgrade 更新软件包同时考虑软件包取代关系 version 显示机器和/或可用的源版本。 Options: -h, --help 显示此帮助消息并退出 -t, --tolerant 忽略错误 -C, --cacheonly 完全从系统缓存运行,不升级缓存 -q, --quiet 静默执行 -v, --verbose 详尽的操作过程 -y, --assumeyes 回答全部问题为是 --version 显示 Yum 版本然后退出
设置yum光盘源
挂载光盘到/media/cdrom
[root@localhost yum.repos.d]# mount /dev/cdrom /media/cdrom/
创建并编辑/etc/yum.repos.d/cdrom.repo文件,添加如下:
[CentOS7_CDROM_ISO] name=CentOS_7_ISO_CDROM baseurl=file:///media/cdrom gpgcheck=0 enabled=1
备份源仓库文件
[root@localhost yum.repos.d]# mv CentOS-Base.repo CentOS-Base.repo.bak
查看源库列表
[root@localhost yum.repos.d]# yum repolist Loaded plugins: fastestmirror, langpacks CentOS7_ISO_CDROM | 3.6 kB 00:00:00 (1/2): CentOS7_ISO_CDROM/group_gz | 154 kB 00:00:00 (2/2): CentOS7_ISO_CDROM/primary_db | 2.7 MB 00:00:00 Loading mirror speeds from cached hostfile repo id repo name status CentOS7_ISO_CDROM CentOS7_ISO_CDROM 3,576 repolist: 3,576 [root@localhost yum.repos.d]#
安装:
[root@localhost Packages]# yum install vsftpd Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile Resolving Dependencies --> Running transaction check ---> Package vsftpd.x86_64 0:3.0.2-9.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ============================================================================================================= Package Arch Version Repository Size ============================================================================================================= Installing: vsftpd x86_64 3.0.2-9.el7 CentOS7CDROMISO 165 k Transaction Summary ============================================================================================================= Install 1 Package Total download size: 165 k Installed size: 343 k Is this ok [y/d/N]: y Downloading packages: Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : vsftpd-3.0.2-9.el7.x86_64 1/1 Verifying : vsftpd-3.0.2-9.el7.x86_64 1/1 Installed: vsftpd.x86_64 0:3.0.2-9.el7 Complete! [root@localhost Packages]#
卸载:
[root@localhost yum.repos.d]# yum remove vsftpd Loaded plugins: fastestmirror, langpacks Resolving Dependencies --> Running transaction check ---> Package vsftpd.x86_64 0:3.0.2-9.el7 will be erased --> Finished Dependency Resolution Dependencies Resolved ============================================================================================================= Package Arch Version Repository Size ============================================================================================================= Removing: vsftpd x86_64 3.0.2-9.el7 @CentOS7CDROMISO 343 k Transaction Summary ============================================================================================================= Remove 1 Package Installed size: 343 k Is this ok [y/N]: y Downloading packages: Running transaction check Running transaction test Transaction test succeeded Running transaction Erasing : vsftpd-3.0.2-9.el7.x86_64 1/1 Verifying : vsftpd-3.0.2-9.el7.x86_64 1/1 Removed: vsftpd.x86_64 0:3.0.2-9.el7 Complete! [root@localhost yum.repos.d]#
查询:
查看仓库信息:
[root@localhost yum.repos.d]# yum repoinfo Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile Repo-id : CentOS7_ISO_CDROM Repo-name : CentOS7_ISO_CDROM Repo-revision: 1427845377 Repo-updated : Wed Apr 1 07:43:47 2015 Repo-pkgs : 3,576 Repo-size : 3.6 G Repo-baseurl : file:///media/cdrom/ Repo-expire : 21,600 second(s) (last: Mon Sep 14 16:28:19 2015) Repo-filename: /etc/yum.repos.d/cdrom.repo repolist: 3,576 [root@localhost yum.repos.d]#
查看已安装程序:
[root@localhost yum.repos.d]# yum list all | grep wget wget.x86_64 1.14-10.el7_0.1 @anaconda [root@localhost yum.repos.d]#
查看包组:
[root@localhost yum.repos.d]# yum grouplist Loaded plugins: fastestmirror, langpacks There is no installed groups file. Maybe run: yum groups mark convert (see man yum) Loading mirror speeds from cached hostfile Available environment groups: Minimal Install Compute Node Infrastructure Server File and Print Server Basic Web Server Virtualization Host Server with GUI GNOME Desktop KDE Plasma Workspaces Development and Creative Workstation Available Groups: Compatibility Libraries Console Internet Tools Development Tools Graphical Administration Tools Legacy UNIX Compatibility Scientific Support Security Tools Smart Card Support System Administration Tools System Management Done [root@localhost yum.repos.d]#
本文出自 “啊杜” 博客,请务必保留此出处http://253737.blog.51cto.com/243737/1694641
原文地址:http://253737.blog.51cto.com/243737/1694641