Pacakage Management in Linux
Pacakage Management in Linux
Pacakage Management in Linux
RPM (Redhat package Management) RPM is the most popular of the Linux package managers. It enables you to install, upgrade, uninstall, query, and verify the integrity of packages. RPM works on individual package files whose filenames end in .rpm . These files are compressed archive files, similar to compressed tarballs or zip files, but they include additional data, such as information on dependencies packages upon which the RPM file depends for normal operation. Managing software via RPMs requires using the rpm utility program, which provides commands for installing, removing, and otherwise manipulating packages. Over the past few years, meta-packaging tools, such as the Yellow Dog Updater, Modified (Yum), have been developed. These tools provide a front-end to download and install or update multiple files from network repositories, which greatly simplifies the task of keeping a system up-to-date. Deleting an Unused Package To delete a package, you use the erase (or e ) option to rpm , which takes a package name as an option: # rpm -e vsftpd If the operation completes successfully, you ll see no other messages. If you try to delete a package that s not installed, rpm will tell you so. Similarly, rpm will complain if you try to delete a package that s depended upon by other packages for instance, if you try to delete a library package upon which program packages rely. If you see such a message, you have three choices: Abandon the attempt to delete the package. _ Delete the packages that depend upon the one you re trying to delete. You can add their names to the command line to delete multiple packages at once. You ll need to judge for yourself whether this action is reasonable. _ Use the nodeps option to tell rpm to ignore dependency problems. This option is not generally recommended because it can result in failures when you try to use the packages that depend upon the one you re trying to remove. Upgrading an Existing Package
# rpm -Uvh yum-2.6.1-0.fc5.noarch.rpm
You can install a new package much like you can upgrade an existing one, but you use the -install (-i) operation rather than --upgrade (-U): # rpm -ivh zsh-4.2.5-1.2.2.i386.rpm As with upgrades, you can install directly from an FTP or Web site by passing a complete URL in front of the RPM filename. Many administrators prefer to install software with the --upgrade (-U) operation; if this operation is fed a package filename for a package that isn t already installed, rpm will install it without further comment, aside from its usual dependency checks. This can be handy because you needn t know whether or not a package is already installed and you can mix upgrades and fresh installations on a single command line. Querying a Package If you don t know what a package does, you can use the --query (-q) operation, which takes a package name as an argument. For the operation to be useful, you re likely to specify the -info (-i) or --list (-l) options, which display general information on the package and a list of the files it contains, respectively. To find out what xpdf does, you d use -i: # rpm -qi xpdf Name : xpdf Relocations: (not relocatable) Version : 3.01 Vendor: Red Hat, Inc. Release : 12.1 Build Date: Sun 12 Feb 2006 03:32:24 PM EST Install Date: Tue 27 Jun 2006 06:57:45 PM EDT Build Host: ls20-bc1-13.build.redhat.com Group : Applications/Publishing Source RPM: xpdf-3.01-12.1.src.rpm Size : 7758073 License: GPL Signature : DSA/SHA1, Mon 06 Mar 2006 04:21:30 PM EST, Key ID b44269d04f2a6fd2 Packager : Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla> URL : http://www.foolabs.com/xpdf/ Summary : A PDF file viewer for the X Window System. Description : Xpdf is an X Window System based viewer for Portable Document Format (PDF) files. Xpdf is a small and efficient program which uses standard X fonts. Verifying a Package RPM maintains a database of all the files it s installed from every package it s installed, along with checksum information on these packages. You can use this information to verify a package s integrity with the --verify (-V) operation:
# rpm -V samba .......T /usr/bin/smbcontrol SM5....T /usr/bin/smbstatus missing d /usr/share/doc/samba-3.0.22/htmldocs/using_samba/figs/sam2_0811.gif If the package verifies completely properly, rpm displays no output. If any files don t match what Samba has recorded in its database, it displays an eight-character code summarizing the problem (or missing if the file is missing), an optional code reporting the type of file, and the filename. The preceding example output indicates three potential problems with the package: _ The /usr/bin/smbcontrol file s time stamp doesn t match what RPM has recorded, as indicated by the T as the final character of the eight-character code. This usually isn t a major problem; it can happen because of an accidental use of the touch utility against the file or because the file was accidentally moved and then copied back to its original location. _ The /usr/bin/smbstatus file s time stamp doesn t match what RPM has recorded. Furthermore, the file size (S), mode (M), and MD5 sum (5) don t match. In other words, the file has been changed or replaced. Such problems can be caused by disk corruption, security breaches, or legitimate editing or replacement of individual files. Sometimes these issues appear on configuration files. A properly constructed package should flag configuration files as such, and so an RPM verify operation won t report changes, but not all packages are properly constructed in this way. _ The sam2_0811.gif file in a deep Samba documentation directory is missing. This file is flagged as being a documentation file (the d between the eight-character code and the filename). Missing files usually indicate disk corruption, security breaches, or accidental deletions by root. Performing a System Update The ultimate in package updates is using Yum to update every package installed on your system. If your distribution shipped with Yum, chances are it s already configured properly. If not, you can obtain Yum from its home page, http://linux.duke.edu/yum/. Configuring it requires editing /etc/yum.conf or files in /etc/yum.repos.d/ to point to a Yum repository for your distribution. Unfortunately, you ll need to track down distribution-specific instructions on doing this; I can t provide specific instructions. Fortunately, most RPMbased distributions now ship with Yum, so you probably won t have to do this. Once Yum is installed and configured, you can check for system updates by issuing a single command: # yum check-update
Alternatively, if you want to update just a few packages (say, tetex and pam), you can specify them on the command line: # yum -y update tetex pam This command will update just those two packages, plus any packages upon which they depend. If you omit the -y option, Yum asks for confirmation before actually installing any updates. In addition to system updates, you can perform package removals (yum remove packagename), package installations (yum install packagename), and more consult the Yum man page for Yum will check the repository sites and report on any packages for which updates are available. This operation can take several seconds to several minutes, depending on the speed of your Internet connection and the load on the Yum repositories you end up using. If you want to install all of the available updates, you can do so with another command: # yum -y update details. In fact, you can do just about all of your package maintenance using the yum command rather than the rpm command. Yum still relies on RPM to do its dirty work, though, and sometimes using rpm is necessary. For instance, if you want to install a package that you ve obtained from a source other than a Yum repository, you must use rpm or some other derivative tool, such as a GUI front end to rpm. One potential problem with Yum is that it downloads packages to your hard disk and then installs them, but it doesn t automatically delete packages. To ensure that your hard disk doesn t fill up with package files you no longer need, type yum clean packages from time to time. This command removes the package files on a one-time basis.