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.

UpGuard checks and validates configurations for every major OS, network device, and cloud provider.

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



Commands using alias from sorted by
Terminal - Commands using alias - 212 results
alias info='info --vi-keys'
2010-02-16 16:35:17
User: eightmillion
Functions: alias
Tags: alias info

I use this alias in my bashrc. The --vi-keys option makes info use vi-like and less-like key bindings.

echo alias xkcd="gwenview `w3m -dump http://xkcd.com/|grep png | awk '{print $5}'` 2> /dev/null" >> .bashrc
2010-01-30 20:38:16
User: GinoMan2440
Functions: alias echo

Add an alias to your .bashrc that allows you to issue the command xkcd to view (with gwenview) the newest xkcd comic... I know there are thousands of them out there but this one is at least replete with installer and also uses a more concise syntax... plus, gwenview shows you the downloading progress as it downloads the comic and gives you a more full featured viewing experience.

alias rc='ssh ${MEDIAPCHOSTNAME} env DISPLAY=:0.0 rhythmbox-client --no-start'
2010-01-17 19:43:43
User: rhythmx
Functions: alias env

Note: you'll want to set up pub-key ssh auth. Gives you a quick means of changing volume/tracks/etc for rhythmbox on a remote machine. E.g.:

rc --next # Play next track

rc --print-playing # Grab the name

rc --volume-down

rc --help

alias PS1="man bash | sed -n '/ASCII bell/,/end a sequence/p'"
2010-01-15 23:39:28
User: haivu
Functions: alias
Tags: bash prompt ps1

I use this command (PS1) to show a list bash prompt's special characters. I tested it against A flavor of Red Hat Linux and Mac OS X

silent(){ $@ > /dev/null 2>&1; }; alias shh=silent
2010-01-04 01:01:03
User: bhepple
Functions: alias

Sometimes I just want to run a command quietly but all that keyboard shifting makes my fingers hurt. This little function does the job eg.:

if shh type less; then PAGER=less; fi
alias :q='tput setaf 1; echo >&2 "this is NOT vi(m) :/"; tput sgr0'
2009-12-08 12:59:44
User: sputnick
Functions: alias echo tput
Tags: vim alias vi tput

For vi(m) users :

Add it in your ~/.bashrc

Add an "exit" @ the end if you are masochist ;)

alias burnaudiocd='mkdir ./temp && for i in *.[Mm][Pp]3;do mpg123 -w "./temp/${i%%.*}.wav" "$i";done;cdrecord -pad ./temp/* && rm -r ./temp'
2009-11-21 19:57:18
User: eightmillion
Functions: alias mpg123 rm

This uses mpg123 to convert the files to wav before burning, but you can use mplayer or mencoder or ffmpeg or lame with the --decode option, or whatever you like.

alias cstdin='echo "Ctrl-D when done." && gcc -Wall -o ~/.stdin.exe ~/.stdin.c && ~/.stdin.exe'
2009-11-19 16:38:51
User: taliver
Functions: alias gcc

This is a quick hack to make a gcc caller. Since it runs with gcc instead of tcc, it's a bit more trustworthy as far as the final answers of things go.

alias gdbbt="gdb -q -n -ex bt -batch"
2009-11-10 22:56:59
User: TeacherTiger
Functions: alias
Tags: gdb

The pstack command prints a stack trace of running processes without needing to attach a debugger, but what about core files? The answer, of course, is to use this command. Usage: gdbbt program corefile

alias ..="cd .." ...="cd ../.." ....="cd ../../.."
alias whatismyip="wget -q -O - http://whatismyip.com/automation/n09230945.asp"
2009-10-30 15:42:52
User: gibboris
Functions: alias

The preferred way for scripts (and easier to parse)

alias ..="cd .."; alias ...="cd ../.."; alias ....="cd ../../.."
2009-10-30 01:04:33
User: Tzunamii
Functions: alias
Tags: cd

Change to your taste. Much quicker than having to add 'cd' every time. Add it to your .bashrc or .bash_profile.

alias clear='( for ((i=1;i<$LINES;i++)) ; do echo "" ; done ) ; clear'
2009-10-27 14:38:31
User: Marcio
Functions: alias echo

If you receives a lot of compiling errors, type 'clear', then reedit your code and press "SHIFT+PGUP".

alias nl2space="perl -ne 'push @F, \$_; END { chomp @F; print join(qq{ }, @F) , qq{\n};}' "
2009-10-01 02:22:23
User: relay
Functions: alias

# newline to space; the whack before dollar-underbar is required

alias nl2space="perl -ne 'push @F, \$_; END { chomp @F; print join(qq{ }, @F) , qq{\n};}' "

