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.
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:
In this case the current user has proxy variable set which allows access to the rpm on the internet but needs root privs to install it.
Running sudo -E preserves the current user proxy var and allows the rpm install to be executed with sudo.
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
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 ;)
This will remove the gpg-pubkey-1aa043b8-53b2e946 from rpm/yum and you'll be prompted to add it back from the given repo.
This will list all the gpg keys that were accepted and installed for yum.
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.