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,232 results
ls -l|awk '{print $6,$8}'|sort -d
2009-03-13 19:00:18
User: archlich
Functions: awk ls sort

Can pipe to tail or change the awk for for file size, groups, users, etc.

lockstat -I -i 977 -s 30 -h sleep 1 > /tmp/profile.out
2009-03-13 13:17:53
User: garylittle
Functions: sleep

Lockstat will sample the kernel 977 times per second, and print out the functions that it sees executing on the CPU during the sample. The -s 10 switch tells lockstsat to not only print that function, but also show the call stack (up to 10 deep).

find ~/project -mtime -1 -type f -print | tar jcvf myfiles.tar.bz2 -T -
2009-03-13 13:03:11
User: voyeg3r
Functions: find tar

create tar.bz2 package from files "-type f" modificated today "-mtime -1" in ~/project

rsync -avz -e ssh --files-from=<(find -mtime +30 -mtime -60) source dest
2009-03-13 12:58:28
User: voyeg3r
Functions: find rsync ssh

rsync from source to dest all between >30

for i in $(seq 0 5) ; do echo "5 - $i" | bc -l ; sleep 60 ; done && echo "bye, bye" && shutdown -h now
2009-03-13 12:16:35
User: arctarus
Functions: bc echo seq shutdown sleep

command to turn off your computer when you go home and can not wait

ls /home/user | xargs ls -lhR | less
over myscript.sh
2009-03-13 06:13:21
User: haivu

over works like 'more' or 'less', but it pretty print the source code

leave +15
2009-03-13 06:09:52
User: haivu
Tags: PIM

If you spend most of your time in front of the terminal, leave is a useful reminder. Leave can have absolute form: leave 1555 reminds you to leave at 3:55PM

ls -A
2009-03-13 05:12:01
User: haivu
Functions: ls
Tags: terminal

This command is almost the same as 'ls -a', but it does not display the current dir (.) or parent (..)

find . -name "*.pdf" -print0 | xargs -0 cp -t downloads/
2009-03-13 03:15:27
User: abcde
Functions: cp find xargs

-t, --target-directory=DIRECTORY (copy all SOURCE arguments into DIRECTORY).

bash -x SCRIPT
2009-03-13 00:09:07
User: jcalvert
Functions: bash

Display commands and their arguments as they are executed. Useful for debugging shell scripts.

lsof | egrep "^COMMAND|deleted"
2009-03-12 23:11:26
User: jyoder
Functions: egrep

If your customer deletes a file that is still in use by a process, that space does not get freed up (will not show up in df) until that process either closes the file on its own, or is killed.

convert image123.png -colors 14 -resize 640x480 grubimg.xpm
2009-03-12 22:55:10
User: starchox
Tags: Linux grub boot

* size must be 640?480 pixels

* only has 14 colors

* save it in XPM format

Edit /boot/grub/menu.lst and add


make sure for your path name and hard disk

find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'
2009-03-12 22:25:26
Functions: find sed

NOT MINE! Taken from hackzine.com blog.

It creates a tree-style output of all the (sub)folders and (sub)files from the current folder and down(deeper)

Quoting some of hackzine's words

"Murphy Mac sent us a link to a handy find/sed command that simulates the DOS tree command that you might be missing on your Mac or Linux box. [..split...] Like most things I've seen sed do, it does quite a bit in a single line of code and is completely impossible to read. Sure it's just a couple of substitutions, but like a jack in the box, it remains a surprise every time I run it."

lsof|grep /somemount/| awk '{print $2}'|xargs kill
2009-03-12 18:42:19
User: archlich
Functions: awk grep xargs

This command will kill all processes using a directory. It's quick and dirty. One may also use a -9 with kill in case regular kill doesn't work. This is useful if one needs to umount a directory.

[[ -d dir ]] || mkdir dir ; cd dir
2009-03-12 17:19:13
User: voyeg3r
Functions: cd dir mkdir

For use in scripts this command is very usefull

mkdir -p doc/{text/,img/{wallpaper/,photos/}}
2009-03-12 17:15:58
User: voyeg3r
Functions: mkdir

create tree of dir's in one command

alias path='echo $PATH | tr ":" "\n"'
2009-03-12 17:07:58
User: voyeg3r
Functions: alias tr

change ":" in path for new line and associate word path to var $PATH

find . -maxdepth 1 -type f -print0 | xargs -0 -i cp ./{}{,.bak}
2009-03-12 16:02:13
User: voyeg3r
Functions: cp find xargs

"." is current dir, maxdepth is the level, -print0 | xargs -0 fix spaces in names, -i interactive , ./ is the current dir {} actual name , and {,.bak} is the atual name + bak

function dpan () { PKG=`perl -e '$_=lc($ARGV[0]); s/::/-/g; print "lib$_-perl\n"' $1`; apt-get install $PKG; }
2009-03-12 15:39:38
User: dave0
Functions: install

Running 'cpan Module::Name' will install that module from CPAN. This is a simple way of using a similar command to install a packaged Perl module from a Debian archive using apt-get.

$EDITOR `perldoc -l Module::Name`
2009-03-12 15:31:37
User: dave0

Ever needed to look at the Perl source of an installed module on your system? This works in 90% of cases.

perl -e 'print map { $_ . "\n" } @INC;'
svn status | grep "^\?" | awk '{print $2}' | xargs svn add
2009-03-12 15:06:12
User: unixfu73000
Functions: awk grep xargs
Tags: svn

This adds all new files to SVN recursively. It doesn't work for files that have spaces in their name, but why would you create a file with a space in its name in the first place?

convert -adjoin -page A4 *.jpeg multipage.pdf
2009-03-12 14:49:18
User: johnquail
Tags: ImageMagick

The linux package imagmagick is required for this command

sudo dmidecode --type 17 | more