Many times, you’ll need to know the release numbers of a large group of packages on your Linux system. Say, for instance, you're not sure which GNOME you’re running. With the help of rpm, grep, a pipe, and a couple of switches, you can figure this out quickly.
In this Daily Feature, I’ll use the Red Hat Package Management System in conjunction with a very powerful search tool (grep) to query the rpm database. These two commands (rpm and grep) are combined with what is commonly called the pipe (|).
The command syntax goes something like this:
rpm -qa | grep PACKAGE_NAME
If you take the command apart, you'll see that you are actually using grep to query (the q switch) all (the a switch) of the rpm database for anything that is relevant to PACKAGE_NAME. Although this does not explain the command to its full complexity, you should get the idea.
So, let's say you want to check to see what packages are installed by GNOME. If you run the command
rpm -qa | grep gnome
you may end up with output similar to:
[jwallen@giles jwallen]$ rpm -qa |grep gnome
The output has been truncated.
As you can see, every package listed contains the name gnome. This illustrates the obvious limitation to this system—there are packages required by GNOME that do not contain the word gnome. For example, GNOME depends on a large number of libraries, such as the gtk libraries. Within the gtk set, there are the following packages (which you can find by using the command rpm -qa | grep gtk):
[jwallen@giles jwallen]$ rpm -qa | grep gtk
Notice above that the package rep-gtk-gnome-0.11-0_helix_2 was also found by the first rpm command.
Obviously, this system is of little help for those needing to find all package dependencies. However, piping rpm and grep will aid you in finding out release numbers and package names.
Although the above system is a bit limited, it has its uses. For finding package names, finding installed packages, and finding release numbers, piping grep and rpm can’t be beat!
Jack Wallen, Jr. is very pleased to have joined the TechRepublic staff as editor in chief of Linux content. Jack was thrown out of the "Window" back in 1995, when he grew tired of the "blue screen of death" and realized that "computing does not equal rebooting." Prior to Jack's headfirst dive into the computer industry, he was a professional actor with film, TV, and Broadway credits. Now, Jack is content with his new position of Linux Evangelist. Ladies and gentlemen—the poster boy for the Linux Generation!The authors and editors have taken care in preparation of the content contained herein, but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for any damages. Always have a verified backup before making any changes.
Jack Wallen is an award-winning writer for TechRepublic and Linux.com. He’s an avid promoter of open source and the voice of The Android Expert. For more news about Jack Wallen, visit his website jackwallen.com.