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,230 results
for i in $(ls /the/path); do du -hs /the/path/$i; done
watch w
for domain in `cat list_of_domains.txt`; do echo $domain; whois $domain >> output.txt; done
2010-02-15 17:13:45
User: pathcl
Functions: echo whois

Outputs multiple whois from a plain text file.

vim -p file1 file2 [...]
lynx -useragent=Opera -dump 'http://www.facebook.com/ajax/typeahead_friends.php?u=4&__a=1' |gawk -F'\"t\":\"' -v RS='\",' 'RT{print $NF}' |grep -v '\"n\":\"' |cut -d, -f2
cat /var/log/secure | grep smtp | awk '{print $9}' | cut -f2 -d= | sort | uniq -c | sort -n | tail
2009-03-30 15:49:54
User: empulse
Functions: awk cat cut grep sort uniq

Searches /var/log/secure for smtp connections then lists these by number of connections made and hosts.

tcpdump -n -v tcp or udp or icmp and not port 22
man $(ls -1 /usr/share/man/man?/ | shuf -n1 | cut -d. -f1)
2010-08-20 23:36:10
User: dooblem
Functions: cut ls man
Tags: man sort shuf

Another one.

Maybe not the quicker because of the sort command, but it will also look in other man sections.

updated with goodevilgenius 'shuf' idea

gconf-editor /apps/evolution/mail/composer/no_signature_delim false
for file in $( git ls-files ); do echo $file; touch -t $(git --no-pager log --date=local -1 --format="%ct" $file | php -r 'echo @date( "YmdHi.s", trim( file_get_contents( "php://stdin" ) ) );') $file; done
cat file1.txt | uniq > file2.txt
wget -O - 'https://USERNAMEHERE:PASSWORDHERE@mail.google.com/mail/feed/atom' --no-check-certificate
2010-09-26 14:47:13
User: PLA
Functions: wget

I use this command in my Conky script to display the number of messages in my Gmail inbox and to list the from: and subject: fields.

find . | xargs grep -l "FOOBAR" | awk '{print "rm -f "$1}' > doit.sh
2014-04-06 15:48:41
User: sergeylukin
Functions: awk find grep xargs
Tags: awk find grep

After this command you can review doit.sh file before executing it.

If it looks good, execute: `. doit.sh`

2012-09-13 15:20:06
User: kaushalmehra
Tags: hard disk

The lspv command displays the information about the physical volume if the specific

physical volume name is specified. If you do not add flags to the lspv command, by default

all the available physical volumes are printed along with the following information:

* Physical disk name.

* Physical volume identifiers (PVIDs).

* The volume group, if any, that the physical volume belongs to or the label,if any,

locked with the lkdev command.

* The state of the volume group.

Active-When the volume group is varied on.

Concurrent-When the volume group is varied on in the concurrent mode.

Locked-When the physical volume is locked with the lkdev command.


In the example, the iw406 system has two hard disks.

Phy disk name Phy vol identfrs (PVIDs) volume group State of Volumne group

hdisk0 00f6267c8a99c7b6 rootvg active

hdisk1 00f6267cb3746d01 appinstvg active

hdisk0 is mounted on volume group rootvg. hdisk1 is mounted on volume group appinstvg

find . -depth -type d -empty -exec rmdir -v {} \;
require 'time';backup_dir = '/path';Dir.glob(backup_dir+"/*.sql").each{ |f| filetime = Time.parse(`mdls -name kMDItemContentCreationDate -raw #{f}`);monthago = Time.now - (30 * 60 * 60 * 24);`rm #{f}` if filetime < monthago }
grep -Pv '^\S*(#|$)'
nohup VBoxHeadless -p 3052 -startvm ServidorProducao &
timelimit -t100 somecommand
2010-09-27 08:44:37
User: CodSpirit

I found this in Ubuntu repos, and consider it better than timeout.

2013-10-09 08:40:06
User: knoppix5
Tags: man search

Will highlight search term i.e. "foo" across entire man page (scroll up or down to see)


That is how to find things ;)


(slash+empty string+Enter) will jump to the next occurence of previous searched item.

echo $EPOCH|awk '{print strftime("%c",$1)}'
tar zxvf package.tar.gz --strip 1
2010-05-18 21:01:23
User: voyeg3r
Functions: tar

if I need get olnly script.sh from "folder/script.sh"

i=0; while [ $i -lt 100 ]; do echo "test, ttest, tttest-${i}" >> kk.file; i=`expr $i + 1`; done
2012-09-13 21:46:18
User: kaushalmehra
Functions: echo

while commandt






{commandt is executed and its exit status tested.}

for i in 1 2 3

> do

> echo $i

> done

ls | wc -l
2013-01-22 03:35:35
User: Sebasg
Functions: ls wc

ls -1 shows one file per line (update: -1 was not really needed)

wc -l counts the lines received from the previous command

find . -type f -exec grep StringToFind \{\} --with-filename \;|sed -e '/svn/d'|sed -e '/~/d'
2009-03-31 18:09:31
User: f241vc15
Functions: find grep sed

Look for a string in one of your codes, excluding the files with svn and ~ (temp/back up files). This can be useful when you're looking for a particular string in one of your source codes for example, inside a directory which is under version control (e.g. svn), removing all the annoying files with ~ (tilde) from the search. you can even change the command after -exec to delete (rm) or view (cat) files found by 'find' for example