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 - 206 results
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"'
alias rot13='perl -pe "y/A-Za-z/N-ZA-Mn-za-m/;"'
alias pi='`cat ~/.pi | grep ' ; alias addpi='echo "cd `pwd`" >> ~/.pi'
2009-02-05 15:46:59
User: senthil
Functions: alias grep
8

example:

--------------------------------------------------------------------------------------------

user@ubuntu:~/workspace/SVN/haystak-repos/trunk/internal/src$ addpi

--------------------------------------------------------------------------------------------

Now that directory is in the list of fast access directories.

You can switch to it anytime like this:

--------------------------------------------------------------------------------------------

user@ubuntu:~$ pi internal`

user@ubuntu:~/workspace/SVN/haystak-repos/trunk/internal/src$ --------------------------------------------------------------------------------------------

Please note the backquote ( the symbol that shares its key with ~ in the keyboard )

pi will switch you to that directory.

To see the list of all fast access directories you have to say "cat ~/.pi"

alias s='screen -X screen'; s top; s vi; s man ls;
2009-02-05 13:47:14
User: jonty
Functions: alias man
18

If you are already running screen then you often want to start a command in a fresh window. You use this alias by typing 's whatever' from your command line and 'whatever' starts running in a new window. Good with interactive commands like info, vim, and nethack.