Hide

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.

Hide

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:

Hide

News

2011-03-12 - Confoo 2011 presentation
Slides are available from the commandlinefu presentation at Confoo 2011: http://presentations.codeinthehole.com/confoo2011/
2011-01-04 - Moderation now required for new commands
To try and put and end to the spamming, new commands require moderation before they will appear on the site.
2010-12-27 - Apologies for not banning the trolls sooner
Have been away from the interwebs over Christmas. Will be more vigilant henceforth.
2010-09-24 - OAuth and pagination problems fixed
Apologies for the delay in getting Twitter's OAuth supported. Annoying pagination gremlin also fixed.
Hide

Tags

Hide

Functions

Commands using alias from sorted by
Terminal - Commands using alias - 209 results
alias vb='vim ~/.bashrc; source ~/.bashrc'
2009-03-02 21:01:49
User: haivu
Functions: alias col groff man
2

Place the line above in your ~/.bahsrc file. Now every time you issue the 'vb' command, you invoke the vim editor to edit it, then source it so the changes take effect immediately.

Notes:

* This mechanism is not working well if your .bashrc contains commands that should not be sourced more than once.

* This trick also work for your csh or tclsh users: place the following line in your ~/.cshrc file:

alias vc 'vim ~/.cshrc; source ~/.cshrc

Thank you adzap for pointing out the missing quote

alias calc 'echo "scale=4;\!*"|bc -l'; alias xcalc 'echo "\!*"|bc -l'
2009-02-28 21:30:59
User: boomer_tn
Functions: alias
1

allows simple C shell access to the power of bc - never could figure out how to do the same thing with Bash - that's why I use tcsh most of the time.

alias trash="rm -fr ~/.local/share/Trash"
2009-02-27 01:55:30
Functions: alias
-4

Force empties the user trash

alias wordpress='mkdir wordpress && cd wordpress && wget http://wordpress.org/latest.tar.gz && tar -xvzf latest.tar.gz && mv wordpress/* . && rm -rf latest.tar.gz wordpress && cp wp-config-sample.php wp-config.php'
a() { alias $1=cd\ $PWD; }
2009-02-21 01:53:01
Functions: alias
0

An easy way to create aliases for moving between many directories

alias mine='ps xco pid,command,%cpu,%mem,state'
alias timestamp='date "+%Y%m%dT%H%M%S"'
2009-02-20 23:18:30
User: olifante
Functions: alias
12

I often need to add a timestamp to a file, but I never seem to remember the exact format string that has to be passed to the date command to get a compact datetime string like 20090220T231410 (i.e yyyymmddThhmmss, the ISO 8601 format popular outside the US)

alias ds='dig +noauthority +noadditional +noqr +nostats +noidentify +nocmd +noquestion +nocomments'
2009-02-19 17:32:56
Functions: alias
4

Turn off almost all of dig's output except for what you'd see in a zone file. This can also be put into ~/.digrc.

alias lrt='ls -lart'
alias rk='d=$(dcop|grep $PPID) && s=$(dcop $d konsole currentSession) && dcop $d $s renameSession'
2009-02-14 00:02:43
User: wwest4
Functions: alias
1

usage: renam

in a script you must replace $PPID with $(awk '{print $4}' /prod/$PPID/stat)

alias pubip='GET http://www.whatismyip.com/automation/n09230945.asp && echo'
2009-02-13 04:38:19
User: abcde
Functions: alias
1

Depends on GET. You can also replace GET with curl, or `wget -qO -` if GET isn't available.

alias chop="tr -d '\r\n'"
2009-02-13 01:44:11
User: wwest4
Functions: alias
0

similar to perl chop()

alias mute="dcop kmix Mixer0 toggleMasterMute\(\) ; dcop kmix Mixer0 masterMute\(\) | sed -e 's/true/muted/' -e 's/false/unmuted/' "
2009-02-12 04:56:33
User: wwest4
Functions: alias
1

arguably better than using the driver interface. lots of potentially cool stuff to be done w/ the dcop client.

alias dir="ls -al"
2009-02-11 16:51:01
User: katylava
Functions: alias
0

If you come from a DOS background and accidentally use DOS commands often, this and others like it can be helpful. Add to your .bash_profile, or wherever you keep such things.

alias apt-get='sudo apt-get'
2009-02-10 22:45:49
User: mogsie
Functions: alias
-4

apt-get must be run as root, and it is useless to run it as your own user. So just run it as root. Saves you the "sudo !!" every time you're adding a package.

alias ll="ls -lh --color=auto"
alias ip4rev "echo \!* | sed 's/^\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)/\4.\3.\2.\1/'"
2009-02-09 17:00:03
Functions: alias
-1

For 'bash'

function ip4rev() { echo $@ | sed 's/^\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)/\4.\3.\2.\1/'; }
alias ip4grep "grep -E '([0-9]{1,3}\.){3}[0-9]{1,3}'"
alias pfind='ps aux | grep '
alias ::='cd ../../'
alias acs='apt-cache search'
alias agi='sudo apt-get install'
alias grep 'gnu grep -i --color=auto'
2009-02-07 18:54:56
User: mnikhil
Functions: alias grep
1

Alias the grep command to show colored results by default.

alias nsl 'netstat -f inet | grep -v CLOSE_WAIT | cut -c-6,21-94 | tail +2'
alias scd='dirs -v; echo -n "select number: "; read newdir; cd -"$newdir"'