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.
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:
Wow, didn't really expect you to read this far down. The latest iteration of the site is in open beta. It's a gentle open beta-- not in prime-time just yet. It's being hosted over at UpGuard (link) and you are more than welcome to give it a shot. Couple things:
Most distributions alias cp to 'cp -i', which means when you attempt to copy into a directory that already contains the file, cp will prompt to overwrite. A great default to have, but when you mean to overwrite thousands of files, you don't want to sit there hitting [y] then [enter] thousands of times.
Enter the backslash. It runs the command unaliased, so as in the example, cp will happily overwrite existing files much in the way mv works.
# AllInOne: Update what packages are available, upgrade to new versions, remove unneeded packages
# (some are no longer needed, replaced by the ones from ap upgrade), check for dependencies
# and clean local cached packages (saved on disk but not installed?,some are needed? [this only cleans unneeded unlike ap clean]).
# aliases (copy into ~/.bashrc file):
a r='ap autoremove -y'
a up='ap update'
a u='up && ap upgrade -y --show-progress && r && ap check && ap autoclean'
# && means "and run if the previous succeeded", you can change it to ; to "run even if previous failed".
I'm not sure if ap check should be before or after ap upgrade -y, you can also change the alias names.
# To expand aliases in bash use ctrl alt e or see this ow.ly/zBKHs
# For more useful aliases go to ow.ly/zBMOx
Search, find and list aliases that match a regexp.
# basic search example:
# loose search example:
# remember to double escape special characters; example:
Simply sourcing .bashrc does not function correctly when you edit it and change an alias for a function or the other way round with the *same name*.
I therefor use this function. Prior to re-sourcing .bashrc it unsets all aliases and functions.
You may want to just use the shortcut "." instead of "source"
Any changes to BASH shell made in .bashrc will be active in the current terminal window from the moment you execute this command, ie. aliases, prompt settings etc. No need to restart terminal.
(In BASH 'source' simile to 'eval' lets you generally execute any bunch of commands stacked in a text file).
When setting up a new aliases file, or having creating a new file.. About every time after editing an aliases file, I source it. This alias makes editing alias a bit easier and they are useful right away. Note if the source failed, it will not echo "aliases sourced".
Sub in vi for your favorite editor, or alter for ksh, sh, etc.
In Bash, when defining an alias, one usually loses the completion related to the function used in that alias (that completion is usually defined in /etc/bash_completion using the complete builtin).
It's easy to reuse the work done for that completion in order to have smart completion for our alias.
That's what is done by this command line (that's only an example but it may be very easy to reuse).
Note 1 : You can use given command line in a loop "for old in apt-get apt-cache" if you want to define aliases like that for many commands.
Note 2 : You can put the output of the command directly in your .bashrc file (after the ". /etc/bash_completion") to always have the alias and its completion
The example command deletes all aliases for network interface 'em0' assuming that the aliases have netmask of 255.255.255.255 and the master IP has some other netmask (such as 255.255.255.0). See here -> http://my.galagzee.com/2009/07/22/deleting-all-network-interface-aliases/ for more on the rationale of this command.