Commands by darkfader (5)

  • 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. Show Sample Output


    -1
    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)' \;
    darkfader · 2013-03-29 14:01:23 4
  • 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. Show Sample Output


    -2
    echo "javascript:location.href='http://www.commandlinefu.com/commands/matching/'+encodeURIComponent('%s')+'/'+btoa('%s')+'/sort-by-votes'"
    darkfader · 2011-03-07 22:01:46 4
  • 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


    -2
    alias sshdo='ssh -q -t root@localhost -- cd $PWD \&\& sudo'
    darkfader · 2010-10-20 22:33:22 8
  • Use when aptbackup will not start or you just want to see what's going on. Show Sample Output


    1
    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
    darkfader · 2010-10-11 22:41:55 7
  • 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. Show Sample Output


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

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. 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.

Share Your Commands


Check These Out

List your interfaces and MAC addresses

List .log files open by a pid
Uses lsof to display the full path of ".log" files opened by a specified PID.

Lists the supported memory types and how much your board can support.

Show running services (using systemctl)

Reset terminal that has been buggered by binary input or similar

Find default gateway

list block devices
Shows all block devices in a tree with descruptions of what they are.

One command line web server on port 80 using nc (netcat)
Very simple web server listening on port 80 will serve index.html file or whatever file you like pointing your browser at http://your-IP-address/index.html for example. If your web server is down for maintenance and you'd like to inform your visitors about it, quickly and easily, you just have to put into the index.html file the right HTML code and you are done! Of course you need to be root to run the command using port 80.

Getting the last argument from the previous command

Search gpg keys from commandline


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: