dd’ing a File
- 0
- Add a Comment
dd’ing a File
This is truly a geeky core function today. If it’s a bit beyond your current understanding of Linux, don’t worry - stick with us and you’ll understand before you know it. Just like the tar trick in today’s GnomeTWEAK, today’s GnomeCORE is a command that will cover all your copying needs and do it with flexibility and thoroughness.
As you’ve seen in a few previous Penguin Shell examples, the dd command is very, very useful. We used it in creating a swap file as well as in creating a boot disk for your system. Fundamentally, it’s a copy command that takes input from one file and puts it in another. If that’s the case, you might ask, why not just use cp? Because (here’s a surprise) dd is much more powerful than a mere copy command.
dd does, indeed, copy input from one file to output. The real power of dd is its ability to write to raw physical I/O and to convert the data being passed to the new file. The cp command simply can’t perform either of these tasks. The first is useful if you’re moving data from, say, a magnetic tape backup to a file. It’s possible to read and write to these raw devices because dd allows the user to set an arbitrary block size - something that’s normally done automatically and only when the device is mounted. The second element can come in handy if, in the process of copying a file from one location to another, the original data also needs to be converted. If, for example, your original data is in the EBCDIC character set rather than ASCII, you can make the conversion to ASCII “on the fly” as you move the data. Conversion can also been done on character case. If you need to convert all upper to lower or vice versa, this, too can be accomplished as part of the dd command.
The dd command syntax is dd [option=value]
Some of the more useful options are if (the input file), of (the output file), and bs (the block size). For a thorough description of dd options and use, visit the dd man page.
Whether you dig deeper or not, dd is another fine example of the power of core command line functions in Linux. Keep it in mind - you’ll undoubtedly use it.
