Question about a ' dd ' command.
kassube at gmx.net
Fri Mar 7 23:37:40 UTC 2008
> I read somewhere that these two commands are special application of
> the basic 'dd' command that will copy and display the transfer action.
> $ 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 and I don't
> understand any of the second line.
Well, to copy /dev/zero to /dev/null is not very useful, unless you want
to benchmark your machine and / or OS. Anyway, /dev/zero is a device
which generates an unlimited amount of 0x00 characters, /dev/null is a
device which ignores any data you write to it. The '&' character makes
the command a background job. The "pid=$!" command saves the process ID
of the last command (the dd command in this case) to the pid environment
variable. "kill -USR1 $pid" sends the USR1 signal to the dd process.
The "sleep 1" command should be obvious - it does nothing for 1 second.
Finally the "kill $pid" command terminates the dd command.
Now you still want to read the man page for the dd command which hopefully
explains the use of the USR1 signal.
> 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,
Well, I think you could find the explanation somewhere here
<http://www.gnu.org/software/bash/manual/bash.html>. But that would mean
learning many bash commands, it isn't easy to learn backwards. IMHO, much
better is the O'Reilley book "Learning the bash shell".
> 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
Don't use these commands unless you really want to overwrite your
partition /dev/sdc3 - but hopefully you knew that already:
dd if =/dev/sda2 of=/dev/sdc3 bs=4096 & pid=$!
kill -USR1 $pid
Now I left away the sleep and terminate commands because you don't want to
copy an arbitrary part of the partition but the entire contents.
More information about the ubuntu-users