PDA

Click to See Complete Forum and Search --> : Linux - RPM Commands


Phat_Penguin
September 25th, 2002, 04:29 PM
From the onset I wish to point out that this is NOT my work, but something I found in the dark recesses of my hard drive today. I am posting it hopefully to assist anyone (in particular newbies), from a security point of view, running a RPM based Linux distro. It sets out a number of RPM commands which enable you to descend into those RPM packages to see what lurks there ....

RPM COMMANDS

- rpm help (short list)
- rpm --help (long list)
- man rpm
- info rpm
- xman
- KHelpcenter

and...

Can you create a file containing a sorted list of all installed packages ?

$ rpm -qa | sort > sorted_list_all_packages

[B]Can you display this last file in columns ?

(larger terminal window needed)

$ cat sorted_list_all_packages | column

[B]What installed package names contain the word rpm ?

Sorted list in columns please.
(cut/paste from konsole to kedit != tabs ?)

[$ rpm -qa | grep rpm | sort | column
gnorpm-0.95.1-1mdk rpmlint-0.24-1mdk
grpmi-7.2-19.1mdk rpm-python-3.0.5-25mdk
gurpmi-0.7-10mdk rpm-rebuilder-0.1-1mdk
rpm-3.0.5-25mdk rpmtools-1.2-11mdk
rpm-build-3.0.5-25mdk rpmtools-compat-1.2-11mdk
rpm-devel-3.0.5-25mdk rpmtools-devel-1.2-11mdk
rpmdrake-1.1-15mdk urpmi-1.3-10mdk

[B]How many listed packages are there ?

$ rpm -qa | grep rpm | wc -l
14

[B]What about RpM ?

$ rpm -qa | grep -i RpM | sort | column
gnorpm-0.95.1-1mdk rpmlint-0.24-1mdk
grpmi-7.2-19.1mdk rpm-python-3.0.5-25mdk
gurpmi-0.7-10mdk rpm-rebuilder-0.1-1mdk
perl-RPM-0.28-2mdk rpmtools-1.2-11mdk
rpm-3.0.5-25mdk rpmtools-compat-1.2-11mdk
rpm-build-3.0.5-25mdk rpmtools-devel-1.2-11mdk
rpm-devel-3.0.5-25mdk urpmi-1.3-10mdk
rpmdrake-1.1-15mdk

[B]How many listed packages are there ?

$ rpm -qa | grep -i RpM | wc -l
15

[B]BACK TO RPM DOCUMENTATION !

What documentation files are in rpm-3.0.5-25mdk ?

$ rpm -qd rpm-3.0.5-25mdk
/usr/share/doc/rpm-3.0.5/CHANGES
/usr/share/doc/rpm-3.0.5/GROUPS
/usr/share/doc/rpm-3.0.5/RPM-PGP-KEY
/usr/share/doc/rpm-3.0.5/buildroot
/usr/share/doc/rpm-3.0.5/dependencies
/usr/share/doc/rpm-3.0.5/format
/usr/share/doc/rpm-3.0.5/macros
/usr/share/doc/rpm-3.0.5/multiplebuilds
/usr/share/doc/rpm-3.0.5/queryformat
/usr/share/doc/rpm-3.0.5/relocatable
/usr/share/doc/rpm-3.0.5/signatures
/usr/share/doc/rpm-3.0.5/spec
/usr/share/doc/rpm-3.0.5/triggers
/usr/share/man/ja/man8/rpm.8.bz2
/usr/share/man/ja/man8/rpm2cpio.8.bz2
/usr/share/man/man1/gendiff.1.bz2
/usr/share/man/man8/rpm.8.bz2
/usr/share/man/man8/rpm2cpio.8.bz2
/usr/share/man/man8/update-alternatives.8.bz2
/usr/share/man/pl/man8/rpm.8.bz2
/usr/share/man/ru/man8/rpm.8.bz2
/usr/share/man/ru/man8/rpm2cpio.8.bz2

[B]How many files in rpm-3.0.5-25mdk ?

$ rpm -ql rpm-3.0.5-25mdk | wc -l
92

[B]Can you display only the first file in rpm-3.0.5-25mdk ?

$ rpm -ql rpm-3.0.5-25mdk | head -n 1
/bin/rpm

[B]Can you give me more details on this last one ?

$ rpm -qlv rpm-3.0.5-25mdk | head -n 1
-rwxr-xr-x root root 887912 Oct 9 2000 /bin/rpm

[B]Can you show me the install state of files for rpm-3.0.5-25mdk ?

Only the last file in list please.

$ rpm -qsv rpm-3.0.5-25mdk | tail -n 1
normal drwxr-xr-x root root 4096 Oct 9 2000 /var/lib/rpm/alternatives

[B]How many non normal files are in rpm-3.0.5-25mdk ?

$ rpm -qsv rpm-3.0.5-25mdk | grep -v -i normal | wc -l
17

[B]Please display showing less information the last non normal file in rpm-3.0.5-25mdk

$ rpm -qs rpm-3.0.5-25mdk | grep -v -i normal | tail -n 1
not installed /usr/share/man/ru/man8/rpm2cpio.8.bz2

[B]What does rpm-3.0.5-25mdk require ?

$ rpm -qv --requires rpm-3.0.5-25mdk
gawk
fileutils
textutils
sh-utils
mktemp
bzip2 >= 0.9.0c-2
popt
/bin/sh
/sbin/ldconfig
ld-linux.so.2
libbz2.so.1
libc.so.6
libdb.so.2
libz.so.1
/bin/bash
/bin/sh
/usr/bin/perl
libc.so.6(GLIBC_2.0)
libc.so.6(GLIBC_2.1)
libdb.so.2(GLIBC_2.0)

[B]Is gawk installed ?

$ rpm -q gawk
gawk-3.0.6-1mdk

[B]What package owns /bin/sh in --requires list ?

$ rpm -qfv /bin/sh
bash-2.04-12mdk

[B]What package(s) provide libc.so.6 in --requires list ?

$ rpm -q --whatprovides libc.so.6
compat-glibc-7.2-2.1.3.3mdk
glibc-2.2.2-4mdk

[B]What does rpm-3.0.5-25mdk provide ?

$ rpm -q --provides rpm-3.0.5-25mdk
librpm.so.0
librpmbuild.so.0

[B]Where is file librpm.so.0 ?

$ rpm -qs rpm-3.0.5-25mdk | grep librpm.so.0
normal /usr/lib/librpm.so.0
normal /usr/lib/librpm.so.0.0.0
or
[b@Ath1-1 b]$ whereis -b librpm.so.0
librpm.so: /usr/lib/librpm.so /usr/lib/librpm.so.0

[B]Is rpm-3.0.5-25mdk a package name ! ?

$ rpm -q --queryformat "%{NAME}\\n" rpm-3.0.5-25mdk
rpm

[B]What is it's version number ?

$ rpm -q --queryformat "%{VERSION}\\n" rpm
3.0.5

[B]What is it's release number ?

$ rpm -q --queryformat "%{RELEASE}\\n" rpm
25mdk

[B]What is it'patch level ?

$ rpm -q --queryformat "%{PATCH}\\n" rpm
(none)

[B]What is it's source ?

$ rpm -q --queryformat "%{SOURCERPM}\\n" rpm
rpm-3.0.5-25mdk.src.rpm

[B]When was package rpm installed ?

$ rpm -q --queryformat "%{INSTALLTIME:date}\\n" rpm
Sat Feb 3 18:05:23 2001

[B]Can you give me more information about package rpm ?

$ rpm -qi rpm
Name : rpm Relocations: /usr
Version : 3.0.5 Vendor: MandrakeSoft
Release : 25mdk Build Date: Mon Oct 9 05:28:51 2000
Install date: Sat Feb 3 18:05:23 2001 Build Host: bi.mandrakesoft.com
Group : System/Configuration/Packaging Source RPM: rpm-3.0.5-25mdk.src.rpm
Size : 2921616 License: GPL
Packager : Linux-Mandrake Team <bugs@linux-mandrake.com>
Summary : The RPM package management system
Description :
Le gestionnaire de paquetages Red Hat nommé RPM (Red Hat Package
Manager) est un puissant utilitaire en ligne de commande capable
d'installer, de désinstaller, de vérifier, d'interroger, et de mettre à jour des paquetages. Chaque paquetage est une archive contenant des fichiers, ainsi que des informations additionnelles sur le paquetage telles que son numéro de version, une description de son contenu, etc.

(Proof this isn't mine - I don't know a word of French :) )

