doc054.htm
来自「Reh Hat user manual. really goooood」· HTM 代码 · 共 308 行
HTM
308 行
<html><body><a href="doc055.html"><img src=../icons/next.gif alt="Next"></a><a href="doc000.html"><img src=../icons/up.gif alt="Up"></a><a href="doc053.html"><img src=../icons/previous.gif alt="Previous"></a><a href="doc000.html"><img src=../icons/contents.gif alt="Contents"></a><a href="doc123.html"><img src=../icons/index.gif alt="Index"></a><hr><h2><a name="s7.2">7.2 Using RPM</a></h2><title>Using RPM</title><p>RPM has five basic modes of operation (not counting package building):installing, uninstalling, upgrading, querying, and verifying. Thissection contains an overview of each mode. For complete details andoptions try <tt>rpm --help</tt>, and see the rpm man pageand the (previously mentioned) RPM book.<p><h3><a name="s7.2.1">7.2.1 Installing</a></h3><title>Installing</title><a name="i194">RPM packages typically have file names like <tt>foo-1.0-1.i386.rpm</tt>,which includes the package name (<tt>foo</tt>), version (<tt>1.0</tt>),release (<tt>1</tt>), and architecture (<tt>i386</tt>).Installing a package is as simple as:<p><blockquote><font size=-1><tt><pre>$ rpm -ivh foo-1.0-1.i386.rpmfoo ####################################</pre></tt></font></blockquote><p>As you can see, RPM prints out the name of the package (which is notnecessarily the same as the file name, which could have been <tt>1.rpm</tt>),and then prints a succession of hash marks as the package is installed,as a sort of progress meter.<p>Installing packages is designed to be simple, but you can get a few errors:<p><h4><a name="s7.2.1.1">7.2.1.1 Package Already Installed</a></h4><title>Package Already Installed</title><p>If the package is already installed, you will see:<p><blockquote><font size=-1><tt><pre>$ rpm -ivh foo-1.0-1.i386.rpmfoo package foo-1.0-1 is already installederror: foo-1.0-1.i386.rpm cannot be installed</pre></tt></font></blockquote><p>If you really want to install the package anyway, you can use<tt>--replacepkgs</tt> on the command line, which tells RPM to ignorethe error.<p><h4><a name="s7.2.1.2">7.2.1.2 Conflicting Files</a></h4><title>Conflicting Files</title><p>If you attempt to install a package that contains a file that has alreadybeen installed by another packages, you'll see:<p><blockquote><font size=-1><tt><pre># rpm -ivh foo-1.0-1.i386.rpmfoo /usr/bin/foo conflicts with file from bar-1.0-1error: foo-1.0-1.i386.rpm cannot be installed</pre></tt></font></blockquote><p>To cause RPM to ignore that error, use <tt>--replacefiles</tt> on thecommand line.<p><h4><a name="s7.2.1.3">7.2.1.3 Unresolved Dependency</a></h4><title>Unresolved Dependency</title><p>RPM packages can ``depend'' on other packages, which means thatthey require other packages to be installed in order to run properly.If you try to install a package for which there is such an unresolveddependency, you'll see:<p><blockquote><font size=-1><tt><pre>$ rpm -ivh bar-1.0-1.i386.rpm failed dependencies: foo is needed by bar-1.0-1</pre></tt></font></blockquote><p>To handle this error you should install the requested packages. Ifyou want to force the installation anyway (a bad idea since the packageprobably will not run correctly), use <tt>--nodeps</tt> on the command line.<p><h3><a name="s7.2.2">7.2.2 Uninstalling</a></h3><title>Uninstalling</title><a name="i195"><p>Uninstalling a package is just as simple as installing:<p><blockquote><font size=-1><tt><pre>$ rpm -e foo</pre></tt></font></blockquote><p>Notice that we used the package <em>name</em> ``<tt>foo</tt>'', not the name of theoriginal package <em>file</em> ``<tt>foo-1.0-1.i386.rpm</tt>''.<p>You can encounter a dependency error when uninstalling a package ifsome other installed package depends on the one you are trying toremove. For example:<p><blockquote><font size=-1><tt><pre>$ rpm -e fooremoving these packages would break dependencies: foo is needed by bar-1.0-1</pre></tt></font></blockquote><p>To cause RPM to ignore that error and uninstall the package anyway(which is a bad idea since the package that depend on it will probablyfail to work properly), use <tt>--nodeps</tt> on the command line.<p><h3><a name="s7.2.3">7.2.3 Upgrading</a></h3><title>Upgrading</title><a name="i196"><p>Upgrading a package is almost just like installing.<p><blockquote><font size=-1><tt><pre>$ rpm -Uvh foo-2.0-1.i386.rpmfoo ####################################</pre></tt></font></blockquote><p>What you don't see above is the fact that RPM automatically uninstalledany old versions of the <tt>foo</tt> package. In fact you may want toalways use <tt>-U</tt> to install packages,since it works fine even when there are no previous versions ofthe package installed.<p>Since RPM performs intelligent upgrading of packages with configurationfiles, you may see a message like:<p><blockquote><font size=-1><tt><pre>saving /etc/foo.conf as /etc/foo.conf.rpmsave</pre></tt></font></blockquote><p>This means that your changes to the configuration file may not be``forward compatible'' with the new configuration file in the package,so RPM saved your original file, and installed a new one. You shouldinvestigate and resolve the differences between the two files as soonas possible to ensure that your system continues to function properly.<p>Since upgrading is really a combination of uninstalling and installing,you can encounter any errors from those modes, plus one more:If RPM thinks you are trying to upgrade to a package with an <em>older</em>version number, you will see:<p><blockquote><font size=-1><tt><pre>$ rpm -Uvh foo-1.0-1.i386.rpmfoo package foo-2.0-1 (which is newer) is already installederror: foo-1.0-1.i386.rpm cannot be installed</pre></tt></font></blockquote><p>To cause RPM to ``upgrade'' anyway, use <tt>--oldpackage</tt> on thecommand line.<p><h3><a name="s7.2.4">7.2.4 Querying</a></h3><title>Querying</title><a name="i197"><p>Querying the database of installed packages is accomplished with<tt>rpm -q</tt>. A simple use is <tt>rpm -q foo</tt>which will print the package name, version, and release number of the installedpackage foo:<p><blockquote><font size=-1><tt><pre>$ rpm -q foorpm-2.0-1</pre></tt></font></blockquote><p>Instead of specifying the package name, you can use the followingoptions with <tt>-q</tt> to specify what package(s) you want to query. These arecalled <em>Package Specification Options</em>.<p><ul><li><tt>-a</tt> queries all currently installed packages.<li><tt>-f <file></tt> will query the packageowning <file>.<li><tt>-F</tt> is the same as <tt>-f</tt> except it takesfilenames via stdin (e.g. <tt>find /usr/bin | rpm -qF</tt>).<li><tt>-p <packagefile></tt> queries thepackage <packagefile>.<li><tt>-P</tt> is like <tt>-p</tt> except it takes package filenamesfrom stdin (e.g. <tt>find /mnt/cdrom/RedHat/RPMS | rpm -qP</tt>).</ul><p>There are a number of ways to specify what information to displayabout queried packages.The following options are used to select the information youare interested in. These are called <em>Information SelectionOptions</em>.<p><ul><li><tt>-i</tt> displays package information such as name, description, release, size, build date, install date, vendor,and other miscellaneous information.<li><tt>-l</tt> displays the list of files that the package ``owns''.<li><tt>-s</tt> displays the state of all the files in the package. Thereare only two possible states, normal and missing.<li><tt>-d</tt> displays a list of files marked as documentation (man pages, info pages, README's, etc).<li><tt>-c</tt> displays a list of files marked as configuration files. These are the files you change after installation toadapt the package to your system (sendmail.cf, passwd, inittab, etc).</ul><p>For those options that display file lists, you can add <tt>-v</tt>to your command line to get the lists in a familiar <tt>ls -l</tt>format.<p><h3><a name="s7.2.5">7.2.5 Verifying</a></h3><title>Verifying</title><a name="i198"><p>Verifying a package compares information about files installed from apackage with the same information from the original package.Among other things, verifyingcompares the size, MD5 sum, permissions, type, owner and group of eachfile.<p><tt>rpm -V</tt> verifies a package. You can use any of the<em>Package Selection Options</em> listed for querying to specify the packagesyou wish to verify. A simple use is <tt>rpm -V foo</tt>which verifies that all the files in the foo package are as theywere when they were originally installed. For example:<p><ul><li>To verify a package containing particular file:<blockquote><font size=-1><tt><pre>rpm -Vf /bin/vi</pre></tt></font></blockquote><li>To verify ALL installed packages:<blockquote><font size=-1><tt><pre>rpm -Va</pre></tt></font></blockquote><li>To verify an installed package against an RPM package file:<blockquote><font size=-1><tt><pre>rpm -Vp foo-1.0-1.i386.rpm</pre></tt></font></blockquote>This can be useful if you suspect that your RPM databases are corrupt.</ul><p>If everything verified properly there will be no output. If there areany discrepancies they will be displayed. The format of the output isa string of 8 characters, a possible ``c'' denoting a configurationfile, and then the file name. Each of the 8 characters denotes theresult of a comparison of one attribute of the file to the value ofthat attribute recorded in the RPM database. A single ``.'' (period)means the test passed. The following characters denote failure ofcertain tests:<p><dl><dt><b>5</b><dd> MD5 checksum<dt><b>S</b><dd> File size<dt><b>L</b><dd> Symbolic link<dt><b>T</b><dd> File modification time<dt><b>D</b><dd> Device<dt><b>U</b><dd> User<dt><b>G</b><dd> Group<dt><b>M</b><dd> Mode (includes permissions and file type)</dl><p>If you see any output, use your best judgment to determine if youshould remove or reinstall the package, or somehow fix the problem.<p><p><hr><a href="doc055.html"><img src=../icons/next.gif alt="Next"></a><a href="doc000.html"><img src=../icons/up.gif alt="Up"></a><a href="doc053.html"><img src=../icons/previous.gif alt="Previous"></a><a href="doc000.html"><img src=../icons/contents.gif alt="Contents"></a><a href="doc123.html"><img src=../icons/index.gif alt="Index"></a><hr></body></html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?