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





Commands by robinsonaarond from sorted by
Terminal - Commands by robinsonaarond - 13 results
alias m='screen -S $$ -m script'
2015-10-01 18:07:18
Functions: alias
Tags: screen script

A quick alias I use right before logging into a server so that I have a log of the transactions as well as the ability to re-connect from another computer. Useful for when your boss says "what commands did you run again on that server?" and you had already closed the terminal ;)

I wrapped it in a script now, with more features, but this is the heart of it.

Never leave home without it.

cd $JAVA_HOME && java -Xbootclasspath/a:jre/lib/deploy.jar -Djava.locale.providers=HOST,JRE,SPI -Xdock:name="Java Control Panel" com.sun.deploy.panel.ControlPanel
2015-07-30 19:24:33
Functions: cd
Tags: java jre

Useful if you need to make changes to the JVM on, say, 1.7 when your default installed is 1.8.

export JAVA_HOME=$(/usr/libexec/java_home -v 1.7)
2015-07-30 18:50:51
Functions: export
Tags: version java

Useful if you have multiple versions of Java installed. The 1.7 pkg for Mac doesn't tell you anything about where it's putting stuff.

rpm -q --queryformat="%{NAME}: %{OPTFLAGS}\n" <rpm>
2012-12-05 22:18:03
Functions: rpm

\n Separates out the architectures on different lines.

2012-02-09 17:31:33

I used it for this function, which prints hashes:

function liner {



printf %${num_lines}s|tr " " "#"



Note the colon-dash, instead of the usual colon-equals.

ps -p $$
2012-02-09 17:27:45
Functions: ps

works as well as echo $0, but also prints process id, which pts you're using. echo $SHELL doesn't always get updated when changing shells, so this is a better solution than that. Just one more variation on a theme.

myhex=$(printf '%02X' ${myip//./ };)
2011-11-30 15:12:28
Functions: printf
Tags: IP hex printf octet

Converts IP octets to hex using printf command. Useful for generating pxeboot aliases in the pxelinux.cfg folder.

ls ${my_dir:=/home}
2011-11-30 15:06:51
Functions: ls

Will use variable value (for variable $my_dir, in this case), an assign a default value if there is none.

[ $1 ] && my_dir=$1
2011-11-30 15:02:20

If Argument $1 is supplied, assign it to variable. Otherwise continue on.

script -f /tmp/foo; tail -f /tmp/foo
2011-11-22 15:16:08
Functions: script tail
Tags: script tail -f

script -f /tmp/foo will place all output of the terminal, including carriage returns, to a file. This file can be tail dash-eff'ed by one or more other terminals to display the information of the main terminal. Good way to share one's screen on short notice.

Note: This produces a very accurate output, but that includes depending on the size of your terminal to be the same. You can clear screens or even resize the terminal for others using this function; I use it in conjunction with the "mid" command in my list.

chflags nohidden ~/Library
2011-11-01 19:59:44

Adds/Removes the hidden flag on a file or folder, making it invisible in the Finder.

alias cls='printf %b '\''\033c'\'''
2011-11-01 14:31:30
Functions: alias

Syntax outside of an alias would be printf %b \\033c. This clears the screen and removes scrollback. Works on gnome-terminal and the XFCE's Terminal, and XTerm. It does clear the screen in Konsole and the Mac Terminal, but does not clear scrollback.

alias mid='printf "\e[8;24;80;t"'
2011-11-01 14:25:45
Functions: alias

Uses printf command to resize terminal.

So far, this is tested to NOT work in Konsole. Works with Mac Terminal, XFCE Terminal, XTerm, gnome-terminal.