# newline to comma; the whack before dollar-underbar is required

alias nl2,="perl -ne 'push @F, \$_; END { chomp @F; print join(qq{,}, @F) , qq{\n};}' "

PROMPT> cat /tmp/foo











# 'tr' does not give a newline after it run. Makes a messy commandline.

PROMPT> cat /tmp/foo|tr "\n" ' '

foo-001 foo-002 foo-003 foo-004 foo-005 foo-006 foo-007 foo-008 foo-009 foo-010 $PROMPT> tr "\n" ' ' /tmp/foo

# 'tr' does not take arguements

PROMPT> tr "\n" ' ' /tmp/foo

tr: extra operand `/tmp/foo'

Try `tr --help' for more information.

# 'nl2space' is a filter and takes arguements, adds a newline after it runs.

PROMPT> cat /tmp/foo| nl2space

foo-001 foo-002 foo-003 foo-004 foo-005 foo-006 foo-007 foo-008 foo-009 foo-010

PROMPT> nl2space /tmp/foo

foo-001 foo-002 foo-003 foo-004 foo-005 foo-006 foo-007 foo-008 foo-009 foo-010

alias ':q'='exit'
2009-09-05 17:59:50
User: tobiasboon
Functions: alias
Tags: vim alias exit :q

Put this in your ~/.bashrc file (or the equivalent)

If you use vim a lot, this alias will be immediately obvious. Your brain will thank you.

old='apt-get'; new="su-${old}"; command="sudo ${old}"; alias "${new}=${command}"; $( complete | sed -n "s/${old}$/${new}/p" ); alias ${new}; complete -p ${new}
2009-08-10 00:15:05
User: Josay
Functions: alias sed

In Bash, when defining an alias, one usually loses the completion related to the function used in that alias (that completion is usually defined in /etc/bash_completion using the complete builtin).

It's easy to reuse the work done for that completion in order to have smart completion for our alias.

That's what is done by this command line (that's only an example but it may be very easy to reuse).

Note 1 : You can use given command line in a loop "for old in apt-get apt-cache" if you want to define aliases like that for many commands.

Note 2 : You can put the output of the command directly in your .bashrc file (after the ". /etc/bash_completion") to always have the alias and its completion

alias z='zenity --info --text="You will not believe it, but your command has finished now! :-)" --display :0.0'
2009-08-03 16:38:29
User: bubo
Functions: alias

tired of switching to the console to check if some command has finished yet? if notify-send does not work on your box try this one... e.g. rsync -av -e /usr/bin/lsh $HOME slowconnection.bar:/mnt/backup ; z (now fire up X, do something useful, get notified if this stuff has finished).

alias vi='emacsclient -n'
2009-07-29 06:18:40
User: freestyler
Functions: alias

add (server-start) in .emacs

alias restart='apache2ctl configtest && apache2ctl restart'
2009-07-21 14:13:15
Functions: alias

making lots of configurations to apache and restarting the server only to find it broken just plain sucks.

alias grip="grep -i"
2009-07-21 11:12:15
User: inof
Functions: alias

This is *NOT* about the -i option in grep. I guess everybody already knows that option. This is about the basic rule of life that the simplest things are sometimes the best. ;-)

One day when I used "grep -i" for the umpteenth time, I decided to make this alias, and I've used it ever since, probably more often than plain grep. (In fact I also have aliases egrip and fgrip defined accordingly. I also have wrip="grep -wi" but I don't use this one that often.)

If you vote this down because it's too trivial and simplistic, that's no problem. I understand that. But still this is really one of my most favourite aliases.

alias sucs="sort | uniq -c | sort -n"
2009-07-21 10:55:06
User: inof
Functions: alias

This alias finds identical lines in a file (or pipe) and prints a sorted count of them (the name "sucs" descends from the first letters of the commands). The first example shows the number of logins of users; the one who logged in most often comes last. The second example extracts web client IP addresses from a log file, then pipes the result through the "sucs" alias to find out which clients are performing the most accesses. Or pipe the first column of ps(1) output through "sucs" to see how many processes your users are running.

alias w3m='w3m -cookie'
echo alias grep=\'grep --color=auto\' >> ~/.bashrc ; . ~/.bashrc
2009-07-05 07:44:13
User: 0x2142
Functions: alias echo
Tags: color grep

This will create a permanent alias to colorize the search pattern in your grep output

alias launchpadkey="sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys"
2009-06-17 12:02:27
User: azeey
Functions: alias
Tags: alias apt-key

Makes it easy to add keys to new ppa sources entries in apt sources.list

Now to add the key for the chromium-daily ppa:

launchpadkey 4E5E17B5
alias findstring="find . -type f -print | xargs grep $1"