Hide

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.

Universal configuration monitoring and system of record for IT.
Hide

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:

Hide

News

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!
Hide

Top Tags

Hide

Functions

Psst. Open beta.

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:

  • » The open beta is running a copy of the database that will not carry over to the final version. Don't post anything you don't mind losing.
  • » If you wish to use your user account, you will probably need to reset your password.
Your feedback is appreciated via the form on the beta page. Thanks! -Jon & CLFU Team

ssh autocomplete based on ~/.ssh/config

Terminal - ssh autocomplete based on ~/.ssh/config
perl -ne 'print "$1 " if /^Host (.+)$/' ~/.ssh/config
2011-08-21 14:51:20
User: bashrc
Functions: perl
5
ssh autocomplete based on ~/.ssh/config

I use this in my bashrc to expand hosts defined in ~/.ssh/config:

function _ssh_completion() {

perl -ne 'print "$1 " if /^Host (.+)$/' ~/.ssh/config

}

complete -W "$(_ssh_completion)" ssh

Here's a great article on how to setup your own ~/.ssh/config:

http://blogs.perl.org/users/smylers/2011/08/ssh-productivity-tips.html

Alternatives

There are 3 alternatives - vote for the best!

Terminal - Alternatives
complete -W "$(echo $(grep '^ssh ' .bash_history | sort -u | sed 's/^ssh //'))" ssh
2009-07-25 23:07:25
User: 0x89
11

Stop tormenting the poor animal cat. See http://sial.org/howto/shell/useless-cat/.

Edit:

replaced

sort | uniq

by