[B]Is there more ?

Yes in rpm documentation and a good old Google search.
(rpm - Red Hat Package Manager)

I do not recall where I obtained this so I cannot, unfortunately, acknowledge the author.

Hope someone here finds the information of benefit.

PP

magickal1
September 27th, 2002, 09:10 PM
While the information is with out a doubt correct, the approach leaves a bit to be desired. For the sake of clarity, Giving the commands was a great idea. However, There was no need for the verbose pasting of the term output. That might confuse the neqwbie that this was intended for as well as making it an unnecessarly long posting. Suggested that next time to omit the output for hte sake of clarity and brevity. Other wise this is very good info for the newbie and those who whish to brush up.

While the information is with out a doubt correct, the approach leaves a bit to be desired. For the sake of clarity, giving the commands was a great idea. However, there was no need for the verbose pasting of the terminal output. That might confuse the newbie as well as making it an unnecessarly long posting. Suggested that next time to omit the output for the sake of clarity and brevity. Other wise this is very good info for the newbie and those who wish to brush up.

cgkanchi
January 7th, 2003, 01:10 PM
It's a nice post actually, and I think more newbies should take an example from this about how to post unoriginal work. Nice job.

From the onset I wish to point out that this is NOT my work, but something I found in the dark recesses of my hard drive today