The rpm command
The rpm command is the Red Hat Package Manager, a tool that simplifies the task of managing packages on your Linux system. Although rpm was originally developed for Red Hat Linux, it's now found on many Linux distributions, including Fedora (which is, of course, based on the Red Hat distribution).
Here's the basic syntax for querying the status of a package:
rpm -q [options] package
To install, upgrade, or remove a package, the basic syntax is more like this:
rpm [ -i | -u | -e ] [options] package-file
You can use quite a few options with the rpm command, but the most common are
- -v: Displays verbose output. You may as well know what rpm is doing while it chugs along.
- -h: Displays hash marks (#) periodically to reassure you that the program hasn't died.
You can use rpm to determine the status of installed packages on your system by using the -q switch. For example, to find out what version of Sendmail is installed, use this command:
$ rpm -q send* Sendmail-8.12.8-4
Notice that you can use a wildcard with the package name. If you don't have a package whose name matches the package name you supply, you get the message package not installed.
To install a package, you use the -i switch and specify a wildcard filename that indicates the location of the package file. It's also a good idea to use the -v and -h switches. For example, to install Sendmail from a mounted CD-ROM drive, you use this command:
$ rpm -ivh /mnt/cdrom/Fedora/Packages/sendmail*
If you want to update to a newer version of a package, you can use the -u switch instead of the -i switch:
$ rpm -uvh /mnt/cdrom/Fedora/Packages/sendmail*
Finally, you can remove a package by using the -e switch:
$ rpm -e send*
Note that to use the rpm command, you should log on as root.
In this tutorial:
- Linux Commands
- Command Shell Basics
- Editing commands
- Wildcards
- Redirection and piping
- Environment variables
- Shell scripts
- Directory and File Handling Commands
- The cd command
- The mkdir command
- The rmdir command
- The ls command
- The cp command
- The rm command
- The mv command
- The touch command
- The cat command
- Commands for Working with Packages and Services
- The rpm command
- Commands for Administering Users
- The usermod command
- The chage command
- The passwd command
- The newusers command
- The groupadd command
- The groupdel command
- Commands for Managing Ownership and Permissions
- The chgrp command
- The chmod command
- Networking Commands
- The ipconfig command
- The netstat command
- The ping command
- The route command
- The traceroute command