CentOS package management

Frequently used tasks:


Query what packages are installed:

rpm -qa | sort

Query when they were installed:

rpm -qa -last | tac

Query an RPM file which is not installed:

rpm -qpi cfengine-2.1.22-1.el4.rf.x86_64.rpm

Query what files will be installed by a package:

rpm -qpl cfengine-2.1.22-1.el4.rf.x86_64.rpm

Examine the dependencies of cfengine (-R stands for “Requires”)

rpm -qpR cfengine-2.1.22-1.el4.rf.x86_64.rpm

Find out to which package file /etc/passwd belongs:

rpm -qf /etc/passwd

Query what files have been installed by a package:

rpm -ql cfengine-2.1.22-1.el4.rf.x86_64.rpm

Install a package:

rpm -ivh cfengine-2.1.22-1.el4.rf.x86_64.rpm

Update a package:

rpm -Uvh package.rpm

Keys and signatures

To use packages from other repositories than the official ones you will have to import their gpg-keys:

rpm --import RPM-GPG-KEY.txt 

Display all currently imported keys:

rpm -qa gpg-pubkey*

Query an imported key in detail:

rpm -qi gpg-pubkey-db42a60e

Erase an imported key:

rpm -e gpg-pubkey-db42a60e

Check the integrity and origin of a package:

rpm --checksig package.rpm


Needful options:

# Output a list of packages available for updates, and all the dependencies 
# they need, including  obsoletes

# Queries the RHN servers to resolve the comma separated list of dependencies. 
# It will return a list of packages that will satisfy these dependencies
# up2date --whatprovides "/etc/motd"
# Output: setup-2.5.37-1.7.noarch

Install or update a package:

up2date packagename

Download package, but do not install:

up2date --download packagename

Show all available packages:

up2date --showall

Display list of available updated packages:

up2date -l

Update packages with (security) updates:

up2date -u

Force update:

up2date -uf

Show channels we are subscribed to:

up2date --show-channels

files/directories (valid for RHEL 4):

  • /etc/sysconfig/rhn/up2date - Configuration settings for Update Agent
  • /etc/sysconfig/rhn/sources - Configuration settings for external package repositories
  • /var/spool/up2date - The spool directory where RPM/up2date stores package lists, package headers and packages
  • /var/log/up2date - This is the log file for up2date


See http://www.centos.org/docs/5/html/yum/index.html

Show all available packages:

yum list available

Show upgradable packages:

yum list upgradable

Show all installed packages:

yum list installed

Install a packages:

yum install packagename

Remove a package:

yum remove packagename

Update a package:

yum update packagename

Upgrade the whole system:

yum upgrade

Cleanup downloaded packages:

yum clean packages

Exclude some packages during update:

yum --exclude=kernel* update

or add to /etc/yum.conf:


exclude=kernel* php*

Upgrade CentOS

Taken from the CentOS announce mailing list

Upgrading from CentOS-5.2 ( or CentOS-5.0 / 5.1 ):

If you are already running CentOS-5.2 or an older CentOS-5 distro, all you need to do is update your machine via yum by running :

'yum update'

Running 'yum list updates' before doing the update is recommended, so you can get a list of packages that are going to be updated. To check you are indeed on CentOS-5.3, run : 'rpm -q centos-release' and that should return: 'centos-release-5-3.el5.centos.1'

centos/packagemanagement.txt · Last modified: 2009-08 by tb
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0 ipv6 ready