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
perl -pi -e 's/([[:lower:]]+)/uc $1/gsex' file
2009-10-08 14:18:50
Functions: perl
Tags: perl

same, except it works on any OS with Perl installed. DOS, Windose, whatever

export HISTFILE=/dev/null && kill -9 $$
rm ~/.bash_history && kill -9 $$
2009-10-08 12:25:47
User: Velenux
Functions: kill rm

Best way I know to get rid of .bash_history and don't allow bash to save the current one on exit

Edit: added ~/ before .bash_history, just in case... ;)

(printf "PERMISSIONS LINKS OWNER GROUP SIZE MONTH DAY HH:MM PROG-NAME\n" \ ; ls -l | sed 1d) | column -t
tr '[:lower:]' '[:upper:]' <"$1"
2009-10-08 11:34:07
User: opexxx
Functions: tr
Tags: tr

Transforms a file to all uppercase.

head -c4 /dev/urandom | od -N4 -tu4 | sed -ne '1s/.* //p'
perl -e '$x = []; push @$x, eval { $x = 1; return $x = 1; }'
2009-10-07 22:42:18
User: dstahlke
Functions: eval perl return

It is not easy to make perl give a segfault, but this does it. This is a known issue but apparently not easy to fix. This is completely useless except for showing people that perl is not bullet-proof.

iptables -L -n -v
2009-10-07 21:13:59
User: gpenguin
Functions: iptables

I was previously unaware of the -v switch. As a result I never got specifics about which interfaces the allowed or dropped applied to. Thought I'd share the wealth...

FYI, -n prevents DNS resolving of IPs.

for USER in `cut -d ":" -f1 </etc/passwd`; do crontab -u ${USER} -l 1>/dev/null 2>&1; if [ ! ${?} -ne 0 ]; then echo -en "--- crontab for ${USER} ---\n$(crontab -u ${USER} -l)\n"; fi; done
2009-10-07 20:51:01
User: tharant
Functions: crontab echo

This is how I list the crontab for all the users on a given system that actually have a crontab.

You could wrap it with a function block and place it in your .profile or .bashrc for quick access.

There's prolly a simpler way to do this. Discuss.

sed -i '19375 s/^/#/' file
2009-10-07 17:50:40
User: TuxOtaku
Functions: sed

This will comment out a line, specified by line number, in a given file.

awk '{print length, $0;}' | sort -nr
find . -iname ".project"| xargs -I {} dirname {} | LC_ALL=C xargs -I {} svn info {} | grep "Last Changed Rev\|Path" | sed "s/Last Changed Rev: /;/" | sed "s/Path: //" | sed '$!N;s/\n//'
2009-10-07 16:13:27
User: hurz
Functions: dirname find grep info sed xargs

Searches for all .project files in current folder and below and uses "svn info" to get the last changed revision. The last sed joins every two lines.

env PS4=' ${BASH_SOURCE}:${LINENO}(${FUNCNAME[0]}) ' sh -x /etc/profile
sudo fc-cache -f -v
2009-10-07 11:01:29
User: eastwind
Functions: fc-cache sudo

Refresh the cache of font directory , usefull after you download font (.ttf or other) from various website and you don't want to reboot or relogin . Close your word processor before using the command , after the refresh reopen your word processor , new fonts is avaible !

aptitude install bash-completion ; source /etc/bash_completion
2009-10-07 09:27:02
User: flart
Functions: install

The really awesome bash completion in debian seems to be an extra package now, which has to be installed. After sourcing /etc/bash_completion it completes almost everything (package names in apt... etc) :-)

To make this permanent, put something like this in your .bashrc:

if [ -f /etc/bash_completion]; then

source /etc/bash_completion


date -ud "1970-01-01 + 1234567890 seconds"
2009-10-07 04:35:40
User: zude
Functions: date

The "-d" option for gnu's "date" command can calculate positive or negative offset from any time, including "now". You can even specify a source timezone (the output timezone can be set with the TZ environment variable). Useful! Fun! Not very well documented!

find ~/Music -daystart -mtime -60 -name *mp3 -printf "%T@\t%p\n" | sort -f -r | head -n 30 | cut -f 2
cvs -n update 2>null | grep -i "M " | sed s/"M "//
ls -alh #mycomment
2009-10-06 13:55:06
Functions: ls

Comments can be used directly on the command line so I can save in the history a brief description of what command does.

mysql -u root -pPasswort -e 'select table_schema,round(sum(data_length+index_length)/1024/1024,4) from information_schema.tables group by table_schema;'
cat file.txt | while read line; do printf "%7.2f -> %7.2f\n" $line; done
ffmpeg -i input.flv -vhook '/usr/lib/vhook/imlib2.so -c white -x 250 -y H+(-1.8*N+80) -t Hallo! -A max(0,255-exp(N/16))' -sameq -acodec copy output.flv
lsof -i tcp -i udp
echo "vertical text" | fold -1
awk '{print(substr($0,1,5))}' file
2009-10-05 18:58:49
Functions: awk

Consider this file :




with awk

hello to


I can use awk substring to laminate words :







Similar to http://www.commandlinefu.com/commands/view/2000/laminate-files-line-by-line