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





All commands from sorted by
Terminal - All commands - 12,273 results
rename -v 's/ /_/g' *
tr : '\n' <<<$PATH
sed 's/:/\n/g' <<<$PATH
ls *.c | while read F; do gcc -Wall -o `echo $F | cut -d . -f 1 - ` $F; done
2009-08-28 13:01:56
User: pichinep
Functions: cut gcc ls read

Compile *.c files with "gcc -Wall" in actual directory, using as output file the file name without extension.

URL="http://www.google.com";curl -L --w "$URL\nDNS %{time_namelookup}s conn %{time_connect}s time %{time_total}s\nSpeed %{speed_download}bps Size %{size_download}bytes\n" -o/dev/null -s $URL
mencoder -of avi -ovc lavc movie.avi -o movie2.avi; ffmpeg -i movie2.avi -r 12 -b 100 movie.flv
2009-08-28 11:05:21
User: dcabanis

First, we convert the VMware avi (VMnc format) to the Microsoft avi format. Next, we convert the Microsoft avi format to FLV format.

You can play around with the -r switch (rate per second) and the -b switch (bitrate). But, if those get larger, so does your FLV file.

find . -type f -exec dos2unix {} +
dig google.com
2009-08-28 04:32:52
User: unixbhaskar
Functions: dig
Tags: dns

It is a much better tool then nslookup for getting information about the any site.It has got better capability too.For reverse information please use the switch "-x" and the ip address.

ethtool eth0
2009-08-28 04:22:03
User: unixbhaskar

This is an commandline utility to get fair piece of information about the attached network card.

2009-08-28 04:14:42
User: unixbhaskar

A wonderful command line utility to check the internet usage. It has got so many useful switch to display the data you want.Please visit the man page to get all the information.Get it from this website http://humdi.net/vnstat

sudo /bin/netstat -tpee
2009-08-28 04:02:10
User: unixbhaskar
Functions: sudo
Tags: shell

To get the connection information of protocol tcp and extended infortmation.

dstat -afv
2009-08-28 03:53:24
User: unixbhaskar
Tags: shell

As mentioned in the summery that it is a powerful command to monitor system activity in great way. It has got the power of vmstat,iostat,mpstat,df,free and sar.Instead of firing each single command separately ,one can fire one single command to get all the info at once.But there is a way to get the individual information too. Please see the man page . You can get it from here : http://dag.wieers.com/home-made/dstat/

du -s `find . -maxdepth 1 \! -name '.'` | sort -n | tail
ssh -t hostA ssh hostB
2009-08-27 21:35:19
User: 0x89
Functions: ssh

Of course you need to be able to access host A for this ;-)

ls | while read f; do mv "$f" "${f// /_}";done
print -l $path
2009-08-27 16:33:04
User: Mikachu
Tags: zsh PATH

This doesn't work in bash, but in zsh you can typeset -T to bind a scalar variable to an array. $PATH and $path behave this way by default.

curl -s wap.kitco.com/exrate.wml | awk ' BEGIN { x=0; FS = "<" } { if ($0~"^<br/>") {x=0} if (x==1) {print $1} if ($0~"EUR/US") {x=1} }'
2009-08-27 16:30:19
User: jamaese
Functions: awk

You can get others rates changing the "EUR/US" part. look at the url: wap.kitco.com/exrate.wml to get more options.

at 6:00 <<< "xmms2 play"
2009-08-27 16:30:07
User: Mikachu
Functions: at

I like the order of the arguments better this way.

sudo find /var/log/ -mtime -7 -type f | xargs du -ch | tail -n1
2009-08-27 14:18:47
User: alvinx
Functions: du find sudo tail xargs

get diskusage of files (in this case logfiles in /var/log) modified during the last n days:

sudo find /var/log/ -mtime -n -type f | xargs du -ch

n -> last modified n*24 hours ago

Numeric arguments can be specified as

+n for greater than n,

-n for less than n,

n for exactly n.

=> so 7*24 hours (about 7 days) is -7

sudo find /var/log/ -mtime -7 -type f | xargs du -ch | tail -n1
qdbus org.kde.screenlocker /MainApplication quit
2009-08-27 13:57:00
User: Alanceil

The unlock command for KDE 4.3 has changed from krunner_lock, this process doesn't exist anymore. So here's the update :-)

If qdbus complains about not being able to find X, put a "DISPLAY=:0 " (:0 being your X server display) in front of the command.

for x in `seq 0 25 $(curl "http://www.commandlinefu.com/commands/browse"|grep "Terminal - All commands" |perl -pe 's/.+(\d+),(\d+).+/$1$2/'|head -n1)`; do curl "http://www.commandlinefu.com/commands/browse/sort-by-votes/plaintext/$x" ; done > a.txt
2009-08-27 11:02:53
User: SuperFly
Functions: grep head perl

'jot' does not come with most *nix distros, so we need to use seq to make it work. This version tested good on Fedora 11.

echo "${PATH//:/$'\n'}"
ssh middlehost "ssh -a root@securehost '> nicescript'" < nicescript
2009-08-26 20:25:12
User: 0x89
Functions: ssh
Tags: ssh scp

Stop tormenting the poor animal cat!

Also you should not that you need a private key not protected by a passphrase on middlehost that grants you access to securehost..

cat /service/solr/log/main/current | tai64nlocal | grep "\(`date '+%F %H'`\|`date '+%F %H %M' | awk '{print $1" 0"$2-1":"$3}'`\)" | grep QTime | awk '{print $NF}' | awk -F\= '{ s += $2} END {print s/NR}'
sudo aptitude unmarkauto $(apt-cache depends some-deb-meta-package-name | grep Depends | cut -d: -f2)
2009-08-26 12:56:33
User: yra
Functions: cut grep sudo

Debian: Mark all dependent packages as manually installed. So they are not automatically removed if you remove some meta package - like gnome-desktop-environment for example.