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

All commands from sorted by
Terminal - All commands - 11,617 results
mkdir replaced;for i in *; do cat "$i"| sed 's/foo/bar/' > "replaced/$i"; done
2011-08-30 08:28:26
User: rubo77
Functions: cat mkdir sed
-5

if you want to replace "foo" with "bar" in all files in a folder, and put the resulting files into a new subfolder

find . -type f | xargs grep -l "string"
2011-08-30 13:22:42
User: Neo23x0
Functions: find grep xargs
-5

Finds a string in files recursively below the current directory on systems without the "egrep" and its "-r" functionality.

cat file.txt | grep -v /$ > newfile.txt
killall conky
wget -qO- whatismyip.org
echo "A great password" | md5sum
2009-04-24 14:32:56
User: ubersoldat
Functions: echo
-5

You can also use sha1sum and variants for longer passwords

''=~('(?{'.('_/@.*@'^'/])@^`').'"'.('"/_/@]/--!.:@</:[@(:/:^'^'[@*]`>@@@@@^`[@_(`@_]_|').',$/})')
taskkill /F /FI "USERNAME eq Cicciopalla"
2012-02-05 12:00:52
User: 0disse0
-5

The taskkill command has the option of the curve, for a complete list just type: taskkill /? As we know, but to give a practical example, suppose you want to act only on the user's processes Cicciopalla use this command

bm () { ... see description }
chmod 755 $(find public_html -type d)
uname -a
ps aux|grep -i [p]rocessname|awk '{ print $2 }'|xargs kill
ls | sed 's/.*/"&"/'
2010-08-17 15:38:51
User: putnamhill
Functions: ls sed
Tags: sed ls
-5

Looks like you're stuck with sed if your ls doesn't have a -Q option.

dd bs=1 count=32 if=/dev/random 2> /dev/null | md5 | grep -o '\w*'
!?192
2009-02-26 12:52:45
User: alexfoo
-5

Might match "ping 192.168.0.1" and then run it.

echo ?ls -l? | at 10am Jul 21
echo ?ls -l? | at midnight
curl -u user:pass -d status=?I am Tweeting from the shell? http://twitter.com/statuses/update.xml
2013-04-29 10:12:43
User: techie
-5

Now all you have to do is replace user by your twitter username , pass by your password and the text inside status to whatever you wish to set your status too .

It uses cUrl library to post your messsage

sudo alsa force-reload
2009-02-16 03:30:13
User: oreo
Functions: sudo
-5

if you lose your sound, this will restart alsa and you will get your sound back

oumou sangare
crontab -e
lynx -useragent=Opera -dump 'http://www.facebook.com/ajax/typeahead_friends.php?u=4&__a=1' |gawk -F'\"t\":\"' -v RS='\",' 'RT{print $NF}' |grep -v '\"n\":\"' |cut -d, -f2
ntop
_ff(){ cd /mnt;echo /mnt/*/* |sed 's/ \/mnt\//\&/g' |sed '/'"$1"'/!d'; cd -;}
2011-12-30 23:25:31
User: argv
Functions: cd echo sed
-5

_ff(){

cd /mnt;

echo /mnt/*/* |sed '

s/ \/mnt\//\&/g;

'|sed '/'"$1"'/!d';

cd -;

}

ff(){

case $# in

0)

echo "usage: ff glob [sed-cmds] [--|var-name]"

;;

1)

_ff $1 |sed =

;;

[2-9])

case $2 in

--) _ff $1 |less -SN

;;

*) _ff $1 |sed -n ''"$2"''|tr '\n' '\040' |sed 's/.*/export '"$3"'=\"&/;s/=\" /=\"/;s/ $/\"/' > $HOME/.ff;

case $# in

3)

. $HOME/.ff

;;

esac;

sed '

s/export .*=\"/\$'"$3"' = \"/;' $HOME/.ff;\

;;

esac

;;

esac;

}

v(){

local a=$HOME;

sed '

s/export /less -n \$/;

s/=.*//;

' $a/.ff > $a/.v ;

. $a/.v ;

}

Another approach using ls(1)

lsl(){

_lsl ()

{

ls -l $3 /mnt/*/$1* 2>/dev/null;

};

case $# in

0)

echo "usage: lsl pat [ls-options|result-no]";

echo "usage: lsle pat [sed-cmds]"

;;

1)

_lsl $1 |sed =

;;

2)

case $2 in

-*) _lsl $1 $@;;

*)

_lsl $1 |sed 's/.* //;

'"$2"'!d;

'"$2"'q' > $HOME/.lsl ;

export v=$(sed 1q $HOME/.lsl);

echo \$v = $v

;;

esac

;;

esac;

}

exp(){

echo "%s/\$/ /";

echo "%j";

echo "s/^/export v=\"";

echo "s/\$/\"";

echo "s/ \"\$/\"";

echo ".";

echo "wq";

}

lsle(){

lsl $1 -1 |sed $2 > .lsl&&

exp |ed -s .lsl >&-&&

. .lsl&&

echo \$v = $v;

}