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.

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.

UpGuard checks and validates configurations for every major OS, network device, and cloud provider.

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 tagged pv from sorted by
Terminal - Commands tagged pv - 32 results
pv -tpreb /dev/sdc2 | dd of=/dev/sdb2 bs=64K conv=noerror,sync
2016-12-22 03:18:09
User: 4fthawaiian
Functions: dd

uses the wonderful 'pv' command to give a progress bar when copying one partition to another. Amazing for long running dd commands

[email protected]; tar -cf - /path/to/dir | pv | nc -l -p 6666 -q 5; [email protected]; nc 6666 | pv | tar -xf -
(pv -n centos-7.0-1406-x86_64-DVD.img | dd of=/dev/disk4 bs=1m conv=notrunc,noerror) 2>&1 | dialog --gauge "Copying CentOS to USB Stick in /dev/disk4" 10 70 0
bkname="test"; tobk="*" ; totalsize=$(du -csb $tobk | tail -1 | cut -f1) ; tar cvf - $tobk | tee >(sha512sum > $bkname.sha512) >(tar -tv > $bkname.lst) | mbuffer -m 4G -P 100% | pv -s $totalsize -w 100 | dd of=/dev/nst0 bs=256k
2014-07-22 15:47:50
User: johnr
Functions: cut dd du tail tar tee

This will write to TAPE (LTO3-4 in my case) a backup of files/folders. Could be changed to write to DVD/Blueray.

Go to the directory where you want to write the output files : cd /bklogs

Enter a name in bkname="Backup1", enter folders/files in tobk="/home /var/www".

It will create a tar and write it to the tape drive on /dev/nst0.

In the process, it will

1) generate a sha512 sum of the tar to $bkname.sha512; so you can validate that your data is intact

2) generate a filelist of the content of the tar with filesize to $bkname.lst

3) buffer the tar file to prevent shoe-shining the tape (I use 4GB for lto3(80mb/sec), 8gb for lto4 (120mb/sec), 3Tb usb3 disks support those speed, else I use 3x2tb raidz.

4) show buffer in/out speed and used space in the buffer

5) show progress bar with time approximation using pv


To eject the tape :

; sleep 75; mt-st -f /dev/nst0 rewoffl


1) When using old tapes, if the buffer is full and the drive slows down, it means the tape is old and would need to be replaced instead of wiping it and recycling it for an other backup. Logging where and when it slows down could provide good information on the wear of the tape. I don't know how to get that information from the mbuffer output and to trigger a "This tape slowed down X times at Y1gb, Y2gb, Y3gb down to Zmb/s for a total of 30sec. It would be wise to replace this tape next time you want to write to it."

2) Fix filesize approximation

3) Save all the output to $bkname.log with progress update being new lines. (any one have an idea?)

4) Support spanning on multiple tape.

5) Replace tar format with something else (dar?); looking at xar right now (https://code.google.com/p/xar/), xml metadata could contain per file checksum, compression algorithm (bzip2, xv, gzip), gnupg encryption, thumbnail, videopreview, image EXIF... But that's an other project.


1) You can specify the width of the progressbar of pv. If its longer than the terminal, line refresh will be written to new lines. That way you can see if there was speed slowdown during writing.

2) Remove the v in tar argument cvf to prevent listing all files added to the archive.

