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 using script from sorted by
Terminal - Commands using script - 15 results
mkfifo /tmp/view; nc -l 9876 < /tmp/view& script -f /tmp/view
2014-06-23 05:06:13
User: snipertyler
Functions: mkfifo script
Tags: Network nc fifo

connect to it with any network command (including web browser - if you don't mind weird formatting)


nc 9876

script -qf | tee >(nc -l -p 5000)
script -t 2> timing.txt -a session.txt ; Run some commands here; exit; scriptreplay timing.txt session.txt
RX1=`cat /sys/class/net/${INTERFACE}/statistics/rx_bytes` (see script below)
2012-01-23 18:22:44
User: jp
Functions: script

Need output in mbps (bits)

# ./bytes-second.sh eth0

eth0 interface maximum Speed: 1000Mb/s

RX:12883212 TX:17402002 B/s | RX:98 TX:132 Mb/s

RX:12371647 TX:17830111 B/s | RX:94 TX:136 Mb/s

RX:12502750 TX:17860915 B/s | RX:95 TX:136 Mb/s

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.

mkfifo foo; script -f foo
2011-09-08 02:51:44
User: realist
Functions: mkfifo script

One person does `mkfifo foo; script -f foo' and another can supervise real-time what is being done using `cat foo'.

# su - <user> ; script /dev/null ; screen -r
2011-07-04 16:26:10
User: dmmst19
Functions: screen script su
Tags: screen su pty

Normally, if you su to another user from root and try to resume that other user's screen session, you will get an error like "Cannot open your terminal '/dev/pts/0' - please check." This is because the other user doesn't have permission for root's pty. You can get around this by running a "script" session as the new user, before trying to resume the screen session. Note you will have to execute each of the three commands separately, not all on the same line as shown here.

Credit: I found this at http://www.hjackson.org/blog/archives/2008/11/29/cannot-open-your-terminal-dev-pts-please-check.

script -qf >(nc -ub 5000)
screencast() { arecord -R 1000 -f cd -t wav $1.wav & RECPID=$!; echo "Starting screencast in new shell. Exit subshell to quit."; script -t 2> $1.timing -a $1.session; kill $RECPID; }
2011-01-20 14:35:47
User: bartonski
Functions: arecord cd echo kill script

This shell function takes a single argument, which is used as the base name of the .wav, .timing and .session files created. To create a screencast:

screencast test

type and talk ...

then type 'exit' or to exit the screencast.

test.wav will contain the audio from your screencast.

test.session will contain text and control characters needed to paint the screen

test.timing will contain timing information needed to synch individual keystrokes in test.session with the audio.

to play back:

aplay test.wav & scriptreplay test.{timing,session}

NOTE: because the shell function uses the variable "$!", and bash likes to expand '!' during history expansion, you will need to turn off bash's history before you enter the shell function.

This can be achieved using the command

set +H
script -t /tmp/mylog.out 2>/tmp/mylog.time; <do your work>; <CTRL-D>; scriptreplay /tmp/mylog.time /tmp/mylog.out
2011-01-19 07:16:30
User: olorin
Functions: script

If you provide the option -t to the script command and redirect stderr into a file, the timing information on what is going on on the terminal, is also stored.

You can replay the session via the scriptreplay command, where you can also provide a speedup factor (see the man page for details).

Great for demonstration purposes ...

script /tmp/log.txt
script -qf | tee >(nc -kl 5000) >(nc -kl 5001) >(nc -kl 5002)
2010-10-11 07:55:30
User: clvv
Functions: script tee
Tags: tee pipe script nc

run 'nc yourip 5000', 'nc yourip 5001' or 'nc yourip 5002' elsewhere will produce an exact same mirror of your shell. This is handy when you want to show someone else some amazing stuff in your shell without giving them control over it.

script -f /dev/pts/3
2009-08-19 07:04:17
User: realist
Functions: script

Will redirect output of current session to another terminal, e.g. /dev/pts/3

Courtesy of bassu, http://www.commandlinefu.com/commands/by/bassu

script /dev/null | tee /dev/pts/3
2009-04-19 00:29:45
Functions: script tee

can display the commands and their output to another user who is connected to another terminal, by example pts/3

2009-02-09 22:38:56
User: chrisdrew
Functions: script

Creates a log of a session in a file called typescript. Or specify the file with:

script filename

Exit the session with control-d.