Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 30 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
30
Dung lượng
663,1 KB
Nội dung
The -g and -u options have the meaning shown in Table 29-6. Specifying -s tells quota to use more understandable units for displaying disk usage and limits. For example, the following command shows bubba’s quota statistics: # quota -s bubba Disk quotas for user bubba (uid 502): Filesystem blocks quota limit grace files quota limit grace /dev/hdb1 2168* 2000 2025 29 0 0 To see a complete list of quota statistics for all users and groups for a file sys- tem, use the repquota program, which accepts the same options as quota but requires a file system argument rather than a user argument. You can use the -a option to see a report for all file systems on which quotas are being used. The following command shows a repquota report for /dev/hdb1, using the -s option to display the output in units of megabytes: # repquota -s /dev/hdb1 *** Report for user quotas on device /dev/hdb1 Block grace time: 14days; Inode grace time: 14days Block limits File limits User used soft hard grace used soft hard grace root 34088 0 0 3 0 0 bubba +- 2168 2000 2025 13days 29 0 0 Summary This chapter briefly recapped the power of the root account on a Red Hat Enterprise Linux system and showed you how to delegate some of that power to nonroot users using Sudo. You also learned to create and manage user and group accounts using a variety of command line utilities and User Manager graphical administration tool. Finally, you read about how to prevent users and groups from monopolizing disk space and how to monitor system disk space utilization using the quota suite of programs. 744 Chapter 29 37_599496 ch29.qxd 8/30/05 7:20 PM Page 744 745 Installing and Upgrading Software Packages IN THIS CHAPTER ■■ Using the Red Hat Package Manager ■■ Checking Software Versions ■■ Obtaining Newer Software ■■ Installing Software from Source One of Linux’s best qualities is the amount of software available for it. Even novice Linux users can download and install new or updated software with little or no difficulty using RPM, the Red Hat Package Manager. Blindly installing software, even on an RPM-based system, may cause problems, though, and in general the more you understand about software installation and maintenance, the more comfortable you will be with the process. This chapter describes how to use RPM and to keep Fedora Core and RHEL-based systems current vis-à-vis updated packages and security patches. It also describes how to use the current version of RPM to add, remove, upgrade, and query software packages. Finally, it briefly describes the process of configuring and installing software from source code. Using the Red Hat Package Manager RPM is a powerful software configuration manager and the preferred tool for installing, removing, verifying, and updating software packages on Fedora Core and RHEL systems. This section describes how to use most RPM features. Later sections cover some topics in detail, though, so they are mentioned only briefly in this one. Most examples illustrate command line usage, but some show how to use Package Manager, a graphical RPM front-end application. CHAPTER 30 38_599496 ch30.qxd 8/30/05 7:36 PM Page 745 RPM consists of two components: a set of databases that store information about installed software and the programs that interface with the databases. RPM can work with binary and source packages. Binary packages, referred to simply as RPMs, contain compiled software ready for installation. They use the file extension .rpm. Source packages, more often called source RPMs or SRPMs, are uncompiled packages containing source code, patches, and build instructions, all of which are used to create binary RPMs. SRPMs have a .src.rpm file extension. Because RPM offers a rich feature set that makes it seem complex and difficult to learn to use, the following sections each explore one of RPM’s modes, in order to simplify the discussion: ■■ General options ■■ Querying ■■ Package maintenance ■■ Administrative options ■■ Miscellaneous options ■■ Package verification The general options control the overall behavior of the rpm command line tool, such as displaying basic usage information. The query functions can be used to obtain a considerable amount of information about installed software. Package maintenance enables package installation, removal, and upgrading. Package verification gives system administrators the ability to compare the present state of files installed by an RPM against information taken from the original package. The package-building mode is used to build or rebuild RPMs from source code. The administration and miscellaneous modes, finally, affect RPM itself, rather than software packages. They are used to fix possible database corruption and to determine RPM’s general configuration. General Options At the command line, the primary RPM command is rpm. In addition to the mode-specific command line options discussed in the following sections, rpm accepts the general command line options listed in Table 30-1. Table 30-1 General RPM Command Line Options OPTION DESCRIPTION -v Displays basic information about the RPM operation’s status -vv Displays debugging information. Most useful to software packagers and RPM developers 746 Chapter 30 38_599496 ch30.qxd 8/30/05 7:36 PM Page 746 Table 30-1 (continued) OPTION DESCRIPTION quiet Displays only error information help Shows a usage summary test Performs a “dry run” of the requested operation without actually modifying the file system or the RPM database version Shows the RPM version number justdb Updates only the database, not the file system The -vv option may prove useful when troubleshooting package installa- tion or removal that fails, but be prepared to sort through voluminous and cryptic-looking output to find the information you need. justdb is used to help repair the database. The results of any operation, such as installing or removing an RPM, affect only RPM’s databases; no files are added to or removed from the file system. test makes it possible to see if a command will succeed without actually changing anything. For example, the following command uses test to delete the whois package from RPM’s database without actually deleting the files: # rpm test -e jwhois # rpmquery jwhois jwhois-3.2.2-14 # ls -l /usr/bin/jwhois -rwxr-xr-x 1 root root 57040 Nov 9 21:28 /usr/bin/jwhois The first command deletes the jwhois package but, because the test was specified, the package wasn’t actually deleted. The second command uses the rpmquery command to see if the jwhois RPM is installed. As you can see, the package is still installed. NOTE The rpm command supports more options than those listed in Table 30-1. To simplify the discussion, this chapter examines only the most common and helpful options. One common use of justdb is to remove an RPM’s entry from the data- base after the package has been upgraded using a non-RPM source, such as a tarball. In such cases, the RPM entry is invalid and needs to be removed with- out deleting the installed files. The most common use of justdb is to repair the RPM database if it becomes corrupted. Installing and Upgrading Software Packages 747 38_599496 ch30.qxd 8/30/05 7:36 PM Page 747 Query Mode RPM’s query mode is one of its most powerful and useful features. The general form of an RPM query is: rpmquery [query_opts] rpmquery (or, if you prefer the old style, rpm -q or rpm query) specifies a query operation and query_opts specifies what to query, the type of query, how the query should run, or the format of its output. You can use the com- mand rpmquery in place of rpm -q or rpm query. Most commonly, queries use the following general syntax: rpmquery [query_opts] package [ ] package names the RPM to query. Query multiple RPMs using a space- separated list of package names. Query mode’s power comes at the cost of a long list of options for the query_opts argument. The options fall into two broad categories. One group, referred to as package selection options, controls which package or packages to query, and the other, known as output selection options, defines what information to display. Table 30-2 lists many but not all of the options available in query mode. The Type column uses S to mark a package selection option and I to mark an information selection option. Unless men- tioned otherwise, all options require at least one package name as an argument. Table 30-2 RPM Query Mode Options OPTION TYPE DESCRIPTION -a S Queries all installed RPMs. Does not require a package specification. -c I Lists only the configuration files stored in the queried RPM(s). changelog I Displays change information about the queried RPM(s). -d I Lists only the documentation files stored in the RPM. dump I For each file stored in the queried RPM(s), displays its path, size, modification time, MD5 checksum, permissions, owner, group, and whether it is a configuration file, documentation file, a device, or a symlink (must be used with -l, -c, or -d). 748 Chapter 30 38_599496 ch30.qxd 8/30/05 7:36 PM Page 748 Table 30-2 (continued) OPTION TYPE DESCRIPTION -f file S Queries the RPM that owns file. Does not require a package specification. -g group S Lists the packages in the RPM group named group. Does not require a package specification. -i I Displays complete information about the queried RPM(s). -l I Lists all of the files stored in the RPM. last I Displays the installation date and time of each RPM queried, starting with the most recently installed RPM. -p package [ ] S Queries the uninstalled RPM named package. provides I Lists all of the capabilities the queried RPM(s) provides. qf ‘ I Creates a customized output format for displayed format_str’ information, using format_str as the model. querytags I Prints all known tags for use with the qf option. Does not require a package specification. requires I Lists all RPMs on which the package depends. -s I For each file in the original RPM, displays its state, which is one of normal, not installed, or replaced. whatprovides S Queries all RPMs that provide capability. capability whatrequires S Queries all RPMs that need capability in order capability to function properly. As you can see in Table 30-2, RPM’s query mode is extensive and flexible, allowing you to obtain any type of information stored in the RPM databases. Using the qf option, in fact, you can create customized query output for use in reports and scripts. The next few sections demonstrate how to use many of these options. First, here are a couple of usage tips: ■■ When using the -f, option, the file argument must be to a full path. That is, the command rpm -qf /usr/bin/xmms will show the name of the RPM that contains xmms; rpm -qf xmms will not. ■■ When specifying a package name with the -p option, you must use the complete RPM filename. Installing and Upgrading Software Packages 749 38_599496 ch30.qxd 8/30/05 7:36 PM Page 749 Querying Package Dependencies The provides, requires, whatrequires, and whatprovides options allow you to identify dependencies between packages. The capability argument represents the dependency itself, which is often the name of another RPM or the name of a particular file. RPM uses dependencies to maintain system integrity, so, for example, if one RPM requires something a second RPM provides, you cannot, in normal usage, delete the second RPM. To illus- trate, to determine on what capabilities the RPM package depends, use the requires option as shown in the following command: $ rpmquery requires rpm /bin/bash beecrypt >= 4.1.2 config(rpm) = 4.4.1-18.1 fileutils libbeecrypt.so.6 libbz2.so.1 libc.so.6 [ ] NOTE Throughout this chapter, RPM commands that display package version numbers might result in different version numbers on your system. The example output is truncated to preserve space. As the output shows, the RPM package requires, in part, the /bin/bash capability and a config(rpm) capability greater than or equal to version 4.4.1-18.1. In this case, the /bin/bash capability refers to the existence of bash shell, /bin/bash, and the config(rpm) capability identifies the minimum acceptable version of rpm. To identify what capabilities a package provides, use the provides option: $ rpmquery provides rpm config(rpm) = 4.4.1-18.1 rpm = 4.4.1-18.1 The two output lines indicate that RPM provides the capabilities (most of which are filenames, in this case) config(rpm) and rpm itself, both at version 4.4.1-18.1. To determine which RPMs depend on a given capability, use whatrequires capability to list all packages requiring capability. For exam- ple, the following command shows all the packages that require the RPM capa- bility the RPM package provides. Although potentially confusing, keep in mind that the name of the package can be used as a capability. 750 Chapter 30 38_599496 ch30.qxd 8/30/05 7:36 PM Page 750 $ rpmquery whatrequires rpm rpm-python-4.4.1-18.1 up2date-4.4.17-1 yum-2.3.2-2 rpm-build-4.4.1-18.1 rpm-devel-4.4.1-18.1 createrepo-0.4.2-2 The command output shows six packages requiring the rpm capability. One of the things this tells you is that these six packages depend on RPM, so before you can remove the RPM package, therefore, you have to remove the six pack- ages that depend on it. Not that you should ever remove RPM from a Fedora Core or RHEL system, of course. The options for querying RPM dependency information offer system administrators valuable information about the relationships between the many RPMs that constitute an installed Red Hat system. What’s in That RPM? You will often find it useful or necessary to determine the contents of an RPM, whether it is installed or not. A number of the options listed in Table 30-2 make this possible. The possibilities range from simply displaying the package name and version numbers all the way to listing detailed information about each file an RPM installs. In fact, you can list all installed RPMs using the -a option. Most queries, though, fall somewhere between these extremes and query a lim- ited subset of packages or a limited selection of package characteristics or files. The simplest query option, rpm -q or rpmquery, shows only an RPM’s name and version number, as the following command illustrates: $ rpmquery jwhois jwhois-3.2.2-1.1 If you want more — and more descriptive — information, add -i: $ rpm -qi jwhois Name : jwhois Relocations: (not relocatable) Version : 3.2.2 Vendor: Red Hat, Inc. Release : 6.FC3.1 Build Date: Tue 09 Nov 2004 09:28:3 3 PM EST Install Date: Thu 27 Jan 2005 08:36:32 PM EST Build Host: tweety.build.red hat.com Group : Applications/Internet Source RPM: jwhois-3.2.2-6.FC3.1.sr c.rpm Size : 200210 License: GPL Packager : Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla> URL : http://www.gnu.org/software/jwhois/ Summary : Internet whois/nicname client. Description : A whois client that accepts both traditional and finger-style queries. Installing and Upgrading Software Packages 751 38_599496 ch30.qxd 8/30/05 7:36 PM Page 751 The output wraps because several lines are longer than 80 characters. The -i option results in a more comprehensive listing describing the RPM. Two of the entries may require additional explanation. The Group label organizes RPM packages by function. Descriptors, which are Applications and Internet in the example, are separated by / and become increasingly spe- cific as you move from left to right. Unfortunately, the values in the Group field are not standardized, and vary from vendor to vendor and even among RPM packagers. The current list of groups (see /usr/share/doc/rpm-4.3.2 /GROUPS) in Fedora Core and RHEL is: 752 Chapter 30 ■■ Amusements/Games ■■ Amusements/Graphics ■■ Applications/Archiving ■■ Applications/Communications ■■ Applications/Databases ■■ Applications/Editors ■■ Applications/Emulators ■■ Applications/Engineering ■■ Applications/File ■■ Applications/Internet ■■ Applications/Multimedia ■■ Applications/Productivity ■■ Applications/Publishing ■■ Applications/System ■■ Applications/Text ■■ Development/Debuggers ■■ Development/Languages ■■ Development/Libraries ■■ Development/System ■■ Development/Tools ■■ Documentation ■■ System Environment/Base ■■ System Environment/Daemons ■■ System Environment/Kernel ■■ System Environment/Libraries ■■ System Environment/Shells ■■ User Interface/Desktops ■■ User Interface/X ■■ User Interface/X Hardware Support To list all of the files in an installed RPM, use the -l option: $ rpmquery -l jwhois /etc/jwhois.conf /usr/bin/jwhois /usr/bin/whois /usr/share/doc/jwhois-3.2.2 /usr/share/doc/jwhois-3.2.2/COPYING /usr/share/doc/jwhois-3.2.2/NEWS /usr/share/doc/jwhois-3.2.2/README /usr/share/doc/jwhois-3.2.2/TODO /usr/share/info/jwhois.info.gz [ ] 38_599496 ch30.qxd 8/30/05 7:36 PM Page 752 The -f file option approaches package listing from another direction. For any given file, you can find out which RPM installed it using -f file, where file contains the full path specification. The following command illustrates one way to use this option: $ rpmquery -f /usr/bin/find findutils-4.1.20-7 Not much to it, right? Well, suppose that you do not know the path to an application binary, just its name. In such a case, take advantage of shell com- mands and standard Linux utility programs. For example, the next command uses the which command and the bash shell’s command substitution to resolve a binary’s name to a full path before invoking rpm: $ rpmquery -f $(which emacs) emacs-21.3-21.FC3 As described in Appendix A, the shell replaces the value of $(which emacs) with /usr/bin/emacs before passing it to rpmquery -f. The result is the same as the output of rpmquery -f /usr/bin/emacs. You can also use the command rpmquery -f `which emacs`, which is more shell neutral. TIP By default, the which command works only with executable files available in the directories listed in the $PATH environment variable. So far, every RPM query option discussed applies to installed packages. As it happens, many of them can be used on uninstalled packages, but only if the query specifies -p, which tells RPM to query an uninstalled package. Sup- pose, for example, that you just downloaded the fortune-mod-1.2.1- 1.i386.rpm package. To list its files, use -l, as explained earlier, and -p: $ rpm -qpl fortune-mod-1.2.1-1.i386.rpm /etc/profile.d/fortune.sh /usr/bin/randstr /usr/bin/rot /usr/bin/strfile /usr/bin/unstr The output, truncated to conserve space, is identical to that of an installed package. Installing and Upgrading Software Packages 753 38_599496 ch30.qxd 8/30/05 7:36 PM Page 753 [...]... subdirectories, the files !INDEX, !INDEX.html, !INDEX.short.html, and README in each directory describe, in varying levels of detail, the contents of each directory and, if applicable, its subdirectories If you prefer not to browse Ibiblio.org’s Linux archive directly, you can use its Linsearch interface, based on the Linux Software Map described in the next section, by pointing your browser at ibiblio.org/pub /Linux. .. that all the package files exist p Prep Unpacks the source code and applies any patches s Source Builds only a source RPM 761 762 Chapter 30 Stages are executed in the order listed, and later stages require preceding ones, with one exception That is, the l (list) step, for example, cannot be performed before the p (prep) stage, and the b (binary) stage happens after the p, l, c, and i (prep, list,... tracks changes to your system, such as installing, upgrading, and removing RPMs, is a very useful habit to acquire because it records each modification made to the system Although we used to recommend handwritten logs, it is probably more sensible to use some sort of soft format, such as a Web page on an intranet or another type of document that can be shared, the idea being that multiple administrators... two flavors, -U, for upgrade, and -F, for freshen What is the difference between upgrading a package and freshening it? Upgrading a package, using -U, installs it even if an earlier version is not currently installed, but freshening a package, using -F, installs it only if an earlier version is currently installed Other than this subtle but important difference, -U and -F are identical to -i, even down... assume that the SRPM is already installed using the instructions in the “Installing RPMs” section earlier in the chapter) # cd /usr/src/redhat/SPECS # rpmbuild -bb util -linux. spec Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.57851 + umask 022 + cd /usr/src/redhat/BUILD + LANG=C + export LANG + unset DISPLAY + cd /usr/src/redhat/BUILD + rm -rf util -linux- 2.12a + /usr/bin/gzip -dc /usr/src/redhat/SOURCES/util -linux- 2.12a.tar.gz... Wrote:/usr/src/redhat/RPMS/i386/util -linux- debuginfo-2.12a-16.i386.rpm They indicate that RPM created two binary RPMs, util -linux- 2.12a16.i386.rpm and util -linux- debuginfo-2.12a-16.i386.rpm, in the /usr/src/redhat/RPMS/i386 directory First, how can one SRPM produce two binary RPMs? This is simply one of RPM’s features More importantly, why would it do so? Typically, one SRPM results in multiple binary... Rather, many methods exist This section covers the most common methods for locating software version information On a Fedora Core or RHEL system, the easiest way to identify software versions is to use RPM’s query capabilities Suppose, for example, that you want to find out which version of Emacs, a popular editor, is installed on your system As explained earlier in the chapter, use RPM’s query option,... (and its predecessors, Metalab and Sunsite) is a public repository for information of all sorts, not just downloadable software For example, at the time this chapter was written, it featured an exhibit commemorating America’s World War II veterans in honor of Memorial Day, including articles, photographs, and multimedia items At the same time, Ibiblio.org hosted a stunning 55 GB of downloadable Linux software,... environment, some changes indicate a potential problem, but others do not If a binary file’s size, checksum, modification time, or user or group ownership has changed and you have not manually upgraded the package, this is cause for alarm because under normal circumstances, these characteristics do not change That is, it is highly likely that the original file has been replaced or modified, perhaps... Packages that have additional requirements usually state what they are, so read the package documentation to ensure that your system has the required software Unpacking the Source Code After downloading the bc package (bc-1.0.6.tar.gz in this chapter’s source code directory ), move it to a location where it will not interfere with the system For this example, I moved it to /tmp After cding to /tmp, you . the queried RPM(s ), displays its path, size, modification time, MD5 checksum, permissions, owner, group, and whether it is a configuration file, documentation file, a device, or a symlink (must. maintain system integrity, so, for example, if one RPM requires something a second RPM provides, you cannot, in normal usage, delete the second RPM. To illus- trate, to determine on what capabilities. 762 Wrote: /usr/src/redhat/RPMS/i386/util -linux- 2.12a-16.i386.rpm Wrote:/usr/src/redhat/RPMS/i386/util -linux- debuginfo-2.12a-16.i386.rpm They indicate that RPM created two binary RPMs, util -linux- 2.12a- 16.i386.rpm