sort -u
complete -W "$(echo `cat ~/.ssh/known_hosts | cut -f 1 -d ' ' | sed -e s/,.*//g | uniq | grep -v "\["`;)" ssh
2009-07-23 15:59:55
User: viner
3

Add to your bash profile to minimize carpal tunnel syndrome.

Doesn't work with [email protected] but appending "-l user" works fine if needed.

Works for ping as well..

complete -W "$(echo `cat ~/.ssh/known_hosts | cut -f 1 -d ' ' | sed -e s/,.*//g | uniq | grep -v "\["`;)" ping

complete -o default -o nospace -W "$(grep -i -e '^host ' ~/.ssh/config | awk '{print substr($0, index($0,$2))}' ORS=' ')" ssh scp sftp
2013-11-19 14:44:41
User: Wamith
Functions: scp ssh
1

I sue this in my .bashrc file

This will also do auto-completion for scp and sftp

complete -W "$(echo $(grep ^Host ~/.ssh/config | sed -e 's/Host //' | grep -v "\*"))" ssh
2014-09-20 19:16:24
User: nathancahill
1

Autocomplete from .ssh/config

complete -W "$(sed 's/;.*//;' /etc/hosts | awk ' /^[[:digit:]]/ {$1 = "";print tolower($0)}')" ssh
2011-06-20 03:54:45
User: daodennis
0

If you have a lot of hosts in /etc/hosts this would be very useful. Anyone have any more concise examples?

Know a better way?

If you can do better, submit your command here.

What others think

I would use a pattern like

/^\s*Host\s*=\s*(.+)$/

(My config uses "Host=name")

Comment by dbbolton 282 weeks and 3 days ago

As everyone knows of which Mentor is always making brand-new handbags in various series. That is why, many instructor clients are happy to understand the completely new entrance involving mentor handbags in many different designs and styles. New coach bags come in a number of selections such as Poppy series, Kristine collection, Julia collection and many others. Listed below are the newest choices of new trainer handbags that you could take into account about:Coach Madison Collection .Madison variety would be the previous selection however some people enjoy the particular handbag kind of that series. That's the reason Mentor always makes along with changes the actual Madison series along with completely new arrival on the Coach handbags. Get to illustrate Trainer Madison Maggie, you'll find that bag in every time every yr. For the reason that from the design and style regarding Trainer Madison Maggie which might be usually basic and lovely. This specific bag is an ideal bag for ladies to cart in numerous instances. It really is very ideal carry handbags for any kind of women.Coach Julia Assortment .Julia collection would be the completely new Trainer bags series together with the kind of glenohumeral joint handbags. Fresh mentor Julia handbags are made of synthetic leather or trademark textile using the natural leather lean. They may be suitable for women who adore leather-based bags throughout shoulder or maybe hobo handbags fashion. You can get a Brand-new Julia Buckskin Make Bag for that major dimension you can also get Julia Article author Handle on top Tote with the little choice.Coach Poppy Selection .Because of the use of the particular Poppy variety, Private coach carries on generating great glamor form of mentor handbag in Poppy series. Coach Poppy handbags are incredibly multi-colored in addition to glamor while using fantastic form of coloration combo. You can obtain a Brand new Poppy Graffiti Fashion Tote to the huge sizing just one additionally, you can in addition take a Completely new Poppy Author Art work Cool Bag intended for various other use of small bag.Actually there are lots of additional brand new series available just like Mentor Charm series, Coach Beachfront assortment, Mentor Kristin assortment, and also Coach Peyton assortment. All those are generally previously mentioned just a couple example of the modern introduction regarding instructor handbags that you can imagine.You know you can always find great options to opt for if you wish to find fantastic handbags by Instructor. Consider the style http://www.hermesbeltsbirkinkellybag.co.uk/ current market presently, many women have become aficionado to discuss trainer totes as well as handbags. They will really like these individuals in addition to get all of them as the greatest developer handbag collection.

Comment by stephanieg915 2 days ago

www.canadagoosefemmehomme2016.fr/canada-goose-chapka_342.html,www.canadagoosefemmehomme2016.fr/canada-goose-victoria_293.html,www.canadagoosefemmehomme2016.fr/doudoune-canada-goose-rose_421.html,www.canadagoosefemmehomme2016.fr/canada-goose-destockage_165.html,www.canadagoosefemmehomme2016.fr/canada-goose-doudoune-sans-manche_166.html,www.canadagoosefemmehomme2016.fr/magasin-canada-goose-new-york_396.html,www.canadagoosefemmehomme2016.fr/doudoune-canada-goose-d-occasion_466.html,www.canadagoosefemmehomme2016.fr/canada-goose-ou-parajumpers_414.html,www.canadagoosefemmehomme2016.fr/foxe-bomber-canada-goose_392.html,www.canadagoosefemmehomme2016.fr/parka-canada-goose-homme_376.html,www.canadagoosefemmehomme2016.fr/parka-canada-goose-homme-pas-cher_419.html,www.canadagoosefemmehomme2016.fr/boutique-canada-goose-paris_302.html,www.canadagoosefemmehomme2016.fr/canada-goose-lyon_237.html,www.canadagoosefemmehomme2016.fr/canada-goose-site-fiable_136.html,www.canadagoosefemmehomme2016.fr/canada-goose-200_411.html,www.canadagoosefemmehomme2016.fr/canada-goose-snow-mantra-parka_479.html,www.canadagoosefemmehomme2016.fr/heatherton-canada-goose_484.html,www.canadagoosefemmehomme2016.fr/canada-goose-femme-noir_48.html,www.canadagoosefemmehomme2016.fr/canada-goose-trillium_454.html,www.canadagoosefemmehomme2016.fr/canada-goose-huron-bomber_437.html,www.canadagoosefemmehomme2016.fr/canada-goose-doudoune-sans-manche-homme_291.html,www.canadagoosefemmehomme2016.fr/canada-goose-canada-prix_284.html,www.canadagoosefemmehomme2016.fr/canada-goose-montreal_267.html,www.canadagoosefemmehomme2016.fr/canada-goose-expedition-homme_207.html,www.canadagoosefemmehomme2016.fr/le-bon-coin-canada-goose_157.html,www.canadagoosefemmehomme2016.fr/canada-goose-chelsea_326.html,www.canadagoosefemmehomme2016.fr/canada-goose-foxe_91.html,www.canadagoosefemmehomme2016.fr/canada-goose-fourrure_377.html,www.canadagoosefemmehomme2016.fr/revendeur-canada-goose-paris_266.html,www.canadagoosefemmehomme2016.fr/canada-goose-toronto-outlet_483.html,www.canadagoosefemmehomme2016.fr/manteau-goose-canada-femme_149.html,www.canadagoosefemmeh

Comment by sguerra376 1 day ago

www.canadagoosefemmehomme2016.fr/canada-goose-kensington-parka-femme_448.html

www.canadagoosefemmehomme2016.fr/manteau-femme-canada-goose_248.html

www.canadagoosefemmehomme2016.fr/vente-de-canada-goose_361.html

www.canadagoosefemmehomme2016.fr/canada-goose-doudoune-femme_69.html

www.canadagoosefemmehomme2016.fr/doudoune-canada-goose-occasion_150.html

www.canadagoosefemmehomme2016.fr/canada-goose-magasin_239.html

www.canadagoosefemmehomme2016.fr/canada-goose-longue-homme_301.html

www.canadagoosefemmehomme2016.fr/canada-goose-le-bon-march��_461.html

www.canadagoosefemmehomme2016.fr/prix-d-une-canada-goose-au-canada_175.html

www.canadagoosefemmehomme2016.fr/canada-goose-paris-magasin_420.html

www.canadagoosefemmehomme2016.fr/canada-goose-grise-femme_269.html

www.canadagoosefemmehomme2016.fr/canada-goose-violette_121.html

www.canadagoosefemmehomme2016.fr/canada-goose-fourrure_377.html

www.canadagoosefemmehomme2016.fr/parka-canada-goose-langford_425.html

www.canadagoosefemmehomme2016.fr/canada-goose-en-france_127.html

www.canadagoosefemmehomme2016.fr/veste-style-canada-goose_223.html

www.canadagoosefemmehomme2016.fr/canada-goose-occasion_413.html

www.canadagoosefemmehomme2016.fr/canada-goose-a-vendre_404.html

www.canadagoosefemmehomme2016.fr/trillium-parka-canada-goose_108.html

www.canadagoosefemmehomme2016.fr/parajumpers-canada-goose_203.html

www.canadagoosefemmehomme2016.fr/canada-goose-ou-parajumpers_414.html

www.canadagoosefemmehomme2016.fr/canada-goose-bomber-chilliwack_119.html

www.canadagoosefemmehomme2016.fr/canada-goose-printemps_410.html

Comment by sguerra376 14 hours ago

Your point of view

You must be signed in to comment.