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

Commands by rubenmoran from sorted by
Terminal - Commands by rubenmoran - 27 results
netstat -n | grep ESTAB |grep :80 | tee /dev/stderr | wc -l
2016-06-26 11:37:19
User: rubenmoran
Functions: grep netstat tee wc

Summarize established connections after netstat output.

Using tee and /dev/stderr you can send one command output to terminal before executing wc so you can summarize at the bottom of the output.

dpkg -l |grep i386 | awk '{ print "apt-get -y remove --purge "$2 }' | sh
Limit kernel compilation load
mv file.png $( mktemp -u | cut -d'.' -f2 ).png
tr -dc a-z0-9 </dev/urandom | tr 0-8 \ | tr 9 \\n | sed 's/^[ \t]*//' | fmt -u
find . -type f -printf %s\\n | paste -sd+ | bc
2011-02-10 09:44:36
User: rubenmoran
Functions: find paste

Computes total size of files in a directory. This value is different "du -b" because doesn't includes directory sizes.

watch -n1 echo
seq -s^2+ 11 |rev| cut -d'+' -f2- | rev | bc
2011-02-10 08:41:14
User: rubenmoran
Functions: cut rev seq
Tags: seq sum math

I can't put the last ^2 with seq, so I reverse it to delete the last +N. So for doing sum(N^2) you have to do sum((N+1)^2). Must be a better way.

seq -s* 10 |bc
seq 1000 | paste -sd+- | bc
seq 10 | paste -sd* | bc
seq 100000 | paste -sd+ | bc
dpkg -S $( which ls )
sed i"+" file.txt | xargs echo 0 |bc
2011-02-09 10:14:22
User: rubenmoran
Functions: echo sed xargs
Tags: sum

In the file data.txt there is a single column of numbers. Sed adds a "+" between lines and xargs prepares the output for bc. The "echo 0" is to avoid to have a "+" at the beginning of the line.

who loves mum
xclip file.txt
2010-06-06 14:28:26
User: rubenmoran
Tags: copy paste

Loads file content on clipboard. Very useful when text selection size is higher than console size.

xrandr | grep \* | cut -d' ' -f4
xrandr | grep \*
echo Y29tbWFuZGxpbmUuZnUgcm9ja3MK | base64 -d
touch file-$(date +%Y%m%d)
grep -i "$(date +%b" "%d )13:4[0-5]" syslog
2010-05-23 16:30:46
User: rubenmoran
Functions: grep
Tags: log minutes

Returns logs between HH:M[Mx-My], for example, between 13:40 and 13:45.

grep -i "$(date +%b\ %d\ %H)" syslog
2010-05-23 16:18:15
User: rubenmoran
Functions: grep
Tags: log date

Uses date to grep de logfile for today and uses it to get the last hour logs. Can be used to get last minute logs or today's logs.

cut -d'/' -f3 file | sort | uniq -c
2010-05-23 16:02:51
User: rubenmoran
Functions: cut file sort uniq

count the times a domain appears on a file which lines are URLs in the form http://domain/resource.

sed -n 's/\([0-9]\{1,3\}\.\)\{3\}[0-9]\{1,3\}/\nip&\n/gp' ips.txt | grep ip | sed 's/ip//'| sort | uniq
2010-05-23 11:26:32
User: rubenmoran
Functions: grep sed sort
Tags: sed ip address

Extracts ip addressess from file using sed. Uses a tag(ip) to grep the IP lines after extracting. Must be a way to just output regex matched on sed.

grep -Eo \([0-9]\{1,3\}[\.]\)\{3\}[0-9] file | sort | uniq