This is designed to be a companion to the AptHelp page for DebianLinux users. I am not very familiar with RedhatLinux and so I will document my experiences here as I learn the commands needed to make Redhat behave.
I'm a newbie to Redhat and I'm writing this as I go, so if you see any mistakes or can see something that should be added, please do.
See also: RedhatLinux, UsingApt, UsingDpkg
Contents
Contents
Files and Directories
- I have no idea what's important or goes where yet.
Using The rpm Command
Basics
- rpm -q redhat-release
- Tells you what version of Redhat you have installed.
- rpm -i <package file>
- Installs the package
- rpm -e <package name>
- Removes all the files associated with the package. It will only remove empty directories (so if you have config files in a directory that is associated with the package it will not remove them).
- rpm -qa
- Lists all of the packages installed on the system.
- rpm -qi <package name>
- Searches the installed packages list and displays the version and and description of the package installed (assuming it is installed).
- rpm -ql <package name>
- Lists the contents of an installed package.
- rpm -F <package file>
Freshens the package. In other words, it upgrades the package ONLY if it's already installed with a lower versions. This is useful for rpm -F /path/to/updates/*rpm
- rpm -U <package file>
Upgrade the package if it's already installed or not. The -U and -F flags can be confusing. Only use -U when you know you want the file installed.
- rpm -qpi <package file>
Displays the description of a package file (eg. python-1.5.2-27.rpm). Good way of checking out a package before you install it. It can also take URLs instead of local file pointers (eg. rpm -qpi http://www.domain.com/download/python-1.5.2-27.rpm).
- rpm -qpl <package file>
- List the contents of a package file.
- rpm -qpli <package file>
- List the contents and description of a package file.
Advanced
- APT clones for RedhatLinux
I haven't used this yet but it claims to be an apt clone for rpm. You can find it here.
Having now investigated this I'm not all that impressed. I gave up after a couple hours of waiting for "rpm-get update" to complete. It looks like it requires that it actually downloads each package which is a potential installation candidate to parse the depends information. Yukky. -- AdamShand
- rpmwhich
A simple BashShell function which tells you which package a file belongs to (equivelent of "dpkg -S <filename>").
rpmwhich () { for f in $*; do ff=$(which $f 2>/dev/null); if [ -n "$ff" ]; then printf "%s: " $ff; rpm -qf $ff; else printf "'%s' not found!\n" $f; fi; done }
Building RPM's
Rebuilding Source RPM's
Sometimes you want to customize a Redhat RPM to tweak the config files or such. This is a step by step example for rebuilding the package for AutoMount version 4 (which still isn't included by default in RedhatLinux <grr>). RPM's are typically distributed as source RPM as well as a binary RPM to make such changes easier. Here are the steps to build the autofs4 source RPM (it must be done on a Redhat box):
Install the source RPM:
- # rpm -i autofs-4.0.0pre10-1.src.rpm
Go to the installed sources:
- # cd /usr/src/redhat/SOURCES/
Now untar the source tarball to somewhere and make whatever changes you need to:
# tar zxvf autofs-4.0.0pre10.tar.gz -C /tmp
# cd /tmp/autofs-4.0.0pre10
Now make whatever tweaks you want to the sources:
- # vi ...
Tar your changes back up and replace the original tarball with the one you've created.
- # tar zcvf /usr/src/redhat/SOURCES/autofs-4.0.0pre10.tar.gz /tmp/autofs-4.0.0pre10
Now build the new binary RPM package:
# cd /usr/src/redhat/SPEC
# rpmbuild -ba autofs.spec
Install the new binary RPM:
- # rpm -i /usr/src/redhat/RPMS/i386/autofs-4.0.0pre10-1.i386.rpm
And you're done. If you have any problems with the build carefully read the error messages and it's possible you may need to make a change to the autofs.spec file.
Building RPM's As Non Root
Stolen from the CourierImap FAQ.
First you need to create a mirror image of the main /usr/src/redhat directories in your home directory:
# mkdir $HOME/rpm
# mkdir $HOME/rpm/SOURCES
# mkdir $HOME/rpm/SPECS
# mkdir $HOME/rpm/BUILD
# mkdir $HOME/rpm/SRPMS
# mkdir $HOME/rpm/RPMS
# mkdir $HOME/rpm/RPMS/i386
Use sparc, or alpha, or whatever's appropriate. Finally:
# echo "%_topdir $HOME/rpm" >> $HOME/.rpmmacros
That's it, now you can build your RPM's without being root:
- # rpmbuild -ta courier-imap-0.34.tar.gz
Useful URLs
http://www.rpm.org/ The definitive starting point.
http://www.rpmfind.net/ and http://www.filewatcher.org/ Good places to find new and updated packages.
Thanks To
ThatDoughnut for actual Redhat knowledge!