Commands using rpm (53)

  • Find out which RPMs were installed on a particular date. These would (naturally) include update RPMs. This example shows searching for "Thu 05 Mar" (with grep). Alternatively, pipe it to less so you can search inside less (with less's neat text highlighting of the search term): rpm -qa --queryformat '%{installtime} \"%{vendor}\" %{name}-%{version}-%{release} %{installtime:date}\n' | less # (this example) search term: Thu 05 Mar Show Sample Output


    4
    rpm -qa --queryformat '%{installtime} \"%{vendor}\" %{name}-%{version}-%{release} %{installtime:date}\n' | grep "Thu 05 Mar"
    mpb · 2009-03-17 13:38:20 12
  • Replace 'more' command with any command which is in your PATH. Show Sample Output


    3
    rpm -qif `which more`
    alcik · 2009-02-27 08:59:07 11

  • 3
    rpm -q -a --qf '%10{SIZE}\t%{NAME}\n' | sort -k1,1n
    octopus · 2010-04-19 07:44:49 9
  • This command could seem pretty pointless especially when you can get the same result more easily using the rpm builtin queryformat, like: rpm -qa --qf "%{NAME} %{VERSION} %{RELEASE}.%{ARCH}\n" | sort | column -t but nonetheless I've learned that sometimes it can be quite interesting trying to explore alternative ways to accomplish the same task (as Perl folks like to say: There's more than one way to do it!) Show Sample Output


    3
    rpm -qa | sed 's/^\(.*\)-\([^-]\{1,\}\)-\([^-]\{1,\}\)$/\1 \2 \3/' | sort | column -t
    acavagni · 2019-03-14 21:11:45 34
  • the newest rpms are at the top; individual packages can also be queried this way: rpm --last -q package


    2
    rpm -qa --last
    systemj · 2009-02-05 16:00:56 55
  • You can use wildcard with rpm search but you have to do 2 things: 1. use "-a" switch (means "all") with query ("-q") switch - argument is a pattern to use while searching for package names of all installed packages 2. protect wildcards, so that shell could not eat them - escape it with backslash ("\") or enclose all pattern between apostrophes ("'"): rpm -qa 'co*de' As you can see above it is possible to insert wildcards into middle of the pattern. If you want, you can add "-i" or another rpm query options, "-i" will print package information for all installed packages matching pattern. Show Sample Output


    2
    rpm -qa \*code\*
    alcik · 2009-03-11 21:16:23 18
  • Low on disk space? Check the largest installed RPMs for delete canditates. Show Sample Output


    2
    rpm -qa --qf '%{SIZE} %{NAME}\n' | sort -nr | nl | head -6 # six largest RPMs
    mpb · 2009-03-15 22:18:17 9
  • Lists all installed RPM packages with name and architecture, which is useful to check for compability packages (+ required i386 packages) on a 64bit system. Show Sample Output


    2
    rpm -qa --queryformat "%{NAME} %{ARCH}\n"
    angrox · 2009-03-18 15:19:21 13
  • In this case, I'm getting the package version for 'redhat-release', but of course, this can be applied to any package installed on the filesystem. This is very handy in scripts that need to determine just the version of the package, without the package name and all the sed and grep hackery to get to the data you want. To find out all the support format strings that 'rpm --qf' supports: rpm --querytags Show Sample Output


    2
    rpm -q --qf "%{VERSION}\n" redhat-release
    atoponce · 2009-03-25 16:46:14 11
  • It's all said in the title. Show Sample Output


    2
    rpm -qa --qf "%-10{SIZE} %-30{NAME}\n" | sort -nr | less
    betsubetsu · 2010-04-14 07:28:41 3

  • 2
    rpm -qa --qf "%-30{NAME} %-10{SIZE}\n" | sort -n | less
    betsubetsu · 2010-04-14 07:30:37 5
  • if you want to see all information about a package use: rpm -qi pkgname full list of querytags can be accessed by the command: rpm --querytags you can also customize the query format how ever you like with using more querytags together along with escape sequences in "man printf"! you can also use more than one package name. for example this command shows name and version in to columns: rpm -q --queryformat %-30{NAME}%{VERSION}\\n pkg1 pkg2 Show Sample Output


    2
    rpm -q --queryformat %{VERSION}\\n pkgname
    mrwill · 2010-06-03 01:54:17 4

  • 2
    rpm -qp --scripts package.rpm
    gerard · 2011-01-04 14:38:14 35
  • For Linux distributions using rpm (eg Mandriva), this command will find the rpm package name that provides a file. Show Sample Output


    2
    rpm -q --whatprovides $filename
    mpb · 2011-02-09 23:28:15 2
  • Many times I give the same commands in loop to find informations about a file. I use this as an alias to summarize that informations in a single command. Now with variables! :D Show Sample Output


    2
    fileinfo() { RPMQF=$(rpm -qf $1); RPMQL=$(rpm -ql $RPMQF);echo "man page:";whatis $(basename $1); echo "Services:"; echo -e "$RPMQL\n"|grep -P "\.service";echo "Config files:";rpm -qc $RPMQF;echo "Provided by:" $RPMQF; }
    nnsense · 2015-05-11 16:46:01 13
  • If somehow if you get more than 1 same name rpm package install, then it cannot be removed by using simple rpm -e as it gives you more than one rpm matches error. The --matches will help to remove all the same name rpm packages.


    1
    rpm -e --allmatches filename.rpm
    sohaileo · 2009-02-12 23:09:24 11
  • This command is very helpful when we need to duplicate a test scenario and first we want to find out the installed libraries together with the version and release numbers and architecture. (look example) Command can be tuned by choosing just the names of libraries we are interested in. For example glibc and gcc. Show Sample Output


    1
    rpm -qa --qf '%{name}-%{version}-%{release}.%{arch}\n'|egrep 'compat|glibc|gcc|libst|binu'|sort
    ovalerio · 2009-02-23 10:17:47 6
  • rpm, sometimes, is not wildcard friendly. To search files installed from package this could be useful. change PACKAGENAME to any package do you want to search Show Sample Output


    1
    rpm -qa | grep PACKAGENAME | xargs rpm -q --filesbypkg
    piscue · 2009-02-26 14:32:12 6
  • On Fedora clean the boot directory; erase older kernel


    1
    rpm -q kernel-2* | grep -v $(uname -r) | xargs yum erase -y
    Nick · 2009-03-28 21:41:15 11

  • 1
    yum clean all ; rpm -Uvh http://download.fedora.redhat.com/pub/fedora/linux/releases/11/Fedora/i386/os/Packages/fedora-release-11-1.noarch.rpm ; yum -y upgrade ; reboot
    freeman · 2009-08-01 21:00:43 5
  • Description is moved to "Sample output" because the html sanitizer for commandlinefu breaks the examples.. Show Sample Output


    1
    diff rpm_output_from_other_computer <(rpm -qa|sort)
    xeor · 2011-06-25 11:45:15 3
  • This should be an option to rpm, but isn't. I wind up using it a lot because I always forget the full name of the packages I want to delete.


    1
    sudo rpm -e `rpm -qa | grep keyword`
    mstock · 2012-10-22 16:06:39 6
  • \n Separates out the architectures on different lines. Show Sample Output


    1
    rpm -q --queryformat="%{NAME}: %{OPTFLAGS}\n" <rpm>
    robinsonaarond · 2012-12-05 22:18:03 5
  • Interesting to see which packages are larger than the kernel package. Useful to understand which RPMs might be candidates to remove if drive space is restricted. Show Sample Output


    1
    rpm -qa --queryformat '%{size} %{name}-%{version}-%{release}\n' | sort -k 1,1 -rn | nl | head -16
    mpb · 2013-03-19 21:10:54 6
  • I use this as an alias to get all .service files related a single installed file/conf (if it has services, of course). For rpm based systems ;) Show Sample Output


    1
    qf2s() { rpm -ql $(rpm -qf $1)|grep -P "\.service"; }
    nnsense · 2015-05-11 16:32:16 9
  •  1 2 3 > 

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands


Check These Out

Chronometer in hour format
Shorter and faster...

Rename files in batch

Find Duplicate Files (based on size first, then MD5 hash)
If you have the fdupes command, you'll save a lot of typing. It can do recursive searches (-r,-R) and it allows you to interactively select which of the duplicate files found you wish to keep or delete.

Sort dotted quads
Sort a list of IPV4 addresses in numerical order. Great as a filter, or within vim using !}

Record microphone input and output to date stamped mp3 file
record audio notes or meetings requires arecord and lame run mp3gain on the resulting file to increase the volume / quality ctrl-c to stop recording

Which processes are listening on a specific port (e.g. port 80)
swap out "80" for your port of interest. Can use port number or named ports e.g. "http"

MPD + Digitally Imported
1.- Enter into the playlist path. 2.- Run the command. 3.- Playlists created!

Convert seconds to [DD:][HH:]MM:SS
Converts any number of seconds into days, hours, minutes and seconds. sec2dhms() { declare -i SS="$1" D=$(( SS / 86400 )) H=$(( SS % 86400 / 3600 )) M=$(( SS % 3600 / 60 )) S=$(( SS % 60 )) [ "$D" -gt 0 ] && echo -n "${D}:" [ "$H" -gt 0 ] && printf "%02g:" "$H" printf "%02g:%02g\n" "$M" "$S" }

Get fully qualified domain names (FQDNs) for IP address with failure and multiple detection

Fixes Centos 6.2 yum's metalink certificate errors
Fix's centos 6.2 yum's error: could not get metalink https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=x86_64 error was 14: PYCURL ERROR 77 - "Problem with the SSL CA cert (path? access rights?)" Error: Cannot retrieve metalink for repository: epel-source. Please verify its path and try again


Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: