Question about a ' dd ' command.

Peter Garrett peter.garrett at
Fri Mar 7 23:52:06 UTC 2008

On Fri, 07 Mar 2008 17:20:03 -0500
elmo <elmo at> wrote:

> I read somewhere that these two commands are special application of  the
> basic 'dd' command that will copy and display the transfer action.

Yes - but these two lines are just an illustration that lasts slightly
more than a second, and does nothing harmful. It just sends a lot of zeros
to nowhere  -  /dev/null is a useful black hole ;-)
> $ dd if=/dev/zero of=/dev/null& pid=$!
> $ kill -USR1 $pid; sleep 1; kill $pid
> I don't understand the null& and pid=$! in the first line 

Attempted explanation follows... The lines you quote are just intended as
an example, as you will see.

$ dd if=/dev/zero of=/dev/null

"Send zeros to the bit bucket" ( that is, to nowhere, if you prefer)

&  : Put the previous command in the background.

pid=$!   : Store the process number identifying the "dd" process in a
variable named "pid" so we can use it later to send signals to the process.

In this case, the signal " kill -USR1 $pid" tells "dd" to output some
information about what it is doing. See "man signal" ( "kill" doesn't
always mean destruction, in Bash !)

;  semicolon divides one command from the next on the command line.

sleep 1  ; Do nothing for one second

kill $pid  : Kill the actual process.

Output here looks like this:

$ dd if=/dev/zero of=/dev/null& pid=$!
[1] 16690
$ kill -USR1 $pid ; sleep 1 ; kill $pid
42209510+0 records in
42209510+0 records out
21611269120 bytes (22 GB) copied, 56.7523 seconds, 381 MB/s

As you see, I let it run for nearly a minute.
The alarming-looking 22 GB actually went nowhere, as explained above.

> and I don't
> understand any of the second line.  There doesn't seem to be any
> explanation of these anywhere.  It appears to me that the writer used
> some notations that can be confusing to other guys like me,

Yes, true that it is confusing if you don't already know.
Have a look for example at

For more information.

> Is there  a  more complete  discussion of  these  commands somewhere?
> Could someone please show me what the commands
> would look like if the simple basic version of ' dd 'is:
>       dd if =/dev/sda2 of=/dev/sdc3  bs=4096

If you wanted to see periodic information during the process, you could
append "&" without the quotes, to that line, as in the example, and assign
the pid with pid=$!

dd if =/dev/sda2 of=/dev/sdc3  bs=4096 & pid=$!

Then every now and then run

kill -USR1 $pid

The final "kill" after the "sleep" would not be good move, unless you
wanted to stop the dd process, which you probably don't want to do. You
could also stop the "kill -USR $pid" command for example with ctrl+c - the
dd command is by then already in the background ( & ) , so it continues to
completion unless specifically killed with " kill $pid"

dd is powerful and low level, so experiment at your own risk! That's why
the commands used /dev/zero as input and sent them to /dev/null - that's
harmless. If you make a slight error using dd, though, disastrous things
can happen silently ( say, overwriting your whole partition with zeros
unintentionally, and so on. )


"INX Is Not X" Live CD based on Ubuntu 7.04 :
Screenshots slideshow:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <>

More information about the ubuntu-users mailing list