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.


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.

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

2011-03-12 - Confoo 2011 presentation
Slides are available from the commandlinefu presentation at Confoo 2011: http://presentations.codeinthehole.com/confoo2011/
2011-01-04 - Moderation now required for new commands
To try and put and end to the spamming, new commands require moderation before they will appear on the site.
2010-12-27 - Apologies for not banning the trolls sooner
Have been away from the interwebs over Christmas. Will be more vigilant henceforth.
2010-09-24 - OAuth and pagination problems fixed
Apologies for the delay in getting Twitter's OAuth supported. Annoying pagination gremlin also fixed.
Hide

Tags

Hide

Functions

Commands by darkfader from sorted by
Terminal - Commands by darkfader - 5 results
find /Applications -type d -maxdepth 1 -exec sh -c 'echo "{}"; (plutil -convert xml1 -o - "{}/Contents/Info.plist" | xpath /dev/stdin "concat(\"v\", /plist/dict/string[preceding-sibling::key[1]=\"CFBundleShortVersionString\"]/node())" 2>/dev/null)' \;
2013-03-29 14:01:23
User: darkfader
Functions: find sh
Tags: osx
-1

Uses find, plutil and xpath.

Note: Some applications don't have proper information. system_profiler might be better to use.

It's a bit slow query.

Due to command length limit, I removed -name "*.app" and CFBundleName.

echo "javascript:location.href='http://www.commandlinefu.com/commands/matching/'+encodeURIComponent('%s')+'/'+btoa('%s')+'/sort-by-votes'"
2011-03-07 22:01:46
User: darkfader
Functions: echo
-1

If you add the bookmarklet to your browser's bookmarks with like say, the keyword 'cfu', you can for example type 'cfu hello' in the location bar and the %s gets replaced with 'hello'.

The bookmarklet will convert the search text to base64 for use with the commandlinefu website and will take you there. Tested with Firefox.

alias sshdo='ssh -q -t root@localhost -- cd $PWD \&\& sudo'
2010-10-20 22:33:22
User: darkfader
Functions: alias cd
Tags: sudo su ssh-agent
-2

Run program as root by SSH key forwarding instead of sudoers.

Put this alias line in .bashrc or wherever you like. Alias arguments might need extra escaping.

You might wonder about security. But you'd block out root login as much as possible of course. In sshd_config you put this:

PermitRootLogin no

Match Address 127.0.0.1

  PermitRootLogin without-password

for p in `grep -v deinstall /var/mobile/Library/Preferences/aptbackup_dpkg-packages.txt | cut --fields=1`; do apt-get -y --force-yes install $p; done
2010-10-11 22:41:55
User: darkfader
Functions: cut install
1

Use when aptbackup will not start or you just want to see what's going on.

ssh-keygen -f ~/.ssh/id_rsa -p
2010-07-19 12:53:35
User: darkfader
Functions: ssh ssh-keygen
3

Protects your secret identity with a passphrase.

OSX 10.6 automatically does key forwarding and can store the passphrase in the keychain.

For other OSes, use ssh -A or set ForwardAgent in ssh_config to enable forwarding. Then use ssh-agent/ssh-add.