]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - bin/dd/dd.1
Upgrade to OpenSSH 7.7p1.
[FreeBSD/FreeBSD.git] / bin / dd / dd.1
1 .\"-
2 .\" Copyright (c) 1990, 1993
3 .\"     The Regents of the University of California.  All rights reserved.
4 .\"
5 .\" This code is derived from software contributed to Berkeley by
6 .\" Keith Muller of the University of California, San Diego.
7 .\"
8 .\" Redistribution and use in source and binary forms, with or without
9 .\" modification, are permitted provided that the following conditions
10 .\" are met:
11 .\" 1. Redistributions of source code must retain the above copyright
12 .\"    notice, this list of conditions and the following disclaimer.
13 .\" 2. Redistributions in binary form must reproduce the above copyright
14 .\"    notice, this list of conditions and the following disclaimer in the
15 .\"    documentation and/or other materials provided with the distribution.
16 .\" 3. Neither the name of the University nor the names of its contributors
17 .\"    may be used to endorse or promote products derived from this software
18 .\"    without specific prior written permission.
19 .\"
20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 .\" SUCH DAMAGE.
31 .\"
32 .\"     @(#)dd.1        8.2 (Berkeley) 1/13/94
33 .\" $FreeBSD$
34 .\"
35 .Dd April 2, 2017
36 .Dt DD 1
37 .Os
38 .Sh NAME
39 .Nm dd
40 .Nd convert and copy a file
41 .Sh SYNOPSIS
42 .Nm
43 .Op Ar operands ...
44 .Sh DESCRIPTION
45 The
46 .Nm
47 utility copies the standard input to the standard output.
48 Input data is read and written in 512-byte blocks.
49 If input reads are short, input from multiple reads are aggregated
50 to form the output block.
51 When finished,
52 .Nm
53 displays the number of complete and partial input and output blocks
54 and truncated input records to the standard error output.
55 .Pp
56 The following operands are available:
57 .Bl -tag -width "of=file"
58 .It Cm bs Ns = Ns Ar n
59 Set both input and output block size to
60 .Ar n
61 bytes, superseding the
62 .Cm ibs
63 and
64 .Cm obs
65 operands.
66 If no conversion values other than
67 .Cm noerror ,
68 .Cm notrunc
69 or
70 .Cm sync
71 are specified, then each input block is copied to the output as a
72 single block without any aggregation of short blocks.
73 .It Cm cbs Ns = Ns Ar n
74 Set the conversion record size to
75 .Ar n
76 bytes.
77 The conversion record size is required by the record oriented conversion
78 values.
79 .It Cm count Ns = Ns Ar n
80 Copy only
81 .Ar n
82 input blocks.
83 .It Cm files Ns = Ns Ar n
84 Copy
85 .Ar n
86 input files before terminating.
87 This operand is only applicable when the input device is a tape.
88 .It Cm fillchar Ns = Ns Ar c
89 When padding a block in conversion mode or due to use of
90 .Cm noerror
91 and
92 .Cm sync
93 modes, fill with the specified
94 .Tn ASCII
95 character, rather than using a space or
96 .Dv NUL .
97 .It Cm ibs Ns = Ns Ar n
98 Set the input block size to
99 .Ar n
100 bytes instead of the default 512.
101 .It Cm if Ns = Ns Ar file
102 Read input from
103 .Ar file
104 instead of the standard input.
105 .It Cm iseek Ns = Ns Ar n
106 Seek on the input file
107 .Ar n
108 blocks.
109 This is synonymous with
110 .Cm skip Ns = Ns Ar n .
111 .It Cm obs Ns = Ns Ar n
112 Set the output block size to
113 .Ar n
114 bytes instead of the default 512.
115 .It Cm of Ns = Ns Ar file
116 Write output to
117 .Ar file
118 instead of the standard output.
119 Any regular output file is truncated unless the
120 .Cm notrunc
121 conversion value is specified.
122 If an initial portion of the output file is seeked past (see the
123 .Cm oseek
124 operand),
125 the output file is truncated at that point.
126 .It Cm oseek Ns = Ns Ar n
127 Seek on the output file
128 .Ar n
129 blocks.
130 This is synonymous with
131 .Cm seek Ns = Ns Ar n .
132 .It Cm seek Ns = Ns Ar n
133 Seek
134 .Ar n
135 blocks from the beginning of the output before copying.
136 On non-tape devices, an
137 .Xr lseek 2
138 operation is used.
139 Otherwise, existing blocks are read and the data discarded.
140 If the user does not have read permission for the tape, it is positioned
141 using the tape
142 .Xr ioctl 2
143 function calls.
144 If the seek operation is past the end of file, space from the current
145 end of file to the specified offset is filled with blocks of
146 .Dv NUL
147 bytes.
148 .It Cm skip Ns = Ns Ar n
149 Skip
150 .Ar n
151 blocks from the beginning of the input before copying.
152 On input which supports seeks, an
153 .Xr lseek 2
154 operation is used.
155 Otherwise, input data is read and discarded.
156 For pipes, the correct number of bytes is read.
157 For all other devices, the correct number of blocks is read without
158 distinguishing between a partial or complete block being read.
159 .It Cm speed Ns = Ns Ar n
160 Limit the copying speed to
161 .Ar n
162 bytes per second.
163 .It Cm status Ns = Ns Ar value
164 Where
165 .Cm value
166 is one of the symbols from the following list.
167 .Bl -tag -width "noxfer"
168 .It Cm noxfer
169 Do not print the transfer statistics as the last line of status output.
170 .It Cm none
171 Do not print the status output.
172 Error messages are shown; informational messages are not.
173 .El
174 .It Cm conv Ns = Ns Ar value Ns Op , Ns Ar value ...
175 Where
176 .Cm value
177 is one of the symbols from the following list.
178 .Bl -tag -width "unblock"
179 .It Cm ascii , oldascii
180 The same as the
181 .Cm unblock
182 value except that characters are translated from
183 .Tn EBCDIC
184 to
185 .Tn ASCII
186 before the
187 records are converted.
188 (These values imply
189 .Cm unblock
190 if the operand
191 .Cm cbs
192 is also specified.)
193 There are two conversion maps for
194 .Tn ASCII .
195 The value
196 .Cm ascii
197 specifies the recommended one which is compatible with
198 .At V .
199 The value
200 .Cm oldascii
201 specifies the one used in historic
202 .At
203 and
204 .No pre- Ns Bx 4.3 reno
205 systems.
206 .It Cm block
207 Treats the input as a sequence of newline or end-of-file terminated variable
208 length records independent of input and output block boundaries.
209 Any trailing newline character is discarded.
210 Each input record is converted to a fixed length output record where the
211 length is specified by the
212 .Cm cbs
213 operand.
214 Input records shorter than the conversion record size are padded with spaces.
215 Input records longer than the conversion record size are truncated.
216 The number of truncated input records, if any, are reported to the standard
217 error output at the completion of the copy.
218 .It Cm ebcdic , ibm , oldebcdic , oldibm
219 The same as the
220 .Cm block
221 value except that characters are translated from
222 .Tn ASCII
223 to
224 .Tn EBCDIC
225 after the
226 records are converted.
227 (These values imply
228 .Cm block
229 if the operand
230 .Cm cbs
231 is also specified.)
232 There are four conversion maps for
233 .Tn EBCDIC .
234 The value
235 .Cm ebcdic
236 specifies the recommended one which is compatible with
237 .At V .
238 The value
239 .Cm ibm
240 is a slightly different mapping, which is compatible with the
241 .At V
242 .Cm ibm
243 value.
244 The values
245 .Cm oldebcdic
246 and
247 .Cm oldibm
248 are maps used in historic
249 .At
250 and
251 .No pre- Ns Bx 4.3 reno
252 systems.
253 .It Cm lcase
254 Transform uppercase characters into lowercase characters.
255 .It Cm pareven , parnone , parodd , parset
256 Output data with the specified parity.
257 The parity bit on input is stripped unless
258 .Tn EBCDIC
259 to
260 .Tn ASCII
261 conversions is also specified.
262 .It Cm noerror
263 Do not stop processing on an input error.
264 When an input error occurs, a diagnostic message followed by the current
265 input and output block counts will be written to the standard error output
266 in the same format as the standard completion message.
267 If the
268 .Cm sync
269 conversion is also specified, any missing input data will be replaced
270 with
271 .Dv NUL
272 bytes (or with spaces if a block oriented conversion value was
273 specified) and processed as a normal input buffer.
274 If the
275 .Cm fillchar
276 option is specified, the fill character provided on the command line
277 will override
278 the automatic selection of the fill character.
279 If the
280 .Cm sync
281 conversion is not specified, the input block is omitted from the output.
282 On input files which are not tapes or pipes, the file offset
283 will be positioned past the block in which the error occurred using
284 .Xr lseek 2 .
285 .It Cm notrunc
286 Do not truncate the output file.
287 This will preserve any blocks in the output file not explicitly written
288 by
289 .Nm .
290 The
291 .Cm notrunc
292 value is not supported for tapes.
293 .It Cm osync
294 Pad the final output block to the full output block size.
295 If the input file is not a multiple of the output block size
296 after conversion, this conversion forces the final output block
297 to be the same size as preceding blocks for use on devices that require
298 regularly sized blocks to be written.
299 This option is incompatible with use of the
300 .Cm bs Ns = Ns Ar n
301 block size specification.
302 .It Cm sparse
303 If one or more output blocks would consist solely of
304 .Dv NUL
305 bytes, try to seek the output file by the required space instead of
306 filling them with
307 .Dv NUL Ns s ,
308 resulting in a sparse file.
309 .It Cm swab
310 Swap every pair of input bytes.
311 If an input buffer has an odd number of bytes, the last byte will be
312 ignored during swapping.
313 .It Cm sync
314 Pad every input block to the input buffer size.
315 Spaces are used for pad bytes if a block oriented conversion value is
316 specified, otherwise
317 .Dv NUL
318 bytes are used.
319 .It Cm ucase
320 Transform lowercase characters into uppercase characters.
321 .It Cm unblock
322 Treats the input as a sequence of fixed length records independent of input
323 and output block boundaries.
324 The length of the input records is specified by the
325 .Cm cbs
326 operand.
327 Any trailing space characters are discarded and a newline character is
328 appended.
329 .El
330 .El
331 .Pp
332 Where sizes or speed are specified, a decimal, octal, or hexadecimal number of
333 bytes is expected.
334 If the number ends with a
335 .Dq Li b ,
336 .Dq Li k ,
337 .Dq Li m ,
338 .Dq Li g ,
339 .Dq Li t ,
340 .Dq Li p ,
341 or
342 .Dq Li w ,
343 the
344 number is multiplied by 512, 1024 (1K), 1048576 (1M), 1073741824 (1G),
345 1099511627776 (1T), 1125899906842624 (1P)
346 or the number of bytes in an integer, respectively.
347 Two or more numbers may be separated by an
348 .Dq Li x
349 to indicate a product.
350 .Pp
351 When finished,
352 .Nm
353 displays the number of complete and partial input and output blocks,
354 truncated input records and odd-length byte-swapping blocks to the
355 standard error output.
356 A partial input block is one where less than the input block size
357 was read.
358 A partial output block is one where less than the output block size
359 was written.
360 Partial output blocks to tape devices are considered fatal errors.
361 Otherwise, the rest of the block will be written.
362 Partial output blocks to character devices will produce a warning message.
363 A truncated input block is one where a variable length record oriented
364 conversion value was specified and the input line was too long to
365 fit in the conversion record or was not newline terminated.
366 .Pp
367 Normally, data resulting from input or conversion or both are aggregated
368 into output blocks of the specified size.
369 After the end of input is reached, any remaining output is written as
370 a block.
371 This means that the final output block may be shorter than the output
372 block size.
373 .Pp
374 If
375 .Nm
376 receives a
377 .Dv SIGINFO
378 (see the
379 .Cm status
380 argument for
381 .Xr stty 1 )
382 signal, the current input and output block counts will
383 be written to the standard error output
384 in the same format as the standard completion message.
385 If
386 .Nm
387 receives a
388 .Dv SIGINT
389 signal, the current input and output block counts will
390 be written to the standard error output
391 in the same format as the standard completion message and
392 .Nm
393 will exit.
394 .Sh EXIT STATUS
395 .Ex -std
396 .Sh EXAMPLES
397 Check that a disk drive contains no bad blocks:
398 .Pp
399 .Dl "dd if=/dev/ada0 of=/dev/null bs=1m"
400 .Pp
401 Do a refresh of a disk drive, in order to prevent presently
402 recoverable read errors from progressing into unrecoverable read errors:
403 .Pp
404 .Dl "dd if=/dev/ada0 of=/dev/ada0 bs=1m"
405 .Pp
406 Remove parity bit from a file:
407 .Pp
408 .Dl "dd if=file conv=parnone of=file.txt"
409 .Pp
410 Check for (even) parity errors on a file:
411 .Pp
412 .Dl "dd if=file conv=pareven | cmp -x - file"
413 .Pp
414 To create an image of a Mode-1 CD-ROM, which is a commonly used format
415 for data CD-ROM disks, use a block size of 2048 bytes:
416 .Pp
417 .Dl "dd if=/dev/cd0 of=filename.iso bs=2048"
418 .Pp
419 Write a filesystem image to a memory stick, padding the end with zeros,
420 if necessary, to a 1MiB boundary:
421 .Pp
422 .Dl "dd if=memstick.img of=/dev/da0 bs=1m conv=noerror,sync"
423 .Sh SEE ALSO
424 .Xr cp 1 ,
425 .Xr mt 1 ,
426 .Xr recoverdisk 1 ,
427 .Xr tr 1 ,
428 .Xr geom 4
429 .Sh STANDARDS
430 The
431 .Nm
432 utility is expected to be a superset of the
433 .St -p1003.2
434 standard.
435 The
436 .Cm files
437 and
438 .Cm status
439 operands and the
440 .Cm ascii ,
441 .Cm ebcdic ,
442 .Cm ibm ,
443 .Cm oldascii ,
444 .Cm oldebcdic
445 and
446 .Cm oldibm
447 values are extensions to the
448 .Tn POSIX
449 standard.
450 .Sh HISTORY
451 A
452 .Nm
453 command appeared in
454 .At v5 .
455 .Sh BUGS
456 Protection mechanisms in the
457 .Xr geom 4
458 subsystem might prevent the super-user from writing blocks to a disk.
459 Instructions for temporarily disabling these protection mechanisms can be
460 found in the
461 .Xr geom 4
462 man page.