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.

Universal configuration monitoring and system of record for IT.

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:



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!

Top Tags





Commands using echo from sorted by
Terminal - Commands using echo - 1,303 results
echo capitalize | { dd bs=1 count=1 conv=ucase 2> /dev/null; cat ;}
echo "SECRET MESSAGE" | gpg -e --armor -s | sendmail USER@DOMAIN.COM
2009-09-04 20:47:12
User: flip387
Functions: echo gpg sendmail

A very simple command to send a signed and encrypted message from the command line using GPG Keys

du -a --max-depth=1 | sort -n | cut -d/ -f2 | sed '$d' | while read i; do if [ -f $i ]; then du -h "$i"; else echo "$(du -h --max-depth=0 "$i")/"; fi; done
2009-09-03 20:43:43
User: nickwe
Functions: cut du echo read sed sort

Based on the MrMerry one, just add some visuals to differentiate files and directories

find . -maxdepth 1 -type d|xargs du -a --max-depth=0|sort -rn|cut -d/ -f2|sed '1d'|while read i;do echo "$(du -h --max-depth=0 "$i")/";done;find . -maxdepth 1 -type f|xargs du -a|sort -rn|cut -d/ -f2|sed '$d'|while read i;do du -h "$i";done
2009-09-03 20:33:21
User: nickwe
Functions: cut du echo find read sed sort xargs

Based on the MrMerry one, just add some visuals and sort directory and files

echo $((3.0/5.0))
echo sortmeplease|sed 's/./&\n/g'|sort|tr -d '\n'
echo sortmeplease | awk '{l=split($1,a,"");asort(a);while(x<=l){printf "%s",a[x];x++ }print "";}'
2009-09-03 10:22:39
User: foob4r
Functions: awk echo

using awk

missed the last char thanks @Josay

echo {1..199}" sheep," | espeak -v english -s 80
2009-09-03 10:08:12
User: MrMerry
Functions: echo

Can change language and speed, see espeak man page for options. (Install espeak in your linux distro via yum or apt-get)

For insomniacs you may need to enclose in a while true; do ...; done loop ;)

echo sortmeplease | grep -o . | sort | tr -d '\n'; echo
2009-09-03 00:52:49
User: MrMerry
Functions: echo grep sort tr

Sorts a character string, using common shell commands.

echo "5 k 3 5 / p" | dc
2009-09-03 00:21:54
User: xamaco
Functions: echo

using bc is for sissies. dc is much better :-D

Polish notation will rule the world...

for dnsREC in $(curl -s http://www.iana.org/assignments/dns-parameters |grep -Eo ^[A-Z\.]+\ |sed 's/TYPE//'); do echo -n "$dnsREC " && dig +short $dnsREC IANA.ORG; done
xmms2 pause && echo "xmms2 play" | at now +5min
2009-08-30 04:35:10
User: Vrekk
Functions: at echo

you can also run "xmms2 pause & at now +5min

echo "${PATH//:/$'\n'}"
for i in 192.168.1.{61..71};do ping -c 1 $i &> /dev/null && echo $i;fi;done
2009-08-26 06:04:24
User: AlecSchueler
Functions: echo ping
Tags: Network ssh bash

If you need to ssh into a computer on the local network but you're unsure of the ip to use, then ping them and see if you get a response. If you do, print out the address you got it from. Adjust the range to suit your network.

echo "xmms2 play" | at 6:00
2009-08-26 04:20:24
User: Vrekk
Functions: at echo

Nice little alarm clock to wake you up on time (hopefully).

You can also do 'echo "vlc path/to/song" | at 6:00

echo "0t${currentEpoch}=Y" | /usr/bin/adb
2009-08-25 12:17:01
User: verboEse
Functions: echo

this works on Solaris, so not better than the "only-GNU"-tool :-(

I think, there is no one-liner for this, that will work on all *nix-es

echo "aBcDeFgH123" | tr a-z A-Z
echo 1234567890 | awk '{ print strftime("%c", $0); }'
2009-08-25 09:37:54
User: alvinx
Functions: awk echo

- convert unixtime to human-readable with awk

- useful to read logfiles with unix-timestamps, f.e. squid-log:

sudo tail -f /var/log/squid3/access.log | awk '{ print strftime("%c ", $1) $0; }

echo `date +%m/%d/%y%X |awk '{print $1;}' `" => "` cat /proc/acpi/thermal_zone/THRM/temperature | awk '{print $2, $3;}'` >> datetmp.log
2009-08-24 21:26:29
User: ninadsp
Functions: awk cat echo

Uses the data in the /proc system, provided by the acpid, to find out the CPU temperature. Can be run on systems without lm-sensors installed as well.

y=http://www.youtube.com;for i in $(curl -s $f|grep -o "url='$y/watch?v=[^']*'");do d=$(echo $i|sed "s|url\='$y/watch?v=\(.*\)&.*'|\1|");wget -O $d.flv "$y/get_video.php?video_id=$d&t=$(curl -s "$y/watch?v=$d"|sed -n 's/.* "t": "\([^"]*\)",.*/\1/p')";done
2009-08-22 21:31:29
User: matthewbauer
Functions: echo grep sed

This will download a Youtube playlist and mostly anything http://code.google.com/apis/youtube/2.0/reference.html#Video_Feeds

The files will be saved by $id.flv

pgrep -u `id -u` firefox-bin || find ~/.mozilla/firefox -name '*.sqlite'|(while read -e f; do echo 'vacuum;'|sqlite3 "$f" ; done)
2009-08-22 10:36:05
User: kamathln
Functions: echo find read

Sqlite database keeps collecting cruft as time passes, which can be cleaned by the 'vacuum;' command. This command cleans up the cruft in all sqlite files relating to the user you have logged in as. This command has to be run when firefox is not running, or it will exit displaying the pid of the firefox running.

for u in `cut -f1 -d: /etc/passwd`; do echo -n $u:; groups $u; done | sort
2009-08-22 09:06:02
User: hemanth
Functions: echo groups
Tags: sort cut for groups

"cut" the user names from /etc/passwd and then running a loop over them.

echo $(( $RANDOM % 10 + 1 ))
echo init 0 | at now + 2 hours
echo "scale=4; 3 / 5" | bc
2009-08-21 21:51:46
User: foob4r
Functions: echo

allows you to use floating point operations in shell scripts