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.


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:



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.




All commands from sorted by
Terminal - All commands - 11,490 results
echo $PATH | tr : \\n
2009-02-13 15:54:58
User: piyo
Functions: echo tr

This works in bash and zsh.

You may also want to alias it, if you need to look at it often...

alias lpath="echo \$PATH | tr : \\\\n"

"\$PATH" to make sure to look at your current $PATH

sc queryex type= service state= all | find "_NAME"
2009-02-13 15:44:42
User: piyo
Functions: find

On Windows 2000 or later, this command will give a listing of all the registered Windows services. You can then know what the name of a command is in order to start and stop it.


sc start Apache2.2


net start Apache2.2

Please note that sc will allow the SERVICE_NAME only, while net will allow both SERVICE_NAME and DISPLAY_NAME.

Note that the space between the = and the next word are important. Not very unixy, that.




find . -name '*.jar' -printf '%f:'
2009-02-13 15:37:51
User: yalestar
Functions: find

Useful for making a CLASSPATH out of a list of JAR files, for example.


export CLASSPATH=.:$(find ./lib -name '*.jar' -printf '%p:')

git config --global --add alias.ff "pull --no-commit -v" ; git ff
2009-02-13 15:30:46
User: piyo

This command will first add an alias known only to git, which will allow you to pull a remote and first-forward the current branch. However, if the remote/branch and your branch have diverged, it will stop before actually trying to merge the two, so you can back out the changes.


Tested on git, msysgit (Windows port)

Actually this is not really the way I want it. I want it to attempt a fast-foward, but not attempt to merge or change my working copy. Unfortunately git pull doesn't have that functionality (yet?).

cat SomeFile.txt | pbcopy
2009-02-13 15:23:10
Functions: cat

Great for little scripts that dig up obscure info that you are going to have to paste into another app anyway.

netsh interface ip dump > current-interfaces.txt
2009-02-13 15:13:05
User: piyo
Functions: dump

On Windows 2000 or newer, you can use the command line to save the current network interface info.

You can then edit the text file and re-apply it using the netsh -f command (or netsh exec). Keep a bunch of text files around to quickly switch connection info without using extra software.




ifconfig eth0 | awk '/inet addr/ {split ($2,A,":"); print A[2]}'
update-alternatives --config x-terminal-emulator
date +%s
2009-02-13 13:30:44
User: legba7
Functions: date

displays time in seconds since January 1, 1970 UTC

sleep 3m; play bigben.wav
2009-02-13 13:20:13
User: legba7
Functions: sleep

plays wave file after 3 minutes

find . -type f -print | xargs grep foo
curl -U username[:password] -x proxyserverIP:proxyserverPort webpageURI
2009-02-13 11:00:33

If you are behind a proxy server and have to authenticate with proxy server to browser web pages then you have to pass proxy server address and its port number along with user credentials to curl to got GET the page using curl. Example : "curl -U srikanth -x

cat /dev/null >filename
2009-02-13 10:50:41
User: vorphalax
Functions: cat

with this command you can empty file

ssh -L 5900:localhost:5900 user@exampleserver.com
2009-02-13 04:53:27
User: Jackie
Functions: ssh

Foward vnc securely from exampleserver.com

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

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

curl -s http://myip.dk | grep '<title>' | sed -e 's/<[^>]*>//g'
2009-02-13 01:44:12
User: uzi
Functions: grep sed

add this alias in .bashrc to fast check the ip address of your modem router

alias myip="curl -s http://myip.dk | grep '' | sed -e 's/]*>//g'"

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

similar to perl chop()

2009-02-13 00:31:49
User: rothgar
Functions: pwd

Simply displays your current working directory. Helps when you are buried deep in /etc or some other obscure place.

rpm -e --allmatches filename.rpm
2009-02-12 23:09:24
User: sohaileo
Functions: rpm

If somehow if you get more than 1 same name rpm package install, then it cannot be removed by using simple rpm -e as it gives you more than one rpm matches error. The --matches will help to remove all the same name rpm packages.

2009-02-12 22:53:02
User: mshenoy

Once Enabled this command enables a trail of all processes on the system. As the name suggested auditing for Solaris machines.

BSM creates a number of files in the /etc/security directory.

tar -zcps <dir> -X <(find <dir> -type f -mtime -<days>) |ssh user@backuphost tar -xzpsC /data/bkup
2009-02-12 22:31:58
User: zb
Functions: find tar

due to bug can not comment

find /tmp -type f -printf 'rm "%p";\n'
2009-02-12 20:23:24
User: zb
Functions: find

add |sh when you agree the list, I often use that method to prevent typos in dangerous or long operations

find ./backup -type f -print0 | xargs -0 md5sum > /checksums_backup.md5
tail -f /var/log/messages
2009-02-12 19:30:33
User: nicdev
Functions: tail

Use this command to see logs update in real time

telnet <ip> <port>
2009-02-12 19:11:03
User: leprasmurf
Functions: telnet

Telnet will make a tcp connection to a remote ip/port to test connectivity. If it times out, it's not reaching the host (maybe the firewall is blocking it). If connection is refused, it's reaching the host, but either the service is not listening on that port, or it's locked.