- Taken from the Fedora Mailing List Issue 102
Peter A. Shevtsov <[email protected]>: From time to time I install some new software on my computers just to look at it, to try, to see if it is the right tool for me, etc. After reading new articles on Fedora Daily Package I run yum more frequently :)
This software requires some additional packages, libraries, etc. Also, it creates some config files in my home dir. But when I remove the software the redundant packages (libraries) and config files stay in my system. Is there any way to remove theses unused packages and old config files?
By way of answering your question about configuration files, consider that package updates are actually a remove and an install action. If configuration files were included in package removal, instead of sometimes treated specially, then upgrading a package might actually erase the administrator's system configuration! This is obviously not a desirable outcome, so many packages mark their system configuration files in the RPM database so they are not yanked off the system. To see if an installed package has a specially marked configuration file, use the command rpm -qc <package_name>.
If you want to clean your system of packages that are not required by any other software on your system, you can use the package-cleanup script that is part of the 'yum-utils' package. Install 'yum-utils' with the command su -c "yum -y install yum-utils" and then run su -c "package-cleanup --leaves" to see a list of these packages. Note that not every dependency installed during a transaction is necessarily a leaf. A more thorough way to remove packages you installed is by surveying the output of the command rpm -qa --last, which shows you recently installed packages listed by date.
You may also be interested in the repackage option, which you can add to your /etc/yum.conf file to be able to roll back your installed software state. Refer to the Fedora Daily Package site for an excellent explanation of how this feature works.
RPM Commands[edit | edit source]
This document contains an overview of the principal RPM commands for installing, uninstalling, upgrading, querying, listing, and checking RPM packages on your Red Hat Linux system.
rpm -ivh foo-2.0-4.i386.rpm rpm -i ftp://ftp.redhat.com/pub/redhat/RPMS/foo-1.0-1.i386.rpm rpm -i http://oss.oracle.com/projects/firewire/dist/files/kernel-2.4.20-18.10.1.i686.rpm
Used to install a RPM package. Note that RPM packages have file naming conventions like foo-2.0-4.i386.rpm, which include the package name (foo), version (2.0), release (4), and architecture (i386). Also notice that RPM understands FTP and HTTP protocols for installing and querying remote RPM files.
rpm -qa 'postfix*' rpm --verify name-of-package...
You can "verify" if the installed software matches the RPM package.
rpm -e foo
To uninstall a RPM package. Note that we used the package name foo, not the name of the original package file foo-2.0-4.i386.rpm above.
rpm -Uvh foo-1.0-2.i386.rpm rpm -Uvh ftp://ftp.redhat.com/pub/redhat/RPMS/foo-1.0-1.i386.rpm rpm -Uvh http://oss.oracle.com/projects/firewire/dist/files/kernel-2.4.20-18.10.1.i686.rpm
To upgrade a RPM package. Using this command, RPM automatically uninstall the old version of the foo package and install the new package. It is safe to always use rpm -Uvh to install and upgrade packages, since it works fine even when there are no previous versions of the package installed! Also notice that RPM understands FTP and HTTP protocols for upgrading from remote RPM files.
To query all installed packages. This command will print the names of all installed packages installed on your Linux system.
rpm -q foo
To query a RPM package. This command will print the package name, version, and release number of the package foo only if it is installed. Use this command to verify that a package is or is not installed on your Linux system.
rpm -qi foo
To display package information. This command display package information including the package name, version, and description of the installed program. Use this command to get detailed information about the installed package.
rpm -ql foo
To list files in installed package. This command will list all of files in an installed RPM package. It works only when the package is already installed on your Linux system.
rpm -qf /usr/bin/mysql
Which package owns a file? This command checks to determine which installed package a particular file belongs to.
rpm -qpl kernel-2.4.20-18.10.1.i686.rpm rpm -qpl ftp://ftp.redhat.com/pub/redhat/RPMS/foo-1.0-1.i386.rpm rpm -qpl http://oss.oracle.com/projects/firewire/dist/files/kernel-2.4.20-18.10.1.i686.rpm
List files in RPM file. This command allows you to query a (possibly) uninstalled RPM file with the use of the the "-p" option. You can use the "-p" option to operate on an RPM file without actually installing anything. This command lists all files in an RPM file you have in the current directory. Also note that RPM can query remote files through the FTP and HTTP protocols.
rpm --verify mysql
To verify an installed package. This command will list all files that do NOT pass the verify tests (done on size, MD5 signature, etc). Where a file does NOT pass, the output is listed using the following codes that signify what failed:
S File size M Mode (includes permissions and file type) 5 MD5 sum L Symlink D Device U User G Group T Mtime
Take for example the following:
# rpm --verify mysql S.5....T c /etc/my.cnf
This example indicates that file /etc/my.cnf failed on:
File size MD5 Sum Modified Time
However, the "c" tells us this is a configuration file so that explains the changes. It should still be looked at to determine what the changes were.
rpm --checksig foo
To check a RPM signature package. This command checks the PGP signature of specified package to ensure its integrity and origin. Always use this command first before installing a new RPM package on your system. Also, GnuPG or Pgp software must be already installed on your system before you can use this command.