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,274 results
paste -sd'+' file|bc -l
for i in $(seq 300) ; do ethtool -s eth0 autoneg on ; sleep 2 ; done
2010-10-31 18:15:54
User: christian773
Functions: seq sleep

use this comand to see which switch port your network interface is using.

but remind, there is no network traffic for 10 minutes or how long you run the comand.

if you start the comand via ssh, port will come up again after the "for loop" has endet

echo "1+2+3+4" | bc
2011-02-24 03:08:00
User: twjolson
Functions: echo

Works for any mathematical operation, even converting numbers from one base to another.

schtasks /delete /tn * /f
tac [FILE]
netstat -l -p --tcp | egrep -e 'www.*[0-9]{3,4}\/(apache2|httpd)' | awk '{print$7}'
pgrep -u username php5-fcgi | xargs kill -9
git-createrepo() { repos_path='/srv/git/'; mkdir $repos_path$1; cd $repos_path$1; git init --bare; echo "Repository location: ssh://$USER@`cat /etc/HOSTNAME``pwd`"; cd -; }
2013-05-09 21:44:24
User: batandwa
Functions: cd echo init mkdir
Tags: git

Creates a git repository in a predefined location.

find /Users/jpn/.ievms/ -type f -print0| xargs -0 du -sh
2013-10-16 09:54:19
Functions: du find xargs

When you do a ls -1 | xargs rm it wouldn't workd because those files have spaces. So you must use

find -print0 and xargs -0

for f in `find ./ -name "*.zip"` ; do p=`pwd`; d=`dirname $f`; cd $d; b=`basename $f`; unzip $b; cd $p; done
2009-05-30 03:42:53
User: packetloss
Functions: cd
Tags: find unzip

unzips all zip files in any subdirectory under the current directory. The zip files are unzipped in their respective subdirs

du -hs /example/folder/
lsb_release -a
tar -cf - file1 dir1/ dir2/ | md5sum
2014-04-17 14:33:44
User: snipertyler
Functions: tar

Doesn't create a file

Make sure to list the files / directories in the same order every time.

sudo dpkg -P $(dpkg -l | grep -i adobeair)
cat /proc/cpuinfo
apt-show-versions -u
2009-02-06 17:56:13
User: cowholio4
Functions: apt

apt-show-versions is a program that shows what packages in the system may be updated and several useful information. The -u option displays a list of upgradeable packages:

From: http://www.debian.org/doc/manuals/apt-howto/ch-helpers.en.html

mysql -? | grep ".cnf"
2011-04-02 15:45:52
User: DarkSavant
Functions: grep
Tags: mysql

This will show the locations, in order of preference, that MySQL will look for a configuration file

> [filename]
2011-05-18 14:59:02
User: bbbco

Ever need to erase the contents of a file and start over from scratch? This easy command allows you to do so. Be warned! This will immediately erase all the contents of your file and start you over from scratch (i.e. your file will be at 0 bytes, like if you touch a file).

echo "string" | sed -e 's/.*match1//' -e 's/match2.*$//'
2009-04-01 15:01:27
User: P17
Functions: echo sed

But who knows to delete the rest of the lines?

I want only "string".

ifconfig eth0 | grep 'HWaddr' | awk '{print $5}' | tr 'a-z' 'A-Z' | sed -e 's/://g'
2010-06-26 05:35:03
User: minigeek
Functions: awk grep ifconfig sed tr

This will get the mac address of the eth0 and change lowercase to uppercase.

The sed command removed the colons.

lame rec01.wav rec01.mp3
sudo sox <file name>.wav -r 8000 <file name>.gsm
du -sh *
ls -l `ls -l |awk '/^l/ {print $8}'`
2009-11-23 16:02:18
User: yooreck
Functions: awk ls

ls -l may vary depending on operating system, so "print $8" may have to be changed

sudo sox <file name>.wav -r 8000 <file name>.gsm