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.

If you have a new feature suggestion or find a bug, please get in touch via http://commandlinefu.uservoice.com/

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.

Universal configuration monitoring and system of record for IT.

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 using rpm from sorted by
Terminal - Commands using rpm - 48 results
rpm -ivh 'http://www.website.com/path/to/desired_software_package.rpm'
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
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 --queryformat "%{NAME} %{ARCH}\n"
rpm -q kernel-2* | grep -v $(uname -r) | xargs yum erase -y
2009-03-28 21:41:15
User: Nick
Functions: grep rpm uname xargs

On Fedora clean the boot directory; erase older kernel

rpm -q --qf "%{VERSION}\n" redhat-release
2009-03-25 16:46:14
User: atoponce
Functions: rpm

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
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 --queryformat "%{NAME} %{ARCH}\n"
2009-03-18 15:19:21
User: angrox
Functions: rpm

Lists all installed RPM packages with name and architecture, which is useful to check for compability packages (+ required i386 packages) on a 64bit system.

rpm -qa --queryformat '%{installtime} \"%{vendor}\" %{name}-%{version}-%{release} %{installtime:date}\n' | grep "Thu 05 Mar"
2009-03-17 13:38:20
User: mpb
Functions: grep rpm

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

rpm -qa --qf '%{SIZE} %{NAME}\n' | sort -nr | nl | head -6 # six largest RPMs
2009-03-15 22:18:17
User: mpb
Functions: head nl rpm sort

Low on disk space? Check the largest installed RPMs for delete canditates.

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

rpm -qa --qf '%{name}-%{version}-%{release}.%{arch}\n'|egrep 'compat|glibc|gcc|libst|binu'|sort
2009-02-23 10:17:47
User: ovalerio
Functions: rpm

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.

rpm -qa --queryformat 'Installed on %{INSTALLTIME:date}\t%{NAME}-%{VERSION}-%{RELEASE}: %{SUMMARY}\n'
rpm -e --allmatches filename.rpm
2009-02-12 23:09:24
User: sohaileo
Functions: rpm

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.

rpm -qlp <package.rpm>
2009-02-07 23:11:59
User: al3x
Functions: rpm

allows to check inside rpm file w/o installing it

rpm -qa --qf '%{name}'
rpm -qa --last
rpm --query --filesbypackage [packagename]
find $PWD -exec rpm --query -f {} \; | sort -u | grep -v "not owned"
2009-02-05 19:33:43
User: wwest4
Functions: find grep rpm sort

shows all RPMs with files in the current directory & its subdirectories.

rpm -qa --last
2009-02-05 16:00:56
User: systemj
Functions: rpm

the newest rpms are at the top; individual packages can also be queried this way:

rpm --last -q package