3) You can get tarsum (http://www.guyrutenberg.com/2009/04/29/tarsum-02-a-read-only-version-of-tarsum/)

and add >(tarsum --checksum sha256 > $bkname_list.sha256) after the tee to generate checksums of individual files !

watch ls -lh /path/to/folder
2014-03-27 10:51:36
User: vonElfensenf
Functions: ls watch
Tags: pv

forgot to use a pv or rsync and want to know how much has been copied.

cd /srcfolder; tar -czf - . | pv -s `du -sb . | awk '{print $1}'` | ssh -c arcfour,blowfish-cbc -p 50005 [email protected] "tar -xzvf - -C /dstfolder"
2013-05-30 07:21:06
User: bhbmaster
Functions: awk cd ssh tar
Tags: ssh tar pv

NOTE: When doing these commands when asked for questions there might be flowing text from the pv doing the progress bar just continue typing as if its not there, close your eyes if it helps, there might be a yes or no question, type "yes" and ENTER to it, and also it will ask for a password, just put in your password and ENTER

I talk alot more about this and alot of other variations of this command on my site:


while true; do nc -l -p 50002 | pv | tar -xf -; done
2013-05-30 07:17:23
User: bhbmaster
Functions: tar
Tags: tar nc pv

Do above at the Destination aka The Server.

Do the following at the Source aka The Client:

tar -cf - /srcfolder | pv | nc www.home.com 50002

If you want ETAs and stuff:

tar -cf - /srcfolder | pv -s `du -sb /srcfolder | awk '{print $1}'` | nc www.home.com 50002

If you dont care about progress bars @ server/destination:

tar -cf - /srcfolder | pv | nc www.home.com 50002

If you dont care about progress bars @ client/source:

tar -cf - /srcfolder | pv -s `du -sb /srcfolder | awk '{print $1}'` | nc www.home.com 50002

I have this in alot better detail where there is more room to talk about it on my site:


pv /dev/random > /dev/null
2013-01-09 15:47:07
User: vdo
Tags: pv entropy

Meters your actual entropy with pipe viewer command

nc -l $PORT | pv -b > archive.tar.bz2
2012-11-13 16:47:45
Tags: netcat tar pv

Receives bzip'd tar archive via netcat (openbsd nc) and stores locally. Displays size with pv. Start this receiver first, then the sender.

kill -SIGUSR1 xxxx
2012-04-12 09:32:24
User: netaxiz
Functions: kill
Tags: dd pv

run this in another terminal, were xxxx is the process ID of the running dd process.

the progress will report on the original terminal that you ran dd on

pv -tpreb /dev/urandom | dd of=file.img
2012-04-11 22:32:52
User: marrowsuck
Functions: dd
Tags: dd pv

This version was mentioned in the comments. Credits go to flatcap.

SIZE=`fdisk -s /dev/sdx`; dd if=/dev/sdx bs=1M | pv -s "$SIZE"k > hdd.img
pv -petrs $(stat -c %s file.iso) file.iso | dd bs=1M oflag=sync of=/dev/sdX
time (pv file.iso | dd bs=1M oflag=sync of=/dev/sdX 2>/dev/null)
dd if=<device> | pv | nc <target> <port>
2012-01-27 18:37:36
Functions: dd
Tags: dd nc pv 7z

Create an image of "device" and send it to another machine through the network ("target" and "port" sets the ip and port the stream will be sent to), outputting a progress bar

On the machine that will receive, compress and store the file, use:

nc -l -p <port> | 7z a <filename> -si -m0=lzma2 -mx=9 -ms=on

Optionally, add the -v4g switch at the end of the line in order to split the file every 4 gigabytes (or set another size: accepted suffixes are k, m and g).

The file will be compressed using 7z format, lzma2 algorithm, with maximum compression level and solid file activated.

The compression stage will be executed on the machine which will store the image. It was planned this way because the processor on that machine was faster, and being on a gigabit network, transfering the uncompressed image wasn't much of a problem.

tcpdump -w - |pv -bert >/dev/null
2011-12-14 00:24:02
User: h3xx
Functions: tcpdump

Real gurus don't need fancy tools like iftop or jnettop.

pv file | gzip > file.gz
pv -t -p /path/to/sqlfile.sql | mysql -uUSERNAME -pPASSWORD -D DATABASE_NAME
nc -l -p 7777 > /dev/null
2011-01-24 00:06:45
User: kerim

On the another machine write this command.

pv -r /dev/zero | nc 7777

It will show live throughput between two machine.The destination machine ip is at our example

You must multiply by 8 for the network calculation.

You must install pv and netcat commands for this commands usage.

[email protected]


cat /dev/sda | pv -r > /dev/null
2011-01-23 22:58:56
User: kerim
Functions: cat

Change your drive letter as you wish.

Using pv command for speed detect.First of all you must install pv command for usage.


[email protected]

(pv -n ~/database.sql | mysql -u root -pPASSWORD -D database_name) 2>&1 | zenity --width 550 --progress --auto-close --auto-kill --title "Importing into MySQL" --text "Importing into the database"
2010-06-19 22:40:10
User: kbrill
Tags: mysql pv zenity

This uses PV to monitor the progress of the MySQL import and displays it though Zenity. You could also do this

pv ~/database.sql | mysql -u root -pPASSWORD -D database_name

and get a display in the CLI that looks like this

2.19MB 0:00:06 [ 160kB/s] [> ] 5% ETA 0:01:40

My Nautalus script using this command is here


dd if=/dev/zero | pv | dd of=/dev/null
tail -f access.log | pv -l -i10 -r >/dev/null
2010-04-29 21:02:01
User: dooblem
Functions: tail
Tags: tail pv

Displays the realtime line output rate of a logfile.

-l tels pv to count lines

-i to refresh every 10 seconds

-l option is not in old versions of pv. If the remote system has an old pv version:

ssh tail -f /var/log/apache2/access.log | pv -l -i10 -r >/dev/null

pv -cN orig < foo.tar.bz2 | bzcat | pv -cN bzcat | gzip -9 | pv -cN gzip > foo.tar.gz
2010-04-16 05:21:10
User: rkulla
Functions: gzip

In this example we convert a .tar.bz2 file to a .tar.gz file.

If you don't have Pipe Viewer, you'll have to download it via apt-get install pv, etc.