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/
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.
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
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:
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.
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.
This will list all installed packages on a RedHat/CentOS based system, sort them alphabetically, Parse off the version numbers, and delete any duplicate entries.
This is good if you need to build out a mirrored system or rebuild a failing system.
Find the package a file belongs to on an rpm-based distro.
Description is moved to "Sample output" because the html sanitizer for commandlinefu breaks the examples..
For Linux distributions using rpm (eg Mandriva), this command will find the rpm package name that provides a file.
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
If you want to relocate a package on your own, or you just want to know what those PREIN/UN and POSTIN/UN scripts will do, this will dump out all that detail simply.
You may want to expand the egrep out other verbose flags like CHANGELOGTEXT etc, as your needs require.
It isn't clear, but the formatting around $tag is important: %{$tag} just prints out the first line, while [%{$tag }] iterates thru multi-line output, joining the lines with a space (yes, there's a space between the g and } characters. To break it out for all newlines, use [%{$tag\n}] but the output will be long.
This is aside from rpm2cpio | cpio -ivd to extract the package files.
This should work on any RPM-based distribution. It's more reliable than trying to parse the content of the files.
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.
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
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.