📄 092-095.html
字号:
<HTML>
<HEAD>
<TITLE>Linux Unleashed, Third Edition:Wrapping Up the Installation</TITLE>
<SCRIPT>
<!--
function displayWindow(url, width, height) {
var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>
-->
<!--ISBN=0672313723//-->
<!--TITLE=Linux Unleashed, Third Edition//-->
<!--AUTHOR=Tim Parker//-->
<!--PUBLISHER=Macmillan Computer Publishing//-->
<!--IMPRINT=Sams//-->
<!--CHAPTER=5//-->
<!--PAGES=092-095//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="089-092.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="095-098.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<H4 ALIGN="LEFT"><A NAME="Heading7"></A><FONT COLOR="#000077">RPM</FONT></H4>
<P>RPM is not restricted to Red Hat Linux; it has appeared in several different versions of Linux. RPM is a character-based system that allows you to build, install, query, verify, update, and uninstall software packages. (A software package in Linux terms consists of an archive of files and information about that package, such as the package name, version number, and a brief description.) RPM has ten modes of operation, each with a different set of options. This can make RPM a little confusing to work with, although most of the uses are straightforward. RPM’s modes and their purposes are shown in Table 5.1.
</P>
<TABLE WIDTH="100%"><CAPTION ALIGN=LEFT><B>Table 5.1.</B> RPM’s modes and what they are used for.
<TR>
<TH COLSPAN="3"><HR>
<TR>
<TH WIDTH="32%" ALIGN="LEFT">Mode name
<TH WIDTH="30%" ALIGN="LEFT">Command line
<TH WIDTH="38%" ALIGN="LEFT">Used for
<TR>
<TH COLSPAN="3"><HR>
<TR>
<TD>Build
<TD><TT>rpm -[b|t]O</TT>
<TD>Build a package
<TR>
<TD>Fix permissions
<TD><TT>rpm --setperms</TT>
<TD>Fix the permissions on a package
<TR>
<TD>Install
<TD><TT>rpm -i</TT>
<TD>Adding new software
<TR>
<TD VALIGN="TOP">Query
<TD VALIGN="TOP"><TT>rpm -q</TT>
<TD>Check to see what packages and files are installed
<TR>
<TD VALIGN="TOP">Rebuild Database
<TD VALIGN="TOP"><TT>rpm --rebuilddb</TT>
<TD>Rebuild the package database
<TR>
<TD VALIGN="TOP">Set owners and groups
<TD VALIGN="TOP"><TT>rpm --setugids</TT>
<TD>Set the owner and group of a package
<TR>
<TD>Show RC
<TD><TT>rpm --showrc</TT>
<TD>
<TR>
<TD VALIGN="TOP">Signature check
<TD VALIGN="TOP"><TT>rpm --checksig</TT>
<TD>Check the package to ensure there are no errors
<TR>
<TD>Uninstall
<TD><TT>rpm -e</TT>
<TD>Remove a package
<TR>
<TD VALIGN="TOP">Verify
<TD VALIGN="TOP"><TT>rpm -V|-y| --verify</TT>
<TD>Verify that a package is installed properly (all files installed)
<TR>
<TD COLSPAN="3"><HR>
</TABLE>
<P>We won’t bother with a lot of detail about all these options because most are self-explanatory and covered in the documentation, but a few common-usage examples will help you become more familiar with RPM. To install software with RPM, you need to specify the package name that you want to install. The syntax of the install command is as follows:
</P>
<!-- CODE SNIP //-->
<PRE>
rpm -i [install-options] <package_filename>
</PRE>
<!-- END CODE SNIP //-->
<P>There are dozens of installation options possible, most of which don’t do very much except modify the behavior of RPM slightly. A few of the more useful installation options for RPM are
</P>
<DL>
<DD><B>•</B> <TT>allfiles</TT>. Installs or upgrades all the files in the package.
<DD><B>•</B> <TT>force</TT>. The same as using <TT>replacepkgs</TT>, <TT>replacefiles</TT>, and <TT>oldpackage</TT> together.
<DD><B>•</B> <TT>h</TT> or <TT>--hash</TT>. Displays 50 hash marks as the package archive is unpacked to show the system is working (use with the <TT>-v</TT> option for a nicely formatted status display).
<DD><B>•</B> <TT>includedocs</TT>. Installs documentation files (usually done by default).
<DD><B>•</B> <TT>ignoreos</TT>. Forces installation or upgrading if the operating systems of the RPM and the host are not the same.
<DD><B>•</B> <TT>keep-temps</TT>. Keeps temporary files created during the installation process, useful for debugging installation problems.
<DD><B>•</B> <TT>percent</TT>. Displays progress percentages as files are unpacked (intended to make RPM easy to run from scripts).
<DD><B>•</B> <TT>quiet</TT>. Displays a minimal set of messages (but all error messages).
<DD><B>•</B> <TT>replacefiles</TT>. Installs the package even if new files replace files from already installed packages.
<DD><B>•</B> <TT>replacepkgs</TT>. Installs the package(s) even if they are already installed.
<DD><B>•</B> <TT>test</TT>. Does not install but checks for conflicts.
</DL>
<P>Check the man page for a full list of options. The packagee name to be added is usually given as a complete path, although a URL is also possible with many versions of RPM. To install a package called Xgames, the command would be given like this:
</P>
<!-- CODE SNIP //-->
<PRE>
rpm -i /mnt/cdrom/col/install/Xgames.rpm
</PRE>
<!-- END CODE SNIP //-->
<P>In this case, the package is called Xgames.rpm, and the full path to the package is given (this one is on a CD-ROM in the col—collections—directory).
</P>
<P>The verify mode of the RPM command is handy for making certain that all portions of a package have been installed and still exist on your system. This is sometimes necessary after installing other packages that may overwrite part of an existing package. When you verify a package, RPM compares information about the installed files in the package with information about the files taken from the original package and stored in the RPM database. Among other things, verifying compares the filename, size, check sum, permissions, type, owner, and group of each file. Any discrepancies in the comparison are displayed on the screen.</P>
<P>To use the verify mode of RPM, use the command with the <TT>-w</TT> option and the package name. RPM will use one of these eight characters to show a failure of one of the tests:</P>
<CENTER>
<TABLE WIDTH="90%"><TR>
<TD WIDTH="10%">• <TT>5</TT>
<TD WIDTH="90%">MD5 sum (checksum)
<TR>
<TD>• <TT>S</TT>
<TD>File size incorrect
<TR>
<TD>• <TT>L</TT>
<TD>Symbolic link incorrect
<TR>
<TD>• <TT>T</TT>
<TD>Time incorrect
<TR>
<TD>• <TT>D</TT>
<TD>Device incorrect
<TR>
<TD>• <TT>U</TT>
<TD>User owner incorrect
<TR>
<TD>• <TT>G</TT>
<TD>Group owner incorrect
<TR>
<TD>• <TT>M</TT>
<TD>Mode incorrect (includes permissions and file types)
</TABLE>
</CENTER>
<P>If you find errors in a package, it is usually easiest to reinstall the package.
</P>
<H4 ALIGN="LEFT"><A NAME="Heading8"></A><FONT COLOR="#000077">installpkg</FONT></H4>
<P>The <TT>installpkg</TT> utility is a hold-over from UNIX, where it has been around for years. The <TT>installpkg</TT> utility can be used to install a package in much the same way as RPM. The command to install the package Xgames would be</P>
<!-- CODE SNIP //-->
<PRE>
installpkg /usr/col/Xgames
</PRE>
<!-- END CODE SNIP //-->
<P>By default <TT>installpkg</TT> looks for packages with <TT>.tgz</TT> file extensions. If you have a different extension and know that <TT>installpkg</TT> can handle it, specify the full package name including the extension on the command line. In the case of the above command, the <TT>installpkg</TT> tool extracts any files in the package <TT>/usr/col/Xgames.tgz</TT>, unpacking them as it goes.</P>
<P>The directory used by <TT>installpkg</TT> as the base for its installation is the current one, so in the case of the above example, whatever directory we are in when we issue the <TT>installpkg</TT> command is where the Xgames package is installed.</P><P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="089-092.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="095-098.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
</td>
</tr>
</table>
<!-- begin footer information -->
</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -