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:



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.

Top Tags



Tail a log-file over the network

Terminal - Tail a log-file over the network
tail -f error_log | nc -l 1234
2010-05-07 18:14:04
User: zlemini
Functions: tail
Tail a log-file over the network

Netcat is used to serve a log-file over a network on port 1234.

Point a browser to the specified server/port combo to view log-file updates in real-time.


There are 8 alternatives - vote for the best!

Terminal - Alternatives
socat -u FILE:/var/log/syslog,ignoreeof TCP4-LISTEN:12345,fork,reuseaddr
2013-02-18 13:36:01
User: ichbins
Tags: socat

it also works with the chrome browser. The alternative with tail and nc doesn't

(echo -e "HTTP/1.1 200 Ok\n\r"; tail -f /var/log/syslog) | nc -l 1234
2013-02-09 06:15:42
User: adimania
Functions: echo tail

This one is tried and tested for Ubuntu 12.04. Works great for tailing any file over http.

Know a better way?

If you can do better, submit your command here.

What others think

That doesn't seem to work with my Firefox.

How does netcat handle the http procol ?

Comment by dooblem 259 weeks and 2 days ago

Sorry i should have mentioned i tested this on MacOS.

Here is the Linux (Ubuntu) version:

( echo -e "HTTP/1.0 200 Ok\n\r"; tail -f error_log; ) | nc -lp 1234

Comment by zlemini 259 weeks and 2 days ago

I did as you posted in your comment, but my nc man pages says that l and p cannot be used together, nc won't start; I'm on Ubuntu 10.04, my nc version is: OpenBSD netcat (Debian patchlevel 1.89-3ubuntu2)

Comment by Montecristo 258 weeks and 5 days ago

I've taken the last version from sourceforge but it still doesn't work, when I point my browser to http://localhost:1234 it keeps loading...

Comment by Montecristo 258 weeks and 5 days ago

there are two versions of netcat. One should be started with -l -p and another one without -p. Yeah, welcome to the unix world. This command doesn't work well because browser buffers some amount of data and if nothing is written to the transferred file nothing is shown. Additionally this command doesn't work with chrome browser.

Comment by ichbins 113 weeks and 6 days ago

Your point of view

You must be signed in to comment.