What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again.

Delete that bloated snippets file you've been using and share your personal repository with the world. 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.

Get involved!

You can sign-in using OpenID credentials, or register a traditional username and password.

First-time OpenID users will be automatically assigned a username which can be changed after signing in.

UpGuard checks and validates configurations for every major OS, network device, and cloud provider.

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:



May 19, 2015 - A Look At The New Commandlinefu
I've put together a short writeup on what kind of newness you can expect from the next iteration of clfu. Check it out here.
March 2, 2015 - New Management
I'm Jon, I'll be maintaining and improving clfu. Thanks to David for building such a great resource!

Top Tags



Commands tagged rpm from sorted by
Terminal - Commands tagged rpm - 21 results
qf2s() { rpm -ql $(rpm -qf $1)|grep -P "\.service"; }
2015-05-11 16:32:16
User: nnsense
Functions: grep rpm

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 ;)

rpm -e --allmatches gpg-pubkey-1aa043b8-53b2e946
2014-12-09 21:27:08
User: krizzo
Functions: rpm
Tags: GPG rpm yum pubkey

This will remove the gpg-pubkey-1aa043b8-53b2e946 from rpm/yum and you'll be prompted to add it back from the given repo.

rpm -qa gpg-pubkey --qf "%{version}-%{release} %{summary}\n"
2014-12-09 21:23:28
User: krizzo
Functions: rpm
Tags: GPG rpm yum pubkey

This will list all the gpg keys that were accepted and installed for yum.

rpm -qa --queryformat '%{SIZE}\n' | awk '{sum += $1} END {printf("Total size in packages = %4.1f GB\n", sum/1024**3)}'
2013-12-14 20:22:41
User: skytux
Functions: awk rpm

It is not the installed size in files, but the size of RPM packages.

rpm -q --queryformat="%{NAME}: %{OPTFLAGS}\n" <rpm>
2012-12-05 22:18:03
Functions: rpm

\n Separates out the architectures on different lines.

sudo rpm -e `rpm -qa | grep keyword`
2012-10-22 16:06:39
User: mstock
Functions: grep rpm sudo
Tags: rpm

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.

ruby -e 'puts `rpmdep glibc`.split(",")[2..-1]'
whichpkg() { rpm -qf "[email protected]"; }
2011-07-05 23:39:32
User: flatcap
Functions: rpm
Tags: rpm

Find the package a file belongs to on an rpm-based distro.

summpkg() { rpm -qfi "[email protected]"; }
2011-07-05 23:39:24
User: flatcap
Functions: rpm
Tags: rpm

Find information about the rpm package which owns a certain file.

sudo rpm -if "http://rpm_server/rpm_repo/this-app.rpm"
rpm -qp --scripts package.rpm
rpm2cpio package.rpm |cpio -dimv
yum --disablerepo=* --enablerepo=epel list available
2010-05-19 13:26:39
User: w00binda
Tags: rpm yum

How to list just one repo with yum. First I disable all repo, second I enable just the repo that I want to list.

rpm -q -a --qf '%10{SIZE}\t%{NAME}\n' | sort -k1,1n
parse_rpm() { RPM=$1;B=${RPM##*/};B=${B%.rpm};A=${B##*.};B=${B%.*};R=${B##*-};B=${B%-*};V=${B##*-};B=${B%-*};N=$B;echo "$N $V $R $A"; }
2009-12-19 20:07:26
User: bhepple
Tags: rpm

parse_rpm xorg-x11-fonts-ISO8859-1-75dpi-7.1-2.1.el5.noarch.rpm

xorg-x11-fonts-ISO8859-1-75dpi 7.1 2.1.el5 noarch

It's a little tricky because RPM names can contain '-' and the name, version and release number can contain '.' This is one or two orders of magnitude faster than using rpm itself:

rpm -qp --queryformat '%{N} %{V} %{R} %{ARCH}\n' $RPM
for i in `rpm -qva | sort ` ; do ; echo "===== $i =====" ; rpm -qvl $i ; done > /tmp/pkgdetails
2009-07-14 20:34:55
User: tkunz
Functions: echo rpm sort

This will create the file /tmp/pkgdetails, which will contain a listing of all the files installed on your RPM-based system (RedHat, Fedora, CentOS, etc). Useful should the RPM system/database become corrupted to find which package installed which files.

rpm -qa --qf '%{name}-%{version}-%{release}.%{arch}\n'
2009-03-24 20:42:17
User: llama
Functions: rpm
Tags: rpm

The queryformat option can be used in a number of ways to find things like duplicate packages, wrong arch, or the exact package to pass to rpm -e, yum remove, etc.

rpm -Va | grep -v "\.\.\.\.\.\.\.T"
rpm -qa \*code\*
2009-03-11 21:16:23
User: alcik
Functions: rpm
Tags: rpm

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.

rpm -qif `which more`
2009-02-27 08:59:07
User: alcik
Functions: rpm
Tags: rpm which

Replace 'more' command with any command which is in your PATH.

rpm -qa | grep PACKAGENAME | xargs rpm -q --filesbypkg
2009-02-26 14:32:12
User: piscue
Functions: grep rpm xargs

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