Systems that use rpm as the package manager can often be managed by using yum, but sometimes a simple rpm command can quickly give the required information.
The RPM Package Manager has a huge number of options, but most commonly only a few are used on a regular basis.
Get a list of rpms for mysql-5.1
Check for mysql version 5.1
$ rpm -qa |grep mysql | grep 5.1 mysql-test-5.1.52-1.el6_0.1.x86_64 mysql-connector-java-5.1.12-2.el6.x86_64 mysql-bench-5.1.52-1.el6_0.1.x86_64 mysql-server-5.1.52-1.el6_0.1.x86_64 mysql-connector-odbc-5.1.5r1144-7.el6.x86_64 mysql-5.1.52-1.el6_0.1.x86_64 mysql-libs-5.1.52-1.el6_0.1.x86_64 mysql-devel-5.1.52-1.el6_0.1.x86_64
Of course we can use egrep, and sort to get a more specific list
$ rpm -qa |egrep -i "bash|ntpdate|httpd"|sort bash-4.1.2-8.el6.x86_64 ntpdate-4.2.4p8-2.el6.x86_64
xargs - build and execute command lines from standard input
Now suppose we want to remove all the rpms found by the rpm query. Sometimes we can just pipe the output to xargs.$ rpm -qa |grep mysql | xargs rpm -e
Other times there are dependencies the prevent removal of some rpms. In that case we can come up with some other tricks. Create a list, and then run "rpm -e" on the list. As a last resort we can use --force, or --nodeps, but that is usually not recommended.
No comments:
Post a Comment