rpm包:
RPM 全名是『 RedHat Package Manager 』简称则为 RPM。RPM 是以一种数据库记录的方式来将你所需要的套件安装到你的 Linux 主机的一套管理程序。他最大的特点就是将您要安装的套件先编译过( 如果需要的话 )并且打包好了,透过包装好的套件里头预设的数据库记录,记录这个套件要安装的时候必须要的相依属性模块( 就是你的 Linux 主机需要先存在的几个必须的套件 ),当安装在你的 Linux 主机时, RPM 会先依照套件里头的纪录数据查询 Linux 主机的相依属性套件是否满足, 若满足则予以安装,若不满足则不予安装。那么安装的时候就将该套件的信息整个写入 RPM 的数据库中,以便未来的查询、验证与反安装!这样一来的优点是:
1. 由于已经编译完成并且打包完毕,所以安装上很方便( 不需要再重新编译 );
2. 由于套件的信息都已经记录在 Linux 主机的数据库上,很方便查询、升级与反安装;
缺点是:
1. 安装的环境必须与打包时的环境需求一致或相当;
2. 需要满足套件的相依属性需求;
3. 反安装时需要特别小心,最底层的套件不可先移除,否则可能造成整个系统的问题!
程序包的组成部分:
二进制程序:/bin, /sbin,/ /usr/bin, /usr/sbin,
库文件:/lib64, /usr/lib64
配置文件:/etc
帮助文件:manual, info,
分包机制:
testapp-VERSION.tar.gz
核心包:testapp-VERSION
支包:testapp-devel-VERSION
VERSION:major.minor.release
base-4.2.4.tar.gz
rpm包的命名机制:
name-VERSION-RELEASE.ARCH.rpm
zsh-5.0.2-7.el7.x86_64.rpm zsh:包的名字 5.0.2:版本号 7.e17:这个软件包的发行商版本,本包为rhel7或者centos7上使用 x86_64:支持系统硬件平台 rpm:包的类型.rpm是编译好的二进制包,可用rpm命令直接安装;.src.rpm表示是源
bash-devel-4.2.4-1.el7.x86_64.rpm
devel:为开发版本 除此之外,还有其他的几个参数选项: noarch:说明这样的软件包可以在任何平台上安装,不需要特定的硬件平台。在任何硬件平台上都可以运行。 manual 手册文档。
RELEASE: rpm release
包和包之间:有可能存在依赖关系:
X --> Y x包是Y包安装的先决条件
[root@bogon Packages]# rpm -ivh samba-python-4.1.12-21.el7_1.x86_64.rpm warning: samba-python-4.1.12-21.el7_1.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY error: Failed dependencies: samba = 4.1.12-21.el7_1 is needed by samba-python-0:4.1.12-21.el7_1.x86_64 [root@bogon Packages]# [root@bogon Packages]# rpm -ivh samba-4.1.12-21.el7_1.x86_64.rpm warning: samba-4.1.12-21.el7_1.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY Preparing... ################################# [100%] Updating / installing... 1:samba-0:4.1.12-21.el7_1 ################################# [100%] [root@bogon Packages]# rpm -ivh samba-python-4.1.12-21.el7_1.x86_64.rpm warning: samba-python-4.1.12-21.el7_1.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY Preparing... ################################# [100%] Updating / installing... 1:samba-python-0:4.1.12-21.el7_1 ################################# [100%] [root@bogon Packages]#
rpm数据库:/var/lib/rpm/
如何获取rpm包:
1、发行版提供的程序包;一般在光盘镜像的Packages文件夹下
[root@bogon Packages]# pwd /home/aa/Packages #home/aa 为我cdrom 的挂载目录
2、Fedora-EPEL ==》自由版本,开源的,网友根据本人自身特点打的个人包
3、项目的官方站点
4、搜索引擎
http://rpmfind.net
http://rpm.pbone.net
http://pkgs.org
CentOS识别光盘用的设备文件:/dev/cdrom
基于rpm命令实现程序包管理:
安装:
rpm {-i|--install} [install-options] PACKAGE_FILE ...
-i:
-v:显示详细过程,-vv, -vvv
-h:每个rpm包都提供一个或多个capabilities
--nodeps:忽略依赖关系安装
--replacepkgs:重装程序包
[root@bogon Packages]# rpm -e samba-client [root@bogon Packages]# rpm -ivh samba-client-4.1.12-21.el7_1.x86_64.rpm --nodes rpm: --nodes: unknown option [root@bogon Packages]# rpm -ivh samba-client-4.1.12-21.el7_1.x86_64.rpm --nodeps warning: samba-client-4.1.12-21.el7_1.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY Preparing... ################################# [100%] Updating / installing... 1:samba-client-0:4.1.12-21.el7_1 ################################# [100%] [root@bogon Packages]# grep -qa samba-client ^C [root@bogon Packages]# rpm -qa|grep samba-client samba-client-4.1.12-21.el7_1.x86_64 [root@bogon Packages]# rpm -ivh samba-client-4.1.12-21.el7_1.x86_64.rpm --replacepkgs warning: samba-client-4.1.12-21.el7_1.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY Preparing... ################################# [100%] Updating / installing... 1:samba-client-0:4.1.12-21.el7_1 ################################# [100%] [root@bogon Packages]#
升级:
rpm {-U|--upgrade} [install-options] PACKAGE_FILE ...
rpm {-F|--freshen} [install-options] PACKAGE_FILE ...
-Uvh: 如果有旧版程序包,则升级之;如果没有,则安装之;
-Fvh: 如果有旧版程序包,则升级之;如果没有,则不安装;
--nodeps
--oldpackage:降级;
--force:
卸载:
rpm {-e|--erase} [--nodeps] [--noscripts] [--notriggers] [--test] PACKAGE_NAME ...
查询:
rpm {-q|--query} [select-options] [query-options]
查询选项:
-qa: 查询本机已经安装的所有程序包;
[root@localhost Packages]# rpm -qa vsftpd vsftpd-3.0.2-9.el7.x86_64 [root@localhost Packages]#
-qf /PATH/TO/SOMEFILE: 查询此处的文件由哪个程序包安装生成;
-qc: 查询指定程序包安装生成的配置文件
[root@localhost Packages]# rpm -qc vsftpd /etc/logrotate.d/vsftpd /etc/pam.d/vsftpd /etc/vsftpd/ftpusers /etc/vsftpd/user_list /etc/vsftpd/vsftpd.conf
-qd: 查询指定的程序包安装生成的文档
[root@localhost Packages]# rpm -qd vsftpd /usr/share/doc/vsftpd-3.0.2/AUDIT /usr/share/doc/vsftpd-3.0.2/BENCHMARKS /usr/share/doc/vsftpd-3.0.2/BUGS /usr/share/doc/vsftpd-3.0.2/COPYING /usr/share/doc/vsftpd-3.0.2/Changelog /usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE/README /usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE/README.configuration /usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE/vsftpd.conf /usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE/vsftpd.xinetd /usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE_NOINETD/README /usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE_NOINETD/README.configuration /usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE_NOINETD/vsftpd.conf /usr/share/doc/vsftpd-3.0.2/EXAMPLE/PER_IP_CONFIG/README /usr/share/doc/vsftpd-3.0.2/EXAMPLE/PER_IP_CONFIG/README.configuration /usr/share/doc/vsftpd-3.0.2/EXAMPLE/PER_IP_CONFIG/hosts.allow /usr/share/doc/vsftpd-3.0.2/EXAMPLE/README /usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_HOSTS/README /usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS/README /usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS/README.configuration /usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS/logins.txt /usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS/vsftpd.conf /usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS/vsftpd.pam /usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS_2/README /usr/share/doc/vsftpd-3.0.2/FAQ /usr/share/doc/vsftpd-3.0.2/INSTALL /usr/share/doc/vsftpd-3.0.2/LICENSE /usr/share/doc/vsftpd-3.0.2/README /usr/share/doc/vsftpd-3.0.2/README.security /usr/share/doc/vsftpd-3.0.2/REWARD /usr/share/doc/vsftpd-3.0.2/SECURITY/DESIGN /usr/share/doc/vsftpd-3.0.2/SECURITY/IMPLEMENTATION /usr/share/doc/vsftpd-3.0.2/SECURITY/OVERVIEW /usr/share/doc/vsftpd-3.0.2/SECURITY/TRUST /usr/share/doc/vsftpd-3.0.2/SIZE /usr/share/doc/vsftpd-3.0.2/SPEED /usr/share/doc/vsftpd-3.0.2/TODO /usr/share/doc/vsftpd-3.0.2/TUNING /usr/share/doc/vsftpd-3.0.2/vsftpd.xinetd /usr/share/man/man5/vsftpd.conf.5.gz /usr/share/man/man8/vsftpd.8.gz
-qi: 查询指定的程序包的相关信息;
[root@localhost Packages]# rpm -qi vsftpd Name : vsftpd Version : 3.0.2 Release : 9.el7 Architecture: x86_64 Install Date: Sun 13 Sep 2015 01:41:34 PM CST Group : System Environment/Daemons Size : 351462 License : GPLv2 with exceptions Signature : RSA/SHA256, Thu 03 Apr 2014 05:54:58 AM CST, Key ID 199e2f91fd431d51 Source RPM : vsftpd-3.0.2-9.el7.src.rpm Build Date : Fri 07 Mar 2014 05:58:22 PM CST Build Host : x86-025.build.eng.bos.redhat.com Relocations : (not relocatable) Packager : Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla> Vendor : Red Hat, Inc. URL : https://security.appspot.com/vsftpd.html Summary : Very Secure Ftp Daemon Description : vsftpd is a Very Secure FTP daemon. It was written completely from scratch.
-ql: 查询程序包安装生成的所有文件的列表;
[root@localhost Packages]# rpm -ql vsftpd /etc/logrotate.d/vsftpd /etc/pam.d/vsftpd /etc/vsftpd /etc/vsftpd/ftpusers /etc/vsftpd/user_list /etc/vsftpd/vsftpd.conf /etc/vsftpd/vsftpd_conf_migrate.sh /usr/lib/systemd/system-generators/vsftpd-generator /usr/lib/systemd/system/vsftpd.service /usr/lib/systemd/system/vsftpd.target /usr/lib/systemd/system/[email protected] /usr/sbin/vsftpd /usr/share/doc/vsftpd-3.0.2 /usr/share/doc/vsftpd-3.0.2/AUDIT /usr/share/doc/vsftpd-3.0.2/BENCHMARKS /usr/share/doc/vsftpd-3.0.2/BUGS /usr/share/doc/vsftpd-3.0.2/COPYING /usr/share/doc/vsftpd-3.0.2/Changelog /usr/share/doc/vsftpd-3.0.2/EXAMPLE /usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE /usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE/README /usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE/README.configuration /usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE/vsftpd.conf /usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE/vsftpd.xinetd /usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE_NOINETD /usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE_NOINETD/README /usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE_NOINETD/README.configuration /usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE_NOINETD/vsftpd.conf /usr/share/doc/vsftpd-3.0.2/EXAMPLE/PER_IP_CONFIG /usr/share/doc/vsftpd-3.0.2/EXAMPLE/PER_IP_CONFIG/README /usr/share/doc/vsftpd-3.0.2/EXAMPLE/PER_IP_CONFIG/README.configuration /usr/share/doc/vsftpd-3.0.2/EXAMPLE/PER_IP_CONFIG/hosts.allow /usr/share/doc/vsftpd-3.0.2/EXAMPLE/README /usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_HOSTS /usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_HOSTS/README /usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS /usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS/README /usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS/README.configuration /usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS/logins.txt /usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS/vsftpd.conf /usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS/vsftpd.pam /usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS_2 /usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS_2/README /usr/share/doc/vsftpd-3.0.2/FAQ /usr/share/doc/vsftpd-3.0.2/INSTALL /usr/share/doc/vsftpd-3.0.2/LICENSE /usr/share/doc/vsftpd-3.0.2/README /usr/share/doc/vsftpd-3.0.2/README.security /usr/share/doc/vsftpd-3.0.2/REWARD /usr/share/doc/vsftpd-3.0.2/SECURITY /usr/share/doc/vsftpd-3.0.2/SECURITY/DESIGN /usr/share/doc/vsftpd-3.0.2/SECURITY/IMPLEMENTATION /usr/share/doc/vsftpd-3.0.2/SECURITY/OVERVIEW /usr/share/doc/vsftpd-3.0.2/SECURITY/TRUST /usr/share/doc/vsftpd-3.0.2/SIZE /usr/share/doc/vsftpd-3.0.2/SPEED /usr/share/doc/vsftpd-3.0.2/TODO /usr/share/doc/vsftpd-3.0.2/TUNING /usr/share/doc/vsftpd-3.0.2/vsftpd.xinetd /usr/share/man/man5/vsftpd.conf.5.gz /usr/share/man/man8/vsftpd.8.gz /var/ftp /var/ftp/pub
-q --scripts:查询程序包相关的脚本:
preinstall: 安装前脚本
postinstall:安装后脚本
preuninstall: 卸载前脚本
postuninstall: 卸载后脚本
-p: 查询针对是未安装的程序包文件;
校验:
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
[root@localhost Packages]# rpm --verify vsftpd [root@localhost Packages]# rpm -ql vsftpd /etc/logrotate.d/vsftpd /etc/pam.d/vsftpd /etc/vsftpd /etc/vsftpd/ftpusers /etc/vsftpd/user_list /etc/vsftpd/vsftpd.conf /etc/vsftpd/vsftpd_conf_migrate.sh /usr/lib/systemd/system-generators/vsftpd-generator /usr/lib/systemd/system/vsftpd.service /usr/lib/systemd/system/vsftpd.target /usr/lib/systemd/system/[email protected] /usr/sbin/vsftpd /usr/share/doc/vsftpd-3.0.2 /usr/share/doc/vsftpd-3.0.2/AUDIT /usr/share/doc/vsftpd-3.0.2/BENCHMARKS /usr/share/doc/vsftpd-3.0.2/BUGS /usr/share/doc/vsftpd-3.0.2/COPYING /usr/share/doc/vsftpd-3.0.2/Changelog /usr/share/doc/vsftpd-3.0.2/EXAMPLE /usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE /usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE/README /usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE/README.configuration /usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE/vsftpd.conf /usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE/vsftpd.xinetd /usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE_NOINETD /usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE_NOINETD/README /usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE_NOINETD/README.configuration /usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE_NOINETD/vsftpd.conf /usr/share/doc/vsftpd-3.0.2/EXAMPLE/PER_IP_CONFIG /usr/share/doc/vsftpd-3.0.2/EXAMPLE/PER_IP_CONFIG/README /usr/share/doc/vsftpd-3.0.2/EXAMPLE/PER_IP_CONFIG/README.configuration /usr/share/doc/vsftpd-3.0.2/EXAMPLE/PER_IP_CONFIG/hosts.allow /usr/share/doc/vsftpd-3.0.2/EXAMPLE/README /usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_HOSTS /usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_HOSTS/README /usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS /usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS/README /usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS/README.configuration /usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS/logins.txt /usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS/vsftpd.conf /usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS/vsftpd.pam /usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS_2 /usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS_2/README /usr/share/doc/vsftpd-3.0.2/FAQ /usr/share/doc/vsftpd-3.0.2/INSTALL /usr/share/doc/vsftpd-3.0.2/LICENSE /usr/share/doc/vsftpd-3.0.2/README /usr/share/doc/vsftpd-3.0.2/README.security /usr/share/doc/vsftpd-3.0.2/REWARD /usr/share/doc/vsftpd-3.0.2/SECURITY /usr/share/doc/vsftpd-3.0.2/SECURITY/DESIGN /usr/share/doc/vsftpd-3.0.2/SECURITY/IMPLEMENTATION /usr/share/doc/vsftpd-3.0.2/SECURITY/OVERVIEW /usr/share/doc/vsftpd-3.0.2/SECURITY/TRUST /usr/share/doc/vsftpd-3.0.2/SIZE /usr/share/doc/vsftpd-3.0.2/SPEED /usr/share/doc/vsftpd-3.0.2/TODO /usr/share/doc/vsftpd-3.0.2/TUNING /usr/share/doc/vsftpd-3.0.2/vsftpd.xinetd /usr/share/man/man5/vsftpd.conf.5.gz /usr/share/man/man8/vsftpd.8.gz /var/ftp /var/ftp/pub [root@localhost Packages]# vi /etc/vsftpd/user_list [root@localhost Packages]# rpm --verify vsftpd S.5....T. c /etc/vsftpd/user_list
包校验:
来源合法性验正:非对称加密
完整性验正:单向加密
导入密钥:rpm --import /PATH/TO/KEY_FILE
校验:rpm -K /PATH/TO/RPM_FILE
YUM: Yellowdog Updater Modified
yum repositories:
文件服务器:
ftp://hostname/PATH/TO/REPO
http://hostname/PATH/TO/REPO
file:///PATH/TO/REPO
yum程序的配置文件:
/etc/yum.conf
定义全局配置:对所有仓库都适用的配置
[root@iZ28qzns9m4Z ~]# vim /etc/yum.conf [main] cachedir=/var/cache/yum/$basearch/$releasever #yum缓存的目录,yum在此存储下载的rpm包和数据库 keepcache=0 #缓存是否保存,1保存,0不保存。 debuglevel=2 #除错级别,0──10,默认是2 logfile=/var/log/yum.log #yum的日志文件,默认是/var/log/yum.log exactarch=1 #在更新的时候,是否允许更新不同版本的RPM包,比如是否在i386上更新i686的RPM包。 obsoletes=1 #这是一个update的参数,允许更新陈旧的RPM包。 gpgcheck=1 #是否检查GPG(GNU Private Guard),一种密钥方式签名 plugins=1 #是否允许使用插件,默认是0不允许 installonly_limit=5 #允许保留多少个内核包。 bugtracker_url= #yum的连接地址 distroverpkg=centos-release #密钥
/etc/yum.repos.d/*.repo
一个文件通常用于一个或一组功能相近或相关的仓库
[base-source] #方括号里面的是软件源的名称,将被yum取得并识别 name=CentOS-$releasever - Base Sources #这里也定义了软件 仓库的名称,通常是为了方便阅读配置文件,一般没什么作用,$releasever变量定义了发行版本,通常是8,9,10等数字,以下同 baseurl= #指定一个baseurl(源的镜像服务器地址) gpgcheck=1 #这个选项表示这个repo中下载的rpm将进行gpg的校验,已确定rpm包的来源是有效和安全的 enabled=0 #这个选项表示这个repo中定义的源是启用的,0为禁用 gpgkey= #定义用于校验的gpg密钥,就是数位签章的公钥档所在位置!使用预设值即可
yum命令及参数:
yum [options] [command] [package ...]
命令:
安装:install
[root@localhost Packages]# rpm -e vsftpd warning: /etc/vsftpd/user_list saved as /etc/vsftpd/user_list.rpmsave [root@localhost Packages]# yum install -y vsftp Loaded plugins: langpacks, product-id, subscription-manager This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. No package vsftp available. Error: Nothing to do [root@localhost Packages]# yum install -y vsftp* Loaded plugins: langpacks, product-id, subscription-manager This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. Examining vsftpd-3.0.2-9.el7.x86_64.rpm: vsftpd-3.0.2-9.el7.x86_64 Marking vsftpd-3.0.2-9.el7.x86_64.rpm to be installed Resolving Dependencies There are unfinished transactions remaining. You might consider running yum-complete-transaction, or "yum-complete-transaction --cleanup-only" and "yum history redo last", first to finish them. If those don't work you'll have to try removing/installing packages by hand (maybe package-cleanup can help). --> 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 /vsftpd-3.0.2-9.el7.x86_64 343 k Transaction Summary =========================================================================== Install 1 Package Total size: 343 k Installed size: 343 k 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]#
卸载:remove
[root@localhost ~]# yum remove vsftpd -y Loaded plugins: langpacks, product-id, subscription-manager This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. Resolving Dependencies There are unfinished transactions remaining. You might consider running yum-complete-transaction, or "yum-complete-transaction --cleanup-only" and "yum history redo last", first to finish them. If those don't work you'll have to try removing/installing packages by hand (maybe package-cleanup can help). --> Running transaction check ---> Package vsftpd.x86_64 0:3.0.2-9.el7 will be erased --> Finished Dependency Resolution yum | 4.1 kB 00:00 yum/group_gz | 134 kB 00:00 yum/primary_db | 3.4 MB 00:00 Dependencies Resolved =========================================================================== Package Arch Version Repository Size =========================================================================== Removing: vsftpd x86_64 3.0.2-9.el7 @/vsftpd-3.0.2-9.el7.x86_64 343 k Transaction Summary =========================================================================== Remove 1 Package Installed size: 343 k 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 ~]#
升级:update
[root@localhost Packages]# yum update vsftpd* -y Loaded plugins: langpacks, product-id, subscription-manager This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. Examining vsftpd-3.0.2-9.el7.x86_64.rpm: vsftpd-3.0.2-9.el7.x86_64 vsftpd-3.0.2-9.el7.x86_64.rpm: does not update installed package. No packages marked for update [root@localhost Packages]#
search KEYWORD
list all|installed|availiable
provides /PATH/TO/SOMEFILE: 查询指定文件由哪个包安装生成
重新安装:reinstall
降级:downgrade
清理缓存:clean [ packages | metadata | expire-cache | rpmdb | plugins | all ]
生动生成缓存:makecache
包组:
grouplist
[root@iZ28qzns9m4Z ~]# yum grouplist Loaded plugins: langpacks There is no installed groups file. Maybe run: yum groups mark convert (see man yum) Available environment groups: Minimal Install Compute Node Infrastructure Server File and Print Server MATE Desktop Basic Web Server Virtualization Host Server with GUI GNOME Desktop KDE Plasma Workspaces Development and Creative Workstation Available Groups: CIFS file server Compatibility Libraries Console Internet Tools Desktop Desktop Platform Desktop Platform Development Development Tools Eclipse Educational Software Electronic Lab FCoE Storage Client Fedora Packager General Purpose Desktop Graphical Administration Tools Haskell Legacy UNIX Compatibility Messaging Client Support Messaging Server Support Milkymist MySQL Database client MySQL Database server NFS file server Network Storage Server SNMP Support Scientific Support Security Tools Server Platform Server Platform Development Smart Card Support Storage Availability Tools System Administration Tools System Management TeX support TurboGears application framework Virtualization Web-Based Enterprise Management Xfce iSCSI Storage Client Done [root@iZ28qzns9m4Z ~]#
groupinfo "GRP_NAME"
groupinstall "GRP_NAME"
groupremove "GRP_NAME"
仓库:
repolist [all|enabled|disabled]
repoinfo [all|enabled|disabled]
yum install createrepo
[root@localhost yum.repos.d]# yum install createrepo Loaded plugins: langpacks, product-id, subscription-manager This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. Package createrepo-0.9.9-23.el7.noarch already installed and latest version Nothing to do [root@localhost yum.repos.d]#
createrepo /PATH/TO/RPMFILES/
check-update 检查可提供的包升级 [root@iZ28qzns9m4Z yum.repos.d]# yum check-update Loaded plugins: langpacks NetworkManager.x86_64 1:1.0.0-16.git20150121.b4ea599c.el7_1 updates NetworkManager-glib.x86_64 1:1.0.0-16.git20150121.b4ea599c.el7_1 updates NetworkManager-tui.x86_64 1:1.0.0-16.git20150121.b4ea599c.el7_1 updates abrt.x86_64 2.1.11-22.el7.centos.0.1 updates abrt-addon-ccpp.x86_64 2.1.11-22.el7.centos.0.1 updates abrt-addon-kerneloops.x86_64 2.1.11-22.el7.centos.0.1 updates clean 删除缓存数据 deplist 列出包依赖相关 [root@iZ28qzns9m4Z yum.repos.d]# yum deplist samba Loaded plugins: langpacks package: samba.x86_64 4.1.12-23.el7_1 dependency: /bin/sh provider: bash.x86_64 4.2.46-12.el7 dependency: /usr/sbin/groupadd provider: shadow-utils.x86_64 2:4.1.5.1-18.el7 dependency: libCHARSET3.so()(64bit) provider: samba-libs.x86_64 4.1.12-23.el7_1 erase 移除一个或多个包从你的系统 [root@localhost yum.repos.d]# yum erase samba-client Loaded plugins: fastestmirror, langpacks Resolving Dependencies --> Running transaction check ---> Package samba-client.x86_64 0:4.1.12-21.el7_1 will be erased --> Finished Dependency Resolution Dependencies Resolved =========================================================================== Package Arch Version Repository Size =========================================================================== Removing: samba-client x86_64 4.1.12-21.el7_1 @anaconda 1.3 M Transaction Summary =========================================================================== Remove 1 Package Installed size: 1.3 M Is this ok [y/N]: y Downloading packages: Running transaction check Running transaction test Transaction test succeeded Running transaction Warning: RPMDB altered outside of yum. Erasing : samba-client-4.1.12-21.el7_1.x86_64 1/1 Verifying : samba-client-4.1.12-21.el7_1.x86_64 1/1 Removed: samba-client.x86_64 0:4.1.12-21.el7_1 Complete! groupinfo 显示关于包组的细节 groupinstall 从组里安装软件包到你的系统 grouplist 列出当前的组 groupremove 在一个组中移除包从您的系统 help 显示帮助用法信息 info 显示关于包或一组包的细节信息 [root@localhost yum.repos.d]# yum info samba-client Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirrors.zju.edu.cn * epel: ftp.cuhk.edu.hk * extras: mirrors.cqu.edu.cn * remi-safe: remi.kazukioishi.net * updates: mirrors.pubyun.com Available Packages Name : samba-client Arch : x86_64 Version : 4.1.12 Release : 23.el7_1 Size : 515 k Repo : updates/7/x86_64 Summary : Samba client programs URL : http://www.samba.org/ License : GPLv3+ and LGPLv3+ Description : The samba4-client package provides some SMB/CIFS clients to : complement the built-in SMB/CIFS filesystem in Linux. These : clients allow access of SMB/CIFS shares and printing to : SMB/CIFS printers. install 安装一个或多个软件包在你的系统 list 列出一个包或某组的包 localinstall 安装本地 RPM makecache 生成原数据缓存 provides Find what package provides the given value reinstall 重新安装一个包 repolist 显示软件仓库的配置 resolvedep 决定哪个包提供了给定的依赖 search 查找包细节居给定的字符串 shell 运行交互式的yum shell update 更新一个或多个包在你的系统 upgrade Update packages taking obsoletes into account Options: -h, --help show this help message and exit -t, --tolerant be tolerant of errors -C 从缓冲中运行,而不是升级缓存 -c [config file] config file location -R [minutes] 最大化的命令等待时间 -d [debug level] 调试输出级别 --showduplicates 显示复制, 在repo,list/search命令下 -e [error level] 错误输出级别 -q, --quiet 安静的操作 -v, --verbose verbose operation -y 回答所有的问题为是 --version 显示 YUM版本信息并退出 --installroot=[path] 设置为root安装 --enablerepo=[repo] 激活一个或多个仓库(支持通配符) --disablerepo=[repo] 禁掉一个或多个仓库(支持通配符) -x [package], --exclude=[package] 在名称或glob不包含包。 --disableexcludes=[repo] disable exclude from main, for a repo or for everything --obsoletes enable obsoletes processing during updates --noplugins 禁掉yum插件 --nogpgcheck 禁掉GPG验证检查 --disableplugin=[plugin] 用名称禁掉插件 --enableplugin=[plugin] enable plugins by name --skip-broken 忽略包的依赖问题 --color=COLOR control whether color is used 。。。。内容太多,不在此一一列举
制作一个本地yum 源,最简单的,配置文件如下
[root@localhost ~]# mount /dev/cdrom /mnt/ [root@localhost ~]# cd /mnt/ [root@localhost ~]#cp -r * /home/yum/ [root@localhost ~]#vi /etc/yum.repos.d/yum.repo [root@localhost ~]# cat /etc/yum.repos.d/yum.repo [yum] name=yum baseurl=file:///home/yum/ gpgcheck=0 enable=1 [root@localhost ~]#