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.

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



Psst. Open beta.

Wow, didn't really expect you to read this far down. The latest iteration of the site is in open beta. It's a gentle open beta-- not in prime-time just yet. It's being hosted over at UpGuard (link) and you are more than welcome to give it a shot. Couple things:

  • » The open beta is running a copy of the database that will not carry over to the final version. Don't post anything you don't mind losing.
  • » If you wish to use your user account, you will probably need to reset your password.
Your feedback is appreciated via the form on the beta page. Thanks! -Jon & CLFU Team

All commands from sorted by
Terminal - All commands - 12,363 results
gtar cpf - . | (cd /dest/directory; gtar xpf -)
2009-05-15 13:23:00
User: mnikhil
Functions: cd
Tags: gtar, gtar

It copies the entire current working directory to the destination directory with compression enabled.

mkdir `date --iso`
2009-05-15 12:30:10
User: hal
Functions: mkdir

Create a directory named with the current date in ISO 8601 format (yyyy-mm-dd). Useful for storing backups by date. The --iso switch may only work with GNU date, can use format string argument for other date versions.

svn log | grep "bodge\|fudge\|hack\|dirty"
2009-05-15 09:55:44
User: root
Functions: grep

A good way to understand what you've let yourself in for. Potential project metric could be the count:

svn log | grep -c "bodge\|fudge\|hack\|dirty"
ffmpeg -i <filename>.flv -vn <filename>.mp3
$ mplayer -dumpaudio -dumpfile <filename>.mp3 <filename>.flv
clfu-seach <search words>
svn st | grep '^\?' | awk '{print $2}' | xargs svn add; svn st | grep '^\!' | awk '{print $2}' | xargs svn rm
2009-05-14 14:34:50
User: stedwick
Functions: awk grep xargs

automatically add and remove files in subversion so that you don't have to do it through the annoying svn commands anymore

find . -name "\.svn" -exec rm -rf {} ";"
curl -s http://checkip.dyndns.org/ | grep -o "[[:digit:].]\+"
sudo pmset schedule sleep "08/31/2009 00:00:00"
2009-05-14 09:31:32
User: hobzcalvin
Functions: sleep sudo

Schedule your Mac to sleep at any future time.

Also wake, poweron, shutdown, wakeorpoweron. Or repeating with

sudo pmset repeat wakeorpoweron MTWRFSU 7:00:00

Query with

pmset -g sched

Lots more at http://www.macenterprise.org/articles/powermanagementandschedulingviathecommandline

alt + 1 .
2009-05-14 09:14:01
User: elementa13

alt + number + dot will insert last command argument at $number place, alt + 0 + . will print last command name. For example

ls /tmp /var ls /usr /home

alt + 1 + . will result in '/usr' , if you press alt + . again, it will result in '/tmp'

alt + 0 + . -> 'ls'

function ec() { ec_var="`pwd`" && cd /etc/ && sudo bzr commit -m "$@" && cd $ec_var; }
2009-05-14 04:34:26
Functions: cd sudo

ec commits changes to etckeeper

must have etckeeper installed with bzr to use this

place inside bashrc

can be used from any directory to commit changes

alias lso="sudo lsof -i -T -n"
2009-05-14 04:01:05
Functions: alias

list what applications using what ports

alias agi="sudo apt-get install" #package_names
2009-05-14 03:31:47
Functions: alias

these are some aliases you can use in bashrc to shorten the amount of typing needed to use apt-get, also can be used as reference if you can't remember alot of commands or command parameter variations,etc...

Please comment with more apt-get aliases if I missed any, thx

chkconfig --list | fgrep :on | sed -e 's/\(^.*\)*0:off/\1:/g' -e 's/\(.\):on/\1/g' -e 's/.:off//g' | tr -d [:blank:] | awk -F: '{print$2,$1}' | ssh host 'cat > foo'
2009-05-13 21:17:39
User: catawampus

And then to complete the task:

Go to target host;

ssh host

Turn everything off:

for i in `chkconfig --list | fgrep :on | awk '{print $1}'` ; do chkconfig --level 12345 $i off; done

Create duplicate config:

while read line; do chkconfig --level $line on; done < foo
alias sbrc="source ~/.bashrc" && alias nbrc="nano ~/.bashrc"
2009-05-13 02:41:37
Functions: alias

alias for editing .bashrc and sourcing it with a quick command, very useful for quickly adding and modifying alias' and functions in bashrc, create lots of alias from commandlinefu very quickly, use nano vim or any other edit if you want, very useful if you have a barcode scanner and you want to run commands quickly with barcodes

tail -f --retry /var/log/syslog /var/log/auth.log | ccze -A
du -sb *|sort -nr|head|awk '{print $2}'|xargs du -sh
~<press tab twice>
hexdump -e '90/1 "%_p" "\n"' /dev/mem | less
2009-05-12 16:20:57
User: copremesis
Functions: hexdump

see what's in your memory right now... sometimes you find passwords, account numbers and url's that were recently used. Anyone have a safe command to clear the memory without rebooting?

2009-05-12 14:36:42
User: fritz_monroe
Functions: export

History usually only gives the command number and the command. This will add a timestamp to the history file.

Note: this will only put the correct timestamp on commands used after the export is done. You may want to put this in your .bashrc

kudzu -p
2009-05-12 10:34:59
Functions: kudzu

Kudzu is available on CentOS, used for configuring and detecting new hardware device installed, is also usefull for device listing.

tcs -f 8859-1 -t utf /some/file
2009-05-12 10:13:02
User: michauko
Tags: utf iso

I use it sometimes when I work on a french file transferred from a windows XP to a Debian-UTF8 system. Those are not correctly displayed: ? ? ? and so on

man tcs # for all charsets
egrep -v "^$|^[[:space:]]*#" /etc/some/file
2009-05-12 07:14:48
User: michauko
Functions: egrep
Tags: egrep

Shows a file without comments (at least those starting by #)

- removes empty lines

- removes lines starting by # or "some spaces/tabs then #'"

Useful when you want to quickly see what you have to customize on a freshly installed application without reading the comments that sometimes are a full 1000 lines documentation :)

While posting, I saw this http://www.commandlinefu.com/commands/view/1041/display-contents-of-a-file-wo-any-comments-or-blank-lines

But it's dirty and incomplete, to my mind

My original goal was to remove lines like "\t*#" but I can't figure out how to do a egrep '\t' on a command-line. Two workarounds if needed:

egrep -v 'press control + V then TAB then #' /your/file


egrep -v -f some_file /your/file #where some_file contains what you want to exclude, example a really inserted TAB
grep -i '<searchTerm>\|<someOtherSearchTerm>' <someFileName>
2009-05-11 23:05:54
User: scifisamurai
Functions: grep

This is a simple but useful command to search for multiple terms in a file at once. This prevents you from having to do mutliple grep's of the same file.