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 dzup from sorted by
Terminal - Commands by dzup - 16 results
scrotit(){ echo "Screenshot in $1 seconds...";scrot -d $1 '%Y%m%d%h.png' -e 'curl -sF file1=@- http://ompldr.org/upload < $f | grep -P -o "(?<=File:).*(http://ompldr.org/.*)\<\/a\>";rm $f'| sed -r 's@.*(http://ompldr.org/\w{1,7}).*@\1@';}
2012-12-03 01:21:19
User: dzup
Functions: echo grep rm sed
0

Take a screenshot, give $1 seconds pause to choose what to screenshot, then upload and get URI of post in ompdlr.org

omp(){ $*|convert label:@- png:-|curl -sF file1=@- http://ompldr.org/upload | grep -P -o "(?<=File:).*(http://ompldr.org/.*)\<\/a\>" | sed -r 's@.*(http://ompldr.org/\w{1,7}).*@\1@';}
2012-12-02 19:35:29
User: dzup
Functions: grep sed
1

Create a .png from output command or whatever, the upload and give URI from ompdlr.org

scrot -d 3 '/tmp/%Y-%m-%d_$wx$h.png' -e 'cat $f'|curl -F "image=@-" -F "key=1913b4ac473c692372d108209958fd15" http://api.imgur.com/2/upload.xml|grep -Eo "<original>(.)*</original>" | grep -Eo "http://i.imgur.com/[^<]*"
2012-11-13 21:16:09
User: dzup
Functions: grep
0

That its my personal key that i dont use, if you want yours, go to imgur and get it, or use that one

python -m SimpleHTTPServer 8000 &; sudo localtunnel -k ~/.ssh/id_rsa.pub 8000
2012-10-30 17:52:14
User: dzup
Functions: python sudo
0

you need ruby gems and localtunnel, further instruction on their website

for ubuntu precise, just intall ...

sudo apt-get install ruby ruby1.8-dev rubygems1.8 libopenssl-ruby

sudo gem install localtunnel

ssh-keygen -t rsa

python -m SimpleHTTPServer 8000

sudo localtunnel -k ~/.ssh/id_rsa.pub 8000

ompload() { wget -O- - "$1" --quiet|curl -# -F file1=@- http://ompldr.org/upload|awk '/Info:|File:|Thumbnail:|BBCode:/{gsub(/<[^<]*?\/?>/,"");$1=$1;print}';}
2012-10-19 22:54:55
User: dzup
Functions: awk wget
-2

Like i said, i havent test it yet, all becouse my internet its soo slow, if you try and works please share, also be nice to do it using the direct url link.

wb(){ for i in $(wget -O- -U "" "http://wallbase.cc/random/23/eqeq/1920x1080/0/" --quiet|grep wallpaper/|grep -oe 'http://wallbase.[^"]*'); do if (( n > "$1" )); then break;fi;let n++;wget $(wget -O- -U "" $i --quiet|grep -oe 'http://[^"]*\.jpg');done;}
for i in {1..10};do wget $(wget -O- -U "" "http://images.google.com/images?imgsz=xxlarge&hl=en&q=wallpaper+HD&start=$(($RANDOM%900+100))" --quiet | grep -oe 'http://[^"]*\.jpg' | head -1);done
2012-07-26 10:42:13
User: dzup
Functions: grep head wget
6

you may want &hl=en for &hl=es for the language

you may want imgsz=xxlarge for imgsz=large or whatever filter

you may want q=apples or whatever

ssh -l username server.tdl "tar -czf - /home/username/public_html" | tar -xzf -
SEED=$(head -1 /dev/urandom|od -N 1);for i in {1..10};do tmp=$(mkpasswd ${RANDOM});pass=${tmp:2:6};echo Pass $pass Crypt: $(mkpasswd $pass);done
arecord|aplay
paste(){ curl -s -S --data-urlencode "txt=$($*)" "http://pastehtml.com/upload/create?input_type=txt&result=address";echo;}
listhw(){ curl -s -S --data-urlencode "txt=$(sudo lshw -html)" "http://pastehtml.com/upload/create?input_type=html&result=address";echo;}
2011-10-07 11:16:03
User: dzup
2

In this Linux box i need to become root to get the complete hardware list, so either become root before or call it with sudo as i did, your choice.

imgur(){ convert label:@- png:-|curl -F "image=@-" -F "key=1913b4ac473c692372d108209958fd15" http://api.imgur.com/2/upload.xml|grep -Eo "<original>(.)*</original>" | grep -Eo "http://i.imgur.com/[^<]*";}
2011-09-23 20:02:22
User: dzup
Functions: grep
3

imgur < /etc/issue

% Total % Received % Xferd Average Speed Time Time Time Current

Dload Upload Total Spent Left Speed

100 2360 0 635 100 1725 1027 2792 --:--:-- --:--:-- --:--:-- 4058

http://i.imgur.com/bvbUD.png

imgur(){ $*|convert label:@- png:-|curl -F "image=@-" -F "key=1913b4ac473c692372d108209958fd15" http://api.imgur.com/2/upload.xml|grep -Eo "<original>(.)*</original>" | grep -Eo "http://i.imgur.com/[^<]*";}
2011-09-23 05:42:58
User: dzup
Functions: grep
11

My key is the anonymous one, is good for 50 post an hour with a maximun number of uploads a day, probably will run out, if that happend you can get a free key at the site.

for file in $(find ~/ -iname "*.mp3");do c=$(mp3info $file|grep Genre|cut -f 3 -d :|cut -f 2 -d " ");if [ -z "$c" ];then c="Uncategorized";fi;if [ ! -e $c ];then touch $c.m3u;fi;echo "$file">>$c.m3u;done
for((i=0;i<10;i++)) do tmp=`wget -O- -U "" "http://images.google.com/images?imgsz=xxlarge&hl=es&q=wallpaper&sa=N&start=$(($RANDOM%700+100))&ndsp=10" --quiet|grep -oe 'http://[^"]*\.jpg'|head -1`;[[ $tmp != "" ]] && wget $tmp || echo "Error $[$i+1]";done