使用search命令可以搜索软件包:
$ yum search mysql ##search SOME_STRING ... ... mysql.x86_64 : MySQL client programs and shared libraries mysql-bench.x86_64 : MySQL benchmark scripts and data mysql-connector-java.x86_64 : Official JDBC driver for MySQL mysql-connector-odbc.x86_64 : ODBC driver for MySQL mysql-devel.i686 : Files for development of MySQL applications mysql-devel.x86_64 : Files for development of MySQL applications mysql-server.x86_64 : The MySQL server and related files mysql-test.x86_64 : The test suite distributed with MySQL ... ...
使用info命令可以查询软件包的详细信息:
$yum info mysql-server ##info [PACKAGE|all|installed|updates|extras|obsoletes|recent]
... ... Installed Packages Name : mysql Arch : x86_64 Version : 5.1.52 Release : 1.el6_0.1 Size : 2.4 M Repo : installed From repo : base Summary : MySQL client programs and shared libraries URL : http://www.mysql.com License : GPLv2 with exceptions Description : MySQL is a multi-user, multi-threaded SQL database server. MySQL is a : client/server implementation consisting of a server daemon (mysqld) : and many different client programs and libraries. The base package : contains the standard MySQL client programs and generic MySQL files. Available Packages Name : mysql Arch : x86_64 Version : 5.1.61 Release : 1.el6_2.1 Size : 881 k Repo : updates Summary : MySQL client programs and shared libraries URL : http://www.mysql.com License : GPLv2 with exceptions Description : MySQL is a multi-user, multi-threaded SQL database server. MySQL is a : client/server implementation consisting of a server daemon (mysqld) : and many different client programs and libraries. The base package : contains the standard MySQL client programs and generic MySQL files.
使用deplist命令可以检查软件包的依赖关系:
$ yum deplist mysql ##deplist PACKAGE... ... ... package: mysql.x86_64 5.1.61-1.el6_2.1 dependency: perl(File::Temp) provider: perl.x86_64 4:5.10.1-119.el6_1.1 dependency: libc.so.6(GLIBC_2.3.4)(64bit) provider: glibc.x86_64 2.12-1.47.el6 provider: glibc.x86_64 2.12-1.47.el6_2.9 provider: glibc.x86_64 2.12-1.47.el6_2.12 provider: glibc.x86_64 2.12-1.47.el6_2.5 dependency: grep provider: grep.x86_64 2.6.3-2.el6 ... ...
使用update命令可以升级已经安装的软件包:
$ yum update mysql-server ##update [PACKAGE...]
... ... Setting up Update Process Resolving Dependencies --> Running transaction check ---> Package mysql-server.x86_64 0:5.1.52-1.el6_0.1 will be updated ---> Package mysql-server.x86_64 0:5.1.61-1.el6_2.1 will be an update --> Processing Dependency: mysql = 5.1.61-1.el6_2.1 for package: mysql-server-5.1.61-1.el6_2.1.x86_64 --> Running transaction check ---> Package mysql.x86_64 0:5.1.52-1.el6_0.1 will be updated ---> Package mysql.x86_64 0:5.1.61-1.el6_2.1 will be an update --> Processing Dependency: mysql-libs = 5.1.61-1.el6_2.1 for package: mysql-5.1.61-1.el6_2.1.x86_64 --> Running transaction check ---> Package mysql-libs.x86_64 0:5.1.52-1.el6_0.1 will be updated ---> Package mysql-libs.x86_64 0:5.1.61-1.el6_2.1 will be an update --> Finished Dependency Resolution Dependencies Resolved ============================================================================================================ Package Arch Version Repository Size ============================================================================================================ Updating: mysql-server x86_64 5.1.61-1.el6_2.1 updates 8.1 M Updating for dependencies: mysql x86_64 5.1.61-1.el6_2.1 updates 881 k mysql-libs x86_64 5.1.61-1.el6_2.1 updates 1.2 M Transaction Summary ============================================================================================================ Upgrade 3 Package(s)
... ...
使用check-update命令可以检查软件包的升级信息:
$ yum check-update ##check-update [PACKAGE...] ... ... bash.x86_64 4.1.2-9.el6_2 updates bind-libs.x86_64 32:9.7.3-8.P3.el6_2.3 updates bind-utils.x86_64 32:9.7.3-8.P3.el6_2.3 updates chkconfig.x86_64 1.3.49.3-1.el6_2 updates cups.x86_64 1:1.4.2-44.el6_2.3 updates ... ...
使用erase命令可以移除安装的软件包:
$ yum erase mysql mysql-server ##erase PACKAGE... ... ... ============================================================================================================ Package Arch Version Repository Size ============================================================================================================ Removing: mysql x86_64 5.1.61-1.el6_2.1 @updates 2.4 M mysql-server x86_64 5.1.61-1.el6_2.1 @updates 23 M Removing for dependencies: akonadi x86_64 1.2.1-2.el6 @base/$releasever 1.8 M kdepim x86_64 6:4.3.4-5.el6 @base/$releasever 21 M kdepim-libs x86_64 6:4.3.4-5.el6 @base/$releasever 20 M kdepim-runtime x86_64 4.3.4-5.el6 @base/$releasever 3.2 M kdepim-runtime-libs x86_64 4.3.4-5.el6 @base/$releasever 834 k kdepimlibs-akonadi x86_64 4.3.4-4.el6 @base/$releasever 1.2 M ... ...
使用list命令可以查询已经安装的软件包:
$yum list mysql* ##list [PACKAGE|all|installed|updates|extras|obsoletes|recent] Installed Packages mysql.x86_64 5.1.61-1.el6_2.1 @updates mysql-libs.x86_64 5.1.61-1.el6_2.1 @updates mysql-server.x86_64 5.1.61-1.el6_2.1 @updates Available Packages MySQL-python.x86_64 1.2.3-0.3.c1.1.el6 base mysql-bench.x86_64 5.1.61-1.el6_2.1 updates mysql-connector-java.x86_64 1:5.1.12-2.el6 base mysql-connector-odbc.x86_64 5.1.5r1144-7.el6 base mysql-devel.i686 5.1.61-1.el6_2.1 updates mysql-devel.x86_64 5.1.61-1.el6_2.1 updates mysql-embedded.i686 5.1.61-1.el6_2.1 updates mysql-embedded.x86_64 5.1.61-1.el6_2.1 updates mysql-embedded-devel.i686 5.1.61-1.el6_2.1 updates mysql-embedded-devel.x86_64 5.1.61-1.el6_2.1 updates mysql-libs.i686 5.1.61-1.el6_2.1 updates mysql-test.x86_64 5.1.61-1.el6_2.1 updates
使用repolist命令可以查询系统安装的软件库:
$ yum repolist all ##repolist [all|enabled|disabled] ... ... repo id repo name status base CentOS-6 - Base enabled: 6,294 c6-media CentOS-6 - Media disabled centosplus CentOS-6 - Plus disabled contrib CentOS-6 - Contrib disabled debug CentOS-6 - Debuginfo disabled extras CentOS-6 - Extras enabled: 6 testing CentOS-6 - Testing disabled updates CentOS-6 - Updates enabled: 1,147 repolist: 7,447
使用grouplist命令可以列出所有可用的软件包组:
$ yum grouplist ... ... Installed Groups: Additional Development Base Debugging Tools ... ... Installed Language Groups: Arabic Support [ar] Armenian Support [hy] Assamese Support [as] ... ... Available Groups: Backup Client Backup Server CIFS file server ... ... Available Language Groups: Afrikaans Support [af] Albanian Support [sq] Amazigh Support [ber] ... ...
使用groupinfo命令可以查询软件包组的详细信息:
$ yum groupinfo "FTP Server"
... ... Group: FTP server Description: Allows the system to act as an FTP server. Mandatory Packages: vsftpd Optional Packages: xferstats
安装某个软件包:
$ rpm –ivh portmap-4.0-54.i386.rpm
查询软件包是否已经安装:
$ rpm -q openssh openssh-5.3p1-70.el6.x86_64
查询所有已安装的软件包:
$ rpm -qa
... ... openssh-5.3p1-81.el6.x86_64 openssh-server-5.3p1-81.el6.x86_64 libssh2-1.2.2-11.el6_3.x86_64
... ...
查询软件包详细信息:
]$ rpm -qi openssh Name : openssh Relocations: (not relocatable) Version : 5.3p1 Vendor: CentOS Release : 70.el6 Build Date: Thu 08 Dec 2011 04:25:12 AM CST Install Date: Sat 11 Aug 2012 03:57:26 PM CST Build Host: c6b18n2.bsys.dev.centos.org Group : Applications/Internet Source RPM: openssh-5.3p1-70.el6.src.rpm Size : 679713 License: BSD ... ...
查询软件包所有文件:
$ rpm -ql openssh /etc/ssh /etc/ssh/moduli /usr/bin/ssh-keygen /usr/libexec/openssh /usr/libexec/openssh/ssh-keysign /usr/share/doc/openssh-5.3p1 /usr/share/doc/openssh-5.3p1/CREDITS /usr/share/doc/openssh-5.3p1/ChangeLog /usr/share/doc/openssh-5.3p1/INSTALL /usr/share/doc/openssh-5.3p1/LICENCE ... ...
查询软件包所有文档:
$ rpm -qd openssh /usr/share/doc/openssh-5.3p1/CREDITS /usr/share/doc/openssh-5.3p1/ChangeLog /usr/share/doc/openssh-5.3p1/INSTALL /usr/share/doc/openssh-5.3p1/LICENCE /usr/share/doc/openssh-5.3p1/OVERVIEW /usr/share/doc/openssh-5.3p1/PROTOCOL /usr/share/doc/openssh-5.3p1/PROTOCOL.agent /usr/share/doc/openssh-5.3p1/README
查询软件包所有配置:
$ rpm -qc coreutils /etc/DIR_COLORS /etc/DIR_COLORS.256color /etc/DIR_COLORS.lightbgcolor /etc/pam.d/runuser /etc/pam.d/runuser-l /etc/pam.d/su /etc/pam.d/su-l /etc/profile.d/colorls.csh /etc/profile.d/colorls.sh
查询某个文件所在的软件包(必须是绝对路径):
$ rpm -qf /bin/ls coreutils-8.4-16.el6.x86_64
rpm查询命令(-q)加上v参数可以显示长文件信息:
$ rpm -qcv coreutils -rw-r--r-- 1 root root 4439 Apr 28 2010 /etc/DIR_COLORS -rw-r--r-- 1 root root 5139 Apr 28 2010 /etc/DIR_COLORS.256color -rw-r--r-- 1 root root 4113 Apr 28 2010 /etc/DIR_COLORS.lightbgcolor -rw-r--r-- 1 root root 143 Feb 14 2007 /etc/pam.d/runuser -rw-r--r-- 1 root root 105 Feb 14 2007 /etc/pam.d/runuser-l -rw-r--r-- 1 root root 487 Feb 14 2007 /etc/pam.d/su -rw-r--r-- 1 root root 137 Feb 14 2007 /etc/pam.d/su-l -rw-r--r-- 1 root root 1133 Apr 28 2010 /etc/profile.d/colorls.csh -rw-r--r-- 1 root root 1143 Apr 28 2010 /etc/profile.d/colorls.sh
删除某个软件包,但不删除以来它的软件包:
$ rpm -ev --nodeps httpd