9 @c ======================================================================
10 @c This document has three levels of rendition: PUBLISH, DISTRIB or PROOF,
11 @c as decided by @set symbols. The PUBLISH rendition does not show
12 @c notes or marks asking for revision. Most users will prefer having more
13 @c information, even if this information is not fully revised for adequacy,
14 @c so DISTRIB is the default for tar distributions. The PROOF rendition
15 @c show all marks to the point of ugliness, but is nevertheless useful to
16 @c those working on the manual itself.
17 @c ======================================================================
28 @set RENDITION The book, version
32 @set RENDITION FTP release, version
36 @set RENDITION Proof reading version
39 @c ---------------------------------------------------------------------
40 @c The @FIXME's, @UNREVISED and @c comments are part Fran@,{c}ois's work
41 @c plan. These annotations are somewhat precious to him; he asks that I
42 @c do not alter them inconsiderately. Much work is needed for GNU tar
43 @c internals (the sources, the programs themselves). Revising the
44 @c adequacy of the manual while revising the sources, and cleaning them
45 @c both at the same time, seems to him like a good way to proceed.
46 @c ---------------------------------------------------------------------
48 @c Output marks for nodes needing revision, but not in PUBLISH rendition.
53 @emph{(This message will disappear, once this node revised.)}
58 @c Output various FIXME information only in PROOF rendition.
64 @strong{<FIXME>} \string\ @strong{</>}
69 @macro FIXME-ref{string}
72 @strong{<REF>} \string\ @strong{</>}
77 @macro FIXME-pxref{string}
80 @strong{<PXREF>} \string\ @strong{</>}
85 @macro FIXME-xref{string}
88 @strong{<XREF>} \string\ @strong{</>}
93 @c @macro option{entry}
95 @c @opindex{--\entry\}
99 @set op-absolute-names @kbd{--absolute-names} (@kbd{-P})
100 @set ref-absolute-names @ref{absolute}
101 @set xref-absolute-names @xref{absolute}
102 @set pxref-absolute-names @pxref{absolute}
104 @set op-after-date @kbd{--after-date=@var{date}} (@kbd{--newer=@var{date}}, @kbd{-N @var{date}})
105 @set ref-after-date @ref{after}
106 @set xref-after-date @xref{after}
107 @set pxref-after-date @pxref{after}
109 @set op-append @kbd{--append} (@kbd{-r})
110 @set ref-append @ref{add}
111 @set xref-append @xref{add}
112 @set pxref-append @pxref{add}
114 @set op-atime-preserve @kbd{--atime-preserve}
115 @set ref-atime-preserve @ref{Attributes}
116 @set xref-atime-preserve @xref{Attributes}
117 @set pxref-atime-preserve @pxref{Attributes}
119 @set op-backup @kbd{--backup}
120 @set ref-backup @ref{Backup options}
121 @set xref-backup @xref{Backup options}
122 @set pxref-backup @pxref{Backup options}
124 @set op-block-number @kbd{--block-number} (@kbd{-R})
125 @set ref-block-number @ref{verbose}
126 @set xref-block-number @xref{verbose}
127 @set pxref-block-number @pxref{verbose}
129 @set op-blocking-factor @kbd{--blocking-factor=@var{512-size}} (@kbd{-b @var{512-size}})
130 @set ref-blocking-factor @ref{Blocking Factor}
131 @set xref-blocking-factor @xref{Blocking Factor}
132 @set pxref-blocking-factor @pxref{Blocking Factor}
134 @set op-bzip2 @kbd{--bzip2} (@kbd{-j})
135 @set ref-bzip2 @ref{gzip}
136 @set xref-bzip2 @xref{gzip}
137 @set pxref-bzip2 @pxref{gzip}
139 @set op-checkpoint @kbd{--checkpoint}
140 @set ref-checkpoint @ref{verbose}
141 @set xref-checkpoint @xref{verbose}
142 @set pxref-checkpoint @pxref{verbose}
144 @set op-compare @kbd{--compare} (@kbd{--diff}, @kbd{-d})
145 @set ref-compare @ref{compare}
146 @set xref-compare @xref{compare}
147 @set pxref-compare @pxref{compare}
149 @set op-compress @kbd{--compress} (@kbd{--uncompress}, @kbd{-Z})
150 @set ref-compress @ref{gzip}
151 @set xref-compress @xref{gzip}
152 @set pxref-compress @pxref{gzip}
154 @set op-concatenate @kbd{--concatenate} (@kbd{--catenate}, @kbd{-A})
155 @set ref-concatenate @ref{concatenate}
156 @set xref-concatenate @xref{concatenate}
157 @set pxref-concatenate @pxref{concatenate}
159 @set op-create @kbd{--create} (@kbd{-c})
160 @set ref-create @ref{create}
161 @set xref-create @xref{create}
162 @set pxref-create @pxref{create}
164 @set op-delete @kbd{--delete}
165 @set ref-delete @ref{delete}
166 @set xref-delete @xref{delete}
167 @set pxref-delete @pxref{delete}
169 @set op-dereference @kbd{--dereference} (@kbd{-h})
170 @set ref-dereference @ref{dereference}
171 @set xref-dereference @xref{dereference}
172 @set pxref-dereference @pxref{dereference}
174 @set op-directory @kbd{--directory=@var{directory}} (@kbd{-C @var{directory}})
175 @set ref-directory @ref{directory}
176 @set xref-directory @xref{directory}
177 @set pxref-directory @pxref{directory}
179 @set op-exclude @kbd{--exclude=@var{pattern}}
180 @set ref-exclude @ref{exclude}
181 @set xref-exclude @xref{exclude}
182 @set pxref-exclude @pxref{exclude}
184 @set op-exclude-from @kbd{--exclude-from=@var{file-of-patterns}} (@kbd{-X @var{file-of-patterns}})
185 @set ref-exclude-from @ref{exclude}
186 @set xref-exclude-from @xref{exclude}
187 @set pxref-exclude-from @pxref{exclude}
189 @set op-extract @kbd{--extract} (@kbd{--get}, @kbd{-x})
190 @set ref-extract @ref{extract}
191 @set xref-extract @xref{extract}
192 @set pxref-extract @pxref{extract}
194 @set op-file @kbd{--file=@var{archive-name}} (@kbd{-f @var{archive-name}})
195 @set ref-file @ref{file}
196 @set xref-file @xref{file}
197 @set pxref-file @pxref{file}
199 @set op-files-from @kbd{--files-from=@var{file-of-names}} (@kbd{-I @var{file-of-names}}, @kbd{-T @var{file-of-names}})
200 @set ref-files-from @ref{files}
201 @set xref-files-from @xref{files}
202 @set pxref-files-from @pxref{files}
204 @set op-force-local @kbd{--force-local}
205 @set ref-force-local @ref{file}
206 @set xref-force-local @xref{file}
207 @set pxref-force-local @pxref{file}
209 @set op-group @kbd{--group=@var{group}}
210 @set ref-group @ref{Option Summary}
211 @set xref-group @xref{Option Summary}
212 @set pxref-group @pxref{Option Summary}
214 @set op-gzip @kbd{--gzip} (@kbd{--gunzip}, @kbd{--ungzip}, @kbd{-z})
215 @set ref-gzip @ref{gzip}
216 @set xref-gzip @xref{gzip}
217 @set pxref-gzip @pxref{gzip}
219 @set op-help @kbd{--help}
220 @set ref-help @ref{help}
221 @set xref-help @xref{help}
222 @set pxref-help @pxref{help}
224 @set op-ignore-failed-read @kbd{--ignore-failed-read}
225 @set ref-ignore-failed-read @ref{create options}
226 @set xref-ignore-failed-read @xref{create options}
227 @set pxref-ignore-failed-read @pxref{create options}
229 @set op-ignore-zeros @kbd{--ignore-zeros} (@kbd{-i})
230 @set ref-ignore-zeros @ref{Reading}
231 @set xref-ignore-zeros @xref{Reading}
232 @set pxref-ignore-zeros @pxref{Reading}
234 @set op-incremental @kbd{--incremental} (@kbd{-G})
235 @set ref-incremental @ref{Inc Dumps}
236 @set xref-incremental @xref{Inc Dumps}
237 @set pxref-incremental @pxref{Inc Dumps}
239 @set op-info-script @kbd{--info-script=@var{script-name}} (@kbd{--new-volume-script=@var{script-name}}, @kbd{-F @var{script-name}})
240 @set ref-info-script @ref{Multi-Volume Archives}
241 @set xref-info-script @xref{Multi-Volume Archives}
242 @set pxref-info-script @pxref{Multi-Volume Archives}
244 @set op-interactive @kbd{--interactive} (@kbd{-w})
245 @set ref-interactive @ref{interactive}
246 @set xref-interactive @xref{interactive}
247 @set pxref-interactive @pxref{interactive}
249 @set op-keep-old-files @kbd{--keep-old-files} (@kbd{-k})
250 @set ref-keep-old-files @ref{Writing}
251 @set xref-keep-old-files @xref{Writing}
252 @set pxref-keep-old-files @pxref{Writing}
254 @set op-label @kbd{--label=@var{archive-label}} (@kbd{-V @var{archive-label}})
255 @set ref-label @ref{label}
256 @set xref-label @xref{label}
257 @set pxref-label @pxref{label}
259 @set op-list @kbd{--list} (@kbd{-t})
260 @set ref-list @ref{list}
261 @set xref-list @xref{list}
262 @set pxref-list @pxref{list}
264 @set op-listed-incremental @kbd{--listed-incremental=@var{snapshot-file}} (@kbd{-g @var{snapshot-file}})
265 @set ref-listed-incremental @ref{Inc Dumps}
266 @set xref-listed-incremental @xref{Inc Dumps}
267 @set pxref-listed-incremental @pxref{Inc Dumps}
269 @set op-mode @kbd{--mode=@var{permissions}}
270 @set ref-mode @ref{Option Summary}
271 @set xref-mode @xref{Option Summary}
272 @set pxref-mode @pxref{Option Summary}
274 @set op-multi-volume @kbd{--multi-volume} (@kbd{-M})
275 @set ref-multi-volume @ref{Multi-Volume Archives}
276 @set xref-multi-volume @xref{Multi-Volume Archives}
277 @set pxref-multi-volume @pxref{Multi-Volume Archives}
279 @set op-newer-mtime @kbd{--newer-mtime=@var{date}}
280 @set ref-newer-mtime @ref{after}
281 @set xref-newer-mtime @xref{after}
282 @set pxref-newer-mtime @pxref{after}
284 @set op-no-recursion @kbd{--no-recursion}
285 @set ref-no-recursion @ref{recurse}
286 @set xref-no-recursion @xref{recurse}
287 @set pxref-no-recursion @pxref{recurse}
289 @set op-no-same-owner @kbd{--no-same-owner}
290 @set ref-no-same-owner @ref{Attributes}
291 @set xref-no-same-owner @xref{Attributes}
292 @set pxref-no-same-owner @pxref{Attributes}
294 @set op-no-same-permissions @kbd{--no-same-permissions}
295 @set ref-no-same-permissions @ref{Attributes}
296 @set xref-no-same-permissions @xref{Attributes}
297 @set pxref-no-same-permissions @pxref{Attributes}
299 @set op-null @kbd{--null}
300 @set ref-null @ref{files}
301 @set xref-null @xref{files}
302 @set pxref-null @pxref{files}
304 @set op-numeric-owner @kbd{--numeric-owner}
305 @set ref-numeric-owner @ref{Attributes}
306 @set xref-numeric-owner @xref{Attributes}
307 @set pxref-numeric-owner @pxref{Attributes}
309 @set op-old-archive @kbd{--old-archive} (@kbd{-o})
310 @set ref-old-archive @ref{old}
311 @set xref-old-archive @xref{old}
312 @set pxref-old-archive @pxref{old}
314 @set op-one-file-system @kbd{--one-file-system} (@kbd{-l})
315 @set ref-one-file-system @ref{one}
316 @set xref-one-file-system @xref{one}
317 @set pxref-one-file-system @pxref{one}
319 @set op-overwrite @kbd{--overwrite}
320 @set ref-overwrite @ref{Overwrite Old Files}
321 @set xref-overwrite @xref{Overwrite Old Files}
322 @set pxref-overwrite @pxref{Overwrite Old Files}
324 @set op-owner @kbd{--owner=@var{user}}
325 @set ref-owner @ref{Option Summary}
326 @set xref-owner @xref{Option Summary}
327 @set pxref-owner @pxref{Option Summary}
329 @set op-posix @kbd{--posix}
330 @set ref-posix @ref{posix}
331 @set xref-posix @xref{posix}
332 @set pxref-posix @pxref{posix}
334 @set op-preserve @kbd{--preserve}
335 @set ref-preserve @ref{Attributes}
336 @set xref-preserve @xref{Attributes}
337 @set pxref-preserve @pxref{Attributes}
339 @set op-record-size @kbd{--record-size=@var{size}}
340 @set ref-record-size @ref{Blocking}
341 @set xref-record-size @xref{Blocking}
342 @set pxref-record-size @pxref{Blocking}
344 @set op-recursive-unlink @kbd{--recursive-unlink}
345 @set ref-recursive-unlink @ref{Writing}
346 @set xref-recursive-unlink @xref{Writing}
347 @set pxref-recursive-unlink @pxref{Writing}
349 @set op-read-full-records @kbd{--read-full-records} (@kbd{-B})
350 @set ref-read-full-records @ref{Blocking}
351 @set xref-read-full-records @xref{Blocking}
352 @set pxref-read-full-records @pxref{Blocking}
353 @c FIXME: or should it be Reading, or Blocking Factor
355 @set op-remove-files @kbd{--remove-files}
356 @set ref-remove-files @ref{Writing}
357 @set xref-remove-files @xref{Writing}
358 @set pxref-remove-files @pxref{Writing}
360 @set op-rsh-command @kbd{rsh-command=@var{command}}
362 @set op-same-order @kbd{--same-order} (@kbd{--preserve-order}, @kbd{-s})
363 @set ref-same-order @ref{Scarce}
364 @set xref-same-order @xref{Scarce}
365 @set pxref-same-order @pxref{Scarce}
366 @c FIXME: or should it be Reading, or Attributes?
368 @set op-same-owner @kbd{--same-owner}
369 @set ref-same-owner @ref{Attributes}
370 @set xref-same-owner @xref{Attributes}
371 @set pxref-same-owner @pxref{Attributes}
373 @set op-same-permissions @kbd{--same-permissions} (@kbd{--preserve-permissions}, @kbd{-p})
374 @set ref-same-permissions @ref{Attributes}
375 @set xref-same-permissions @xref{Attributes}
376 @set pxref-same-permissions @pxref{Attributes}
377 @c FIXME: or should it be Writing?
379 @set op-show-omitted-dirs @kbd{--show-omitted-dirs}
380 @set ref-show-omitted-dirs @ref{verbose}
381 @set xref-show-omitted-dirs @xref{verbose}
382 @set pxref-show-omitted-dirs @pxref{verbose}
384 @set op-sparse @kbd{--sparse} (@kbd{-S})
385 @set ref-sparse @ref{sparse}
386 @set xref-sparse @xref{sparse}
387 @set pxref-sparse @pxref{sparse}
389 @set op-starting-file @kbd{--starting-file=@var{name}} (@kbd{-K @var{name}})
390 @set ref-starting-file @ref{Scarce}
391 @set xref-starting-file @xref{Scarce}
392 @set pxref-starting-file @pxref{Scarce}
394 @set op-suffix @kbd{--suffix=@var{suffix}}
395 @set ref-suffix @ref{Backup options}
396 @set xref-suffix @xref{Backup options}
397 @set pxref-suffix @pxref{Backup options}
399 @set op-tape-length @kbd{--tape-length=@var{1024-size}} (@kbd{-L @var{1024-size}})
400 @set ref-tape-length @ref{Using Multiple Tapes}
401 @set xref-tape-length @xref{Using Multiple Tapes}
402 @set pxref-tape-length @pxref{Using Multiple Tapes}
404 @set op-to-stdout @kbd{--to-stdout} (@kbd{-O})
405 @set ref-to-stdout @ref{Writing}
406 @set xref-to-stdout @xref{Writing}
407 @set pxref-to-stdout @pxref{Writing}
409 @set op-totals @kbd{--totals}
410 @set ref-totals @ref{verbose}
411 @set xref-totals @xref{verbose}
412 @set pxref-totals @pxref{verbose}
414 @set op-touch @kbd{--touch} (@kbd{-m})
415 @set ref-touch @ref{Writing}
416 @set xref-touch @xref{Writing}
417 @set pxref-touch @pxref{Writing}
419 @set op-unlink-first @kbd{--unlink-first} (@kbd{-U})
420 @set ref-unlink-first @ref{Writing}
421 @set xref-unlink-first @xref{Writing}
422 @set pxref-unlink-first @pxref{Writing}
424 @set op-update @kbd{--update} (@kbd{-u})
425 @set ref-update @ref{update}
426 @set xref-update @xref{update}
427 @set pxref-update @pxref{update}
429 @set op-use-compress-prog @kbd{--use-compress-prog=@var{program}}
430 @set ref-use-compress-prog @ref{gzip}
431 @set xref-use-compress-prog @xref{gzip}
432 @set pxref-use-compress-prog @pxref{gzip}
434 @set op-verbose @kbd{--verbose} (@kbd{-v})
435 @set ref-verbose @ref{verbose}
436 @set xref-verbose @xref{verbose}
437 @set pxref-verbose @pxref{verbose}
439 @set op-verify @kbd{--verify} (@kbd{-W})
440 @set ref-verify @ref{verify}
441 @set xref-verify @xref{verify}
442 @set pxref-verify @pxref{verify}
444 @set op-version @kbd{--version}
445 @set ref-version @ref{help}
446 @set xref-version @xref{help}
447 @set pxref-version @pxref{help}
449 @set op-volno-file @kbd{--volno-file=@var{file-of-number}}
450 @set ref-volno-file @ref{Using Multiple Tapes}
451 @set xref-volno-file @xref{Using Multiple Tapes}
452 @set pxref-volno-file @pxref{Using Multiple Tapes}
454 @include version.texi
456 @c Put everything in one index (arbitrarily chosen to be the concept index).
467 * tar: (tar). Making tape (or disk) archives.
470 This file documents @sc{gnu} @command{tar}, which creates and extracts
473 Published by the Free Software Foundation,
474 59 Temple Place - Suite 330,
475 Boston, MA 02111-1307, USA
477 Copyright 1992, 1994, 1995, 1996, 1997, 1999, 2000 Free Software
480 Permission is granted to copy, distribute and/or modify this document
481 under the terms of the GNU Free Documentation License, Version 1.1
482 or any later version published by the Free Software Foundation;
483 with no Invariant Sections, with no
484 Front-Cover Texts, and with no Back-Cover Texts.
485 A copy of the license is included in the section entitled ``GNU
486 Free Documentation License''.
490 @setchapternewpage odd
492 @shorttitlepage @sc{gnu} @command{tar}
495 @title @sc{gnu} tar: an archiver tool
496 @subtitle @value{RENDITION} @value{VERSION}, @value{UPDATED}
497 @author Melissa Weisshaus, Jay Fenlason,
498 @author Thomas Bushnell, n/BSG, Amy Gorin
499 @c he said to remove it: Fran@,{c}ois Pinard
500 @c i'm thinking about how the author page *should* look. -mew 2may96
503 @vskip 0pt plus 1filll
504 Copyright @copyright{} 1992, 1994, 1995, 1996, 1997, 1999, 2000 Free Software
507 Permission is granted to copy, distribute and/or modify this document
508 under the terms of the GNU Free Documentation License, Version 1.1
509 or any later version published by the Free Software Foundation;
510 with no Invariant Sections, with no
511 Front-Cover Texts, and with no Back-Cover Texts.
512 A copy of the license is included in the section entitled ``GNU
513 Free Documentation License''.
518 @top @sc{gnu} tar: an archiver tool
520 @cindex file archival
521 @cindex archiving files
523 @sc{gnu} @command{tar} creates and extracts files from archives.
525 This manual documents version @value{VERSION} of @sc{gnu} @command{tar}.
527 The first part of this master menu lists the major nodes in this Info
528 document. The rest of the menu lists all the lower level nodes.
538 * Date input formats::
541 * GNU Free Documentation License::
546 --- The Detailed Node Listing ---
550 * Book Contents:: What this Book Contains
551 * Definitions:: Some Definitions
552 * What tar Does:: What @command{tar} Does
553 * Naming tar Archives:: How @command{tar} Archives are Named
555 * Authors:: @sc{gnu} @command{tar} Authors
556 * Reports:: Reporting bugs or suggestions
558 Tutorial Introduction to @command{tar}
561 * stylistic conventions::
562 * basic tar options:: Basic @command{tar} Operations and Options
563 * frequent operations::
564 * Two Frequent Options::
565 * create:: How to Create Archives
566 * list:: How to List Archives
567 * extract:: How to Extract Members from an Archive
570 Two Frequently Used Options
576 How to Create Archives
578 * prepare for examples::
579 * Creating the archive::
588 How to Extract Members from an Archive
590 * extracting archives::
595 Invoking @sc{gnu} @command{tar}
598 * using tar options::
605 The Three Option Styles
607 * Mnemonic Options:: Mnemonic Option Style
608 * Short Options:: Short Option Style
609 * Old Options:: Old Option Style
610 * Mixing:: Mixing Option Styles
612 All @command{tar} Options
614 * Operation Summary::
616 * Short Option Summary::
618 @sc{gnu} @command{tar} Operations
628 Advanced @sc{gnu} @command{tar} Operations
638 How to Add Files to Existing Archives: @code{--append}
640 * appending files:: Appending Files to an Archive
647 Options used by @code{--create}
649 * Ignore Failed Read::
651 Options Used by @code{--extract}
653 * Reading:: Options to Help Read Archives
654 * Writing:: Changing How @command{tar} Writes Files
655 * Scarce:: Coping with Scarce Resources
657 Options to Help Read Archives
659 * read full records::
662 Changing How @command{tar} Extracts Files Over Preexisting Files
664 * Dealing with Old Files::
665 * Overwrite Old Files::
670 Changing How @command{tar} Writes Files
672 * Modification Times::
673 * Setting Access Permissions::
674 * Writing to Standard Output::
677 Coping with Scarce Resources
682 Performing Backups and Restoring Files
684 * Full Dumps:: Using @command{tar} to Perform Full Dumps
685 * Inc Dumps:: Using @command{tar} to Perform Incremental Dumps
686 * incremental and listed-incremental:: The Incremental Options
687 * Backup Levels:: Levels of Backups
688 * Backup Parameters:: Setting Parameters for Backups and Restoration
689 * Scripted Backups:: Using the Backup Scripts
690 * Scripted Restoration:: Using the Restore Script
692 Setting Parameters for Backups and Restoration
694 * backup-specs example:: An Example Text of @file{Backup-specs}
695 * Script Syntax:: Syntax for @file{Backup-specs}
697 Choosing Files and Names for @command{tar}
699 * file:: Choosing the Archive's Name
700 * Selecting Archive Members::
701 * files:: Reading Names from a File
702 * exclude:: Excluding Some Files
704 * after:: Operating Only on New Files
705 * recurse:: Descending into Directories
706 * one:: Crossing Filesystem Boundaries
708 Reading Names from a File
714 * problems with exclude::
716 Crossing Filesystem Boundaries
718 * directory:: Changing Directory
719 * absolute:: Absolute File Names
723 * General date syntax:: Common rules.
724 * Calendar date items:: 19 Dec 1994.
725 * Time of day items:: 9:20pm.
726 * Time zone items:: @sc{est}, @sc{pdt}, @sc{gmt}, ...
727 * Day of week items:: Monday and others.
728 * Relative items in date strings:: next tuesday, 2 years ago.
729 * Pure numbers in date strings:: 19931219, 1440.
730 * Authors of getdate:: Bellovin, Eggert, Berets, Salz, et al.
732 Controlling the Archive Format
734 * Portability:: Making @command{tar} Archives More Portable
735 * Compression:: Using Less Space through Compression
736 * Attributes:: Handling File Attributes
737 * Standard:: The Standard Format
738 * Extensions:: @sc{gnu} Extensions to the Archive Format
739 * cpio:: Comparison of @command{tar} and @command{cpio}
741 Making @command{tar} Archives More Portable
743 * Portable Names:: Portable Names
744 * dereference:: Symbolic Links
745 * old:: Old V7 Archives
746 * posix:: @sc{posix} archives
747 * Checksumming:: Checksumming Problems
748 * Large or Negative Values:: Large files, negative time stamps, etc.
750 Using Less Space through Compression
752 * gzip:: Creating and Reading Compressed Archives
753 * sparse:: Archiving Sparse Files
755 Tapes and Other Archive Media
757 * Device:: Device selection and switching
758 * Remote Tape Server::
759 * Common Problems and Solutions::
760 * Blocking:: Blocking
761 * Many:: Many archives on one tape
762 * Using Multiple Tapes:: Using Multiple Tapes
763 * label:: Including a Label in the Archive
769 * Format Variations:: Format Variations
770 * Blocking Factor:: The Blocking Factor of an Archive
772 Many Archives on One Tape
774 * Tape Positioning:: Tape Positions and Tape Marks
775 * mt:: The @command{mt} Utility
779 * Multi-Volume Archives:: Archives Longer than One Tape or Disk
780 * Tape Files:: Tape Files
785 @chapter Introduction
787 Welcome to the @sc{gnu} @command{tar} manual. @sc{gnu} @command{tar} creates
788 and manipulates (@dfn{archives}) which are actually collections of
789 many other files; the program provides users with an organized and
790 systematic method for controlling a large amount of data.
793 * Book Contents:: What this Book Contains
794 * Definitions:: Some Definitions
795 * What tar Does:: What @command{tar} Does
796 * Naming tar Archives:: How @command{tar} Archives are Named
798 * Authors:: @sc{gnu} @command{tar} Authors
799 * Reports:: Reporting bugs or suggestions
803 @section What this Book Contains
805 The first part of this chapter introduces you to various terms that will
806 recur throughout the book. It also tells you who has worked on @sc{gnu}
807 @command{tar} and its documentation, and where you should send bug reports
810 The second chapter is a tutorial (@pxref{Tutorial}) which provides a
811 gentle introduction for people who are new to using @command{tar}. It is
812 meant to be self contained, not requiring any reading from subsequent
813 chapters to make sense. It moves from topic to topic in a logical,
814 progressive order, building on information already explained.
816 Although the tutorial is paced and structured to allow beginners to
817 learn how to use @command{tar}, it is not intended solely for beginners.
818 The tutorial explains how to use the three most frequently used
819 operations (@samp{create}, @samp{list}, and @samp{extract}) as well as
820 two frequently used options (@samp{file} and @samp{verbose}). The other
821 chapters do not refer to the tutorial frequently; however, if a section
822 discusses something which is a complex variant of a basic concept, there
823 may be a cross reference to that basic concept. (The entire book,
824 including the tutorial, assumes that the reader understands some basic
825 concepts of using a Unix-type operating system; @pxref{Tutorial}.)
827 The third chapter presents the remaining five operations, and
828 information about using @command{tar} options and option syntax.
830 @FIXME{this sounds more like a @sc{gnu} Project Manuals Concept [tm] more
831 than the reality. should think about whether this makes sense to say
832 here, or not.} The other chapters are meant to be used as a
833 reference. Each chapter presents everything that needs to be said
834 about a specific topic.
836 One of the chapters (@pxref{Date input formats}) exists in its entirety
837 in other @sc{gnu} manuals, and is mostly self-contained. In addition, one
838 section of this manual (@pxref{Standard}) contains a big quote which is
839 taken directly from @command{tar} sources.
841 In general, we give both the long and short (abbreviated) option names
842 at least once in each section where the relevant option is covered, so
843 that novice readers will become familiar with both styles. (A few
844 options have no short versions, and the relevant sections will
848 @section Some Definitions
852 The @command{tar} program is used to create and manipulate @command{tar}
853 archives. An @dfn{archive} is a single file which contains the contents
854 of many files, while still identifying the names of the files, their
855 owner(s), and so forth. (In addition, archives record access
856 permissions, user and group, size in bytes, and last modification time.
857 Some archives also record the file names in each archived directory, as
858 well as other file and directory information.) You can use @command{tar}
859 to @dfn{create} a new archive in a specified directory.
862 @cindex archive member
865 The files inside an archive are called @dfn{members}. Within this
866 manual, we use the term @dfn{file} to refer only to files accessible in
867 the normal ways (by @command{ls}, @command{cat}, and so forth), and the term
868 @dfn{member} to refer only to the members of an archive. Similarly, a
869 @dfn{file name} is the name of a file, as it resides in the filesystem,
870 and a @dfn{member name} is the name of an archive member within the
875 The term @dfn{extraction} refers to the process of copying an archive
876 member (or multiple members) into a file in the filesystem. Extracting
877 all the members of an archive is often called @dfn{extracting the
878 archive}. The term @dfn{unpack} can also be used to refer to the
879 extraction of many or all the members of an archive. Extracting an
880 archive does not destroy the archive's structure, just as creating an
881 archive does not destroy the copies of the files that exist outside of
882 the archive. You may also @dfn{list} the members in a given archive
883 (this is often thought of as ``printing'' them to the standard output,
884 or the command line), or @dfn{append} members to a pre-existing archive.
885 All of these operations can be performed using @command{tar}.
888 @section What @command{tar} Does
891 The @command{tar} program provides the ability to create @command{tar}
892 archives, as well as various other kinds of manipulation. For example,
893 you can use @command{tar} on previously created archives to extract files,
894 to store additional files, or to update or list files which were already
897 Initially, @command{tar} archives were used to store files conveniently on
898 magnetic tape. The name @command{tar} comes from this use; it stands for
899 @code{t}ape @code{ar}chiver. Despite the utility's name, @command{tar} can
900 direct its output to available devices, files, or other programs (using
901 pipes). @command{tar} may even access remote devices or files (as archives).
903 @FIXME{the following table entries need a bit of work..}
905 You can use @command{tar} archives in many ways. We want to stress a few
906 of them: storage, backup, and transportation.
910 Often, @command{tar} archives are used to store related files for
911 convenient file transfer over a network. For example, the @sc{gnu} Project
912 distributes its software bundled into @command{tar} archives, so that
913 all the files relating to a particular program (or set of related
914 programs) can be transferred as a single unit.
916 A magnetic tape can store several files in sequence. However, the tape
917 has no names for these files; it only knows their relative position on
918 the tape. One way to store several files on one tape and retain their
919 names is by creating a @command{tar} archive. Even when the basic transfer
920 mechanism can keep track of names, as FTP can, the nuisance of handling
921 multiple files, directories, and multiple links makes @command{tar}
924 Archive files are also used for long-term storage. You can think of
925 this as transportation from the present into the future. (It is a
926 science-fiction idiom that you can move through time as well as in
927 space; the idea here is that @command{tar} can be used to move archives in
928 all dimensions, even time!)
931 Because the archive created by @command{tar} is capable of preserving file
932 information and directory structure, @command{tar} is commonly used for
933 performing full and incremental backups of disks. A backup puts a
934 collection of files (possibly pertaining to many users and
935 projects) together on a disk or a tape. This guards against accidental
936 destruction of the information in those files. @sc{gnu} @command{tar} has
937 special features that allow it to be used to make incremental and full
938 dumps of all the files in a filesystem.
941 You can create an archive on one system, transfer it to another system,
942 and extract the contents there. This allows you to transport a group of
943 files from one system to another.
946 @node Naming tar Archives
947 @section How @command{tar} Archives are Named
949 Conventionally, @command{tar} archives are given names ending with
950 @samp{.tar}. This is not necessary for @command{tar} to operate properly,
951 but this manual follows that convention in order to accustom readers to
952 it and to make examples more clear.
957 Often, people refer to @command{tar} archives as ``@command{tar} files,'' and
958 archive members as ``files'' or ``entries''. For people familiar with
959 the operation of @command{tar}, this causes no difficulty. However, in
960 this manual, we consistently refer to ``archives'' and ``archive
961 members'' to make learning to use @command{tar} easier for novice users.
963 @node posix compliance
964 @section @sc{posix} Compliance
967 @FIXME{must ask franc,ois about this. dan hagerty thinks this might
968 be an issue, but we're not really sure at this time. dan just tried a
969 test case of mixing up options' orders while the variable was set, and
970 there was no problem...}
972 We make some of our recommendations throughout this book for one
973 reason in addition to what we think of as ``good sense''. The main
974 additional reason for a recommendation is to be compliant with the
975 @sc{posix} standards. If you set the shell environment variable
976 @env{POSIXLY_CORRECT}, @sc{gnu} @command{tar} will force you to adhere to
977 these standards. Therefore, if this variable is set and you violate
978 one of the @sc{posix} standards in the way you phrase a command, for
979 example, @sc{gnu} @command{tar} will not allow the command and will signal an
980 error message. You would then have to reorder the options or rephrase
981 the command to comply with the @sc{posix} standards.
983 There is a chance in the future that, if you set this environment
984 variable, your archives will be forced to comply with @sc{posix} standards,
985 also. No @sc{gnu} @command{tar} extensions will be allowed.
988 @section @sc{gnu} @command{tar} Authors
990 @sc{gnu} @command{tar} was originally written by John Gilmore, and modified by
991 many people. The @sc{gnu} enhancements were written by Jay Fenlason, then
992 Joy Kendall, and the whole package has been further maintained by
993 Thomas Bushnell, n/BSG, and finally Fran@,{c}ois Pinard, with
994 the help of numerous and kind users.
996 We wish to stress that @command{tar} is a collective work, and owes much to
997 all those people who reported problems, offered solutions and other
998 insights, or shared their thoughts and suggestions. An impressive, yet
999 partial list of those contributors can be found in the @file{THANKS}
1000 file from the @sc{gnu} @command{tar} distribution.
1002 @FIXME{i want all of these names mentioned, Absolutely. BUT, i'm not
1003 sure i want to spell out the history in this detail, at least not for
1004 the printed book. i'm just not sure it needs to be said this way.
1005 i'll think about it.}
1007 @FIXME{History is more important, and surely more interesting, than
1008 actual names. Quoting names without history would be meaningless. FP}
1010 Jay Fenlason put together a draft of a @sc{gnu} @command{tar} manual,
1011 borrowing notes from the original man page from John Gilmore. This
1012 was withdrawn in version
1013 1.11. Thomas Bushnell, n/BSG and Amy Gorin worked on a tutorial and
1014 manual for @sc{gnu} @command{tar}. Fran@,{c}ois Pinard put version 1.11.8
1015 of the manual together by taking information from all these sources
1016 and merging them. Melissa Weisshaus finally edited and redesigned the
1017 book to create version 1.12. @FIXME{update version number as
1018 necessary; i'm being optimistic!} @FIXME{Someone [maybe karl berry?
1019 maybe bob chassell? maybe melissa? maybe julie sussman?] needs to
1020 properly index the thing.}
1022 For version 1.12, Daniel Hagerty contributed a great deal of technical
1023 consulting. In particular, he is the primary author of @ref{Backups}.
1026 @section Reporting bugs or suggestions
1029 @cindex reporting bugs
1030 If you find problems or have suggestions about this program or manual,
1031 please report them to @file{bug-tar@@gnu.org}.
1034 @chapter Tutorial Introduction to @command{tar}
1036 This chapter guides you through some basic examples of three @command{tar}
1037 operations: @samp{--create}, @samp{--list}, and @samp{--extract}. If
1038 you already know how to use some other version of @command{tar}, then you
1039 may not need to read this chapter. This chapter omits most complicated
1040 details about how @command{tar} works.
1044 * stylistic conventions::
1045 * basic tar options:: Basic @command{tar} Operations and Options
1046 * frequent operations::
1047 * Two Frequent Options::
1048 * create:: How to Create Archives
1049 * list:: How to List Archives
1050 * extract:: How to Extract Members from an Archive
1055 @section Assumptions this Tutorial Makes
1057 This chapter is paced to allow beginners to learn about @command{tar}
1058 slowly. At the same time, we will try to cover all the basic aspects of
1059 these three operations. In order to accomplish both of these tasks, we
1060 have made certain assumptions about your knowledge before reading this
1061 manual, and the hardware you will be using:
1065 Before you start to work through this tutorial, you should understand
1066 what the terms ``archive'' and ``archive member'' mean
1067 (@pxref{Definitions}). In addition, you should understand something
1068 about how Unix-type operating systems work, and you should know how to
1069 use some basic utilities. For example, you should know how to create,
1070 list, copy, rename, edit, and delete files and directories; how to
1071 change between directories; and how to figure out where you are in the
1072 filesystem. You should have some basic understanding of directory
1073 structure and how files are named according to which directory they are
1074 in. You should understand concepts such as standard output and standard
1075 input, what various definitions of the term ``argument'' mean, and the
1076 differences between relative and absolute path names. @FIXME{and what
1080 This manual assumes that you are working from your own home directory
1081 (unless we state otherwise). In this tutorial, you will create a
1082 directory to practice @command{tar} commands in. When we show path names,
1083 we will assume that those paths are relative to your home directory.
1084 For example, my home directory path is @file{/home/fsf/melissa}. All of
1085 my examples are in a subdirectory of the directory named by that path
1086 name; the subdirectory is called @file{practice}.
1089 In general, we show examples of archives which exist on (or can be
1090 written to, or worked with from) a directory on a hard disk. In most
1091 cases, you could write those archives to, or work with them on any other
1092 device, such as a tape drive. However, some of the later examples in
1093 the tutorial and next chapter will not work on tape drives.
1094 Additionally, working with tapes is much more complicated than working
1095 with hard disks. For these reasons, the tutorial does not cover working
1096 with tape drives. @xref{Media}, for complete information on using
1097 @command{tar} archives with tape drives.
1099 @FIXME{this is a cop out. need to add some simple tape drive info.}
1102 @node stylistic conventions
1103 @section Stylistic Conventions
1105 In the examples, @samp{$} represents a typical shell prompt. It
1106 precedes lines you should type; to make this more clear, those lines are
1107 shown in @kbd{this font}, as opposed to lines which represent the
1108 computer's response; those lines are shown in @code{this font}, or
1109 sometimes @samp{like this}. When we have lines which are too long to be
1110 displayed in any other way, we will show them like this:
1113 This is an example of a line which would otherwise not fit in this space.
1116 @FIXME{how often do we use smallexample?}
1118 @node basic tar options
1119 @section Basic @command{tar} Operations and Options
1121 @command{tar} can take a wide variety of arguments which specify and define
1122 the actions it will have on the particular set of files or the archive.
1123 The main types of arguments to @command{tar} fall into one of two classes:
1124 operations, and options.
1126 Some arguments fall into a class called @dfn{operations}; exactly one of
1127 these is both allowed and required for any instance of using @command{tar};
1128 you may @emph{not} specify more than one. People sometimes speak of
1129 @dfn{operating modes}. You are in a particular operating mode when you
1130 have specified the operation which specifies it; there are eight
1131 operations in total, and thus there are eight operating modes.
1133 The other arguments fall into the class known as @dfn{options}. You are
1134 not required to specify any options, and you are allowed to specify more
1135 than one at a time (depending on the way you are using @command{tar} at
1136 that time). Some options are used so frequently, and are so useful for
1137 helping you type commands more carefully that they are effectively
1138 ``required''. We will discuss them in this chapter.
1140 You can write most of the @command{tar} operations and options in any of
1141 three forms: long (mnemonic) form, short form, and old style. Some of
1142 the operations and options have no short or ``old'' forms; however, the
1143 operations and options which we will cover in this tutorial have
1144 corresponding abbreviations. @FIXME{make sure this is still the case,
1145 at the end}We will indicate those abbreviations appropriately to get
1146 you used to seeing them. (Note that the ``old style'' option forms
1147 exist in @sc{gnu} @command{tar} for compatibility with Unix @command{tar}. We
1148 present a full discussion of this way of writing options and operations
1149 appears in @ref{Old Options}, and we discuss the other two styles of
1150 writing options in @ref{Mnemonic Options} and @ref{Short Options}.)
1152 In the examples and in the text of this tutorial, we usually use the
1153 long forms of operations and options; but the ``short'' forms produce
1154 the same result and can make typing long @command{tar} commands easier.
1155 For example, instead of typing
1158 @kbd{tar --create --verbose --file=afiles.tar apple angst aspic}
1164 @kbd{tar -c -v -f afiles.tar apple angst aspic}
1170 @kbd{tar -cvf afiles.tar apple angst aspic}
1174 For more information on option syntax, see @ref{Advanced tar}. In
1175 discussions in the text, when we name an option by its long form, we
1176 also give the corresponding short option in parentheses.
1178 The term, ``option'', can be confusing at times, since ``operations''
1179 are often lumped in with the actual, @emph{optional} ``options'' in certain
1180 general class statements. For example, we just talked about ``short and
1181 long forms of options and operations''. However, experienced @command{tar}
1182 users often refer to these by shorthand terms such as, ``short and long
1183 options''. This term assumes that the ``operations'' are included, also.
1184 Context will help you determine which definition of ``options'' to use.
1186 Similarly, the term ``command'' can be confusing, as it is often used in
1187 two different ways. People sometimes refer to @command{tar} ``commands''.
1188 A @command{tar} @dfn{command} is the entire command line of user input
1189 which tells @command{tar} what to do --- including the operation, options,
1190 and any arguments (file names, pipes, other commands, etc). However,
1191 you will also sometimes hear the term ``the @command{tar} command''. When
1192 the word ``command'' is used specifically like this, a person is usually
1193 referring to the @command{tar} @emph{operation}, not the whole line.
1194 Again, use context to figure out which of the meanings the speaker
1197 @node frequent operations
1198 @section The Three Most Frequently Used Operations
1200 Here are the three most frequently used operations (both short and long
1201 forms), as well as a brief description of their meanings. The rest of
1202 this chapter will cover how to use these operations in detail. We will
1203 present the rest of the operations in the next chapter.
1208 Create a new @command{tar} archive.
1211 List the contents of an archive.
1214 Extract one or more members from an archive.
1217 @node Two Frequent Options
1218 @section Two Frequently Used Options
1220 To understand how to run @command{tar} in the three operating modes listed
1221 previously, you also need to understand how to use two of the options to
1222 @command{tar}: @samp{--file} (which takes an archive file as an argument)
1223 and @samp{--verbose}. (You are usually not @emph{required} to specify
1224 either of these options when you run @command{tar}, but they can be very
1225 useful in making things more clear and helping you avoid errors.)
1229 * verbose tutorial::
1234 @unnumberedsubsec The @samp{--file} Option
1237 @item --file=@var{archive-name}
1238 @itemx -f @var{archive-name}
1239 Specify the name of an archive file.
1242 You can specify an argument for the @value{op-file} option whenever you
1243 use @command{tar}; this option determines the name of the archive file
1244 that @command{tar} will work on.
1246 If you don't specify this argument, then @command{tar} will use a
1247 default, usually some physical tape drive attached to your machine.
1248 If there is no tape drive attached, or the default is not meaningful,
1249 then @command{tar} will print an error message. The error message might
1250 look roughly like one of the following:
1253 tar: can't open /dev/rmt8 : No such device or address
1254 tar: can't open /dev/rsmt0 : I/O error
1258 To avoid confusion, we recommend that you always specify an archive file
1259 name by using @value{op-file} when writing your @command{tar} commands.
1260 For more information on using the @value{op-file} option, see
1263 @node verbose tutorial
1264 @unnumberedsubsec The @samp{--verbose} Option
1269 Show the files being worked on as @command{tar} is running.
1272 @value{op-verbose} shows details about the results of running
1273 @command{tar}. This can be especially useful when the results might not be
1274 obvious. For example, if you want to see the progress of @command{tar} as
1275 it writes files into the archive, you can use the @samp{--verbose}
1276 option. In the beginning, you may find it useful to use
1277 @samp{--verbose} at all times; when you are more accustomed to
1278 @command{tar}, you will likely want to use it at certain times but not at
1279 others. We will use @samp{--verbose} at times to help make something
1280 clear, and we will give many examples both using and not using
1281 @samp{--verbose} to show the differences.
1283 Sometimes, a single instance of @samp{--verbose} on the command line
1284 will show a full, @samp{ls} style listing of an archive or files,
1285 giving sizes, owners, and similar information. Other times,
1286 @samp{--verbose} will only show files or members that the particular
1287 operation is operating on at the time. In the latter case, you can
1288 use @samp{--verbose} twice in a command to get a listing such as that
1289 in the former case. For example, instead of saying
1292 @kbd{tar -cvf afiles.tar apple angst aspic}
1296 above, you might say
1299 @kbd{tar -cvvf afiles.tar apple angst aspic}
1303 This works equally well using short or long forms of options. Using
1304 long forms, you would simply write out the mnemonic form of the option
1308 $ @kbd{tar --create --verbose --verbose @dots{}}
1312 Note that you must double the hyphens properly each time.
1314 Later in the tutorial, we will give examples using @w{@samp{--verbose
1318 @unnumberedsubsec Getting Help: Using the @code{--help} Option
1323 The @samp{--help} option to @command{tar} prints out a very brief list of
1324 all operations and option available for the current version of
1325 @command{tar} available on your system.
1329 @section How to Create Archives
1332 One of the basic operations of @command{tar} is @value{op-create}, which
1333 you use to create a @command{tar} archive. We will explain
1334 @samp{--create} first because, in order to learn about the other
1335 operations, you will find it useful to have an archive available to
1338 To make this easier, in this section you will first create a directory
1339 containing three files. Then, we will show you how to create an
1340 @emph{archive} (inside the new directory). Both the directory, and
1341 the archive are specifically for you to practice on. The rest of this
1342 chapter and the next chapter will show many examples using this
1343 directory and the files you will create: some of those files may be
1344 other directories and other archives.
1346 The three files you will archive in this example are called
1347 @file{blues}, @file{folk}, and @file{jazz}. The archive is called
1348 @file{collection.tar}.
1350 This section will proceed slowly, detailing how to use @samp{--create}
1351 in @code{verbose} mode, and showing examples using both short and long
1352 forms. In the rest of the tutorial, and in the examples in the next
1353 chapter, we will proceed at a slightly quicker pace. This section
1354 moves more slowly to allow beginning users to understand how
1355 @command{tar} works.
1358 * prepare for examples::
1359 * Creating the archive::
1365 @node prepare for examples
1366 @subsection Preparing a Practice Directory for Examples
1368 To follow along with this and future examples, create a new directory
1369 called @file{practice} containing files called @file{blues}, @file{folk}
1370 and @file{jazz}. The files can contain any information you like:
1371 ideally, they should contain information which relates to their names,
1372 and be of different lengths. Our examples assume that @file{practice}
1373 is a subdirectory of your home directory.
1375 Now @command{cd} to the directory named @file{practice}; @file{practice}
1376 is now your @dfn{working directory}. (@emph{Please note}: Although
1377 the full path name of this directory is
1378 @file{/@var{homedir}/practice}, in our examples we will refer to
1379 this directory as @file{practice}; the @var{homedir} is presumed.
1381 In general, you should check that the files to be archived exist where
1382 you think they do (in the working directory) by running @command{ls}.
1383 Because you just created the directory and the files and have changed to
1384 that directory, you probably don't need to do that this time.
1386 It is very important to make sure there isn't already a file in the
1387 working directory with the archive name you intend to use (in this case,
1388 @samp{collection.tar}), or that you don't care about its contents.
1389 Whenever you use @samp{create}, @command{tar} will erase the current
1390 contents of the file named by @value{op-file} if it exists. @command{tar}
1391 will not tell you if you are about to overwrite an archive unless you
1392 specify an option which does this. @FIXME{xref to the node for
1393 --backup!}To add files to an existing archive, you need to use a
1394 different option, such as @value{op-append}; see @ref{append} for
1395 information on how to do this.
1397 @node Creating the archive
1398 @subsection Creating the Archive
1400 To place the files @file{blues}, @file{folk}, and @file{jazz} into an
1401 archive named @file{collection.tar}, use the following command:
1404 $ @kbd{tar --create --file=collection.tar blues folk jazz}
1407 The order of the arguments is not very important, @emph{when using long
1408 option forms}. You could also say:
1411 $ @kbd{tar blues --create folk --file=collection.tar jazz}
1415 However, you can see that this order is harder to understand; this is
1416 why we will list the arguments in the order that makes the commands
1417 easiest to understand (and we encourage you to do the same when you use
1418 @command{tar}, to avoid errors).
1420 Note that the part of the command which says,
1421 @w{@kbd{--file=collection.tar}} is considered to be @emph{one} argument.
1422 If you substituted any other string of characters for
1423 @kbd{collection.tar}, then that string would become the name of the
1424 archive file you create.
1426 The order of the options becomes more important when you begin to use
1427 short forms. With short forms, if you type commands in the wrong order
1428 (even if you type them correctly in all other ways), you may end up with
1429 results you don't expect. For this reason, it is a good idea to get
1430 into the habit of typing options in the order that makes inherent sense.
1431 @xref{short create}, for more information on this.
1433 In this example, you type the command as shown above: @samp{--create}
1434 is the operation which creates the new archive
1435 (@file{collection.tar}), and @samp{--file} is the option which lets
1436 you give it the name you chose. The files, @file{blues}, @file{folk},
1437 and @file{jazz}, are now members of the archive, @file{collection.tar}
1438 (they are @dfn{file name arguments} to the @samp{--create} operation).
1439 @FIXME{xref here to the discussion of file name args?}Now that they are
1440 in the archive, they are called @emph{archive members}, not files.
1441 @FIXME{xref to definitions?}
1443 When you create an archive, you @emph{must} specify which files you want
1444 placed in the archive. If you do not specify any archive members, @sc{gnu}
1445 @command{tar} will complain.
1447 If you now list the contents of the working directory (@kbd{ls}), you will
1448 find the archive file listed as well as the files you saw previously:
1451 blues folk jazz collection.tar
1455 Creating the archive @samp{collection.tar} did not destroy the copies of
1456 the files in the directory.
1458 Keep in mind that if you don't indicate an operation, @command{tar} will not
1459 run and will prompt you for one. If you don't name any files, @command{tar}
1460 will complain. You must have write access to the working directory,
1461 or else you will not be able to create an archive in that directory.
1463 @emph{Caution}: Do not attempt to use @value{op-create} to add files to
1464 an existing archive; it will delete the archive and write a new one.
1465 Use @value{op-append} instead. @xref{append}.
1467 @node create verbose
1468 @subsection Running @samp{--create} with @samp{--verbose}
1470 If you include the @value{op-verbose} option on the command line,
1471 @command{tar} will list the files it is acting on as it is working. In
1472 verbose mode, the @code{create} example above would appear as:
1475 $ @kbd{tar --create --verbose --file=collection.tar blues folk jazz}
1481 This example is just like the example we showed which did not use
1482 @samp{--verbose}, except that @command{tar} generated the remaining lines
1484 (note the different font styles).
1490 In the rest of the examples in this chapter, we will frequently use
1491 @code{verbose} mode so we can show actions or @command{tar} responses that
1492 you would otherwise not see, and which are important for you to
1496 @subsection Short Forms with @samp{create}
1498 As we said before, the @value{op-create} operation is one of the most
1499 basic uses of @command{tar}, and you will use it countless times.
1500 Eventually, you will probably want to use abbreviated (or ``short'')
1501 forms of options. A full discussion of the three different forms that
1502 options can take appears in @ref{Styles}; for now, here is what the
1503 previous example (including the @value{op-verbose} option) looks like
1504 using short option forms:
1507 $ @kbd{tar -cvf collection.tar blues folk jazz}
1514 As you can see, the system responds the same no matter whether you use
1515 long or short option forms.
1517 @FIXME{i don't like how this is worded:} One difference between using
1518 short and long option forms is that, although the exact placement of
1519 arguments following options is no more specific when using short forms,
1520 it is easier to become confused and make a mistake when using short
1521 forms. For example, suppose you attempted the above example in the
1525 $ @kbd{tar -cfv collection.tar blues folk jazz}
1529 In this case, @command{tar} will make an archive file called @file{v},
1530 containing the files @file{blues}, @file{folk}, and @file{jazz}, because
1531 the @samp{v} is the closest ``file name'' to the @samp{-f} option, and
1532 is thus taken to be the chosen archive file name. @command{tar} will try
1533 to add a file called @file{collection.tar} to the @file{v} archive file;
1534 if the file @file{collection.tar} did not already exist, @command{tar} will
1535 report an error indicating that this file does not exist. If the file
1536 @file{collection.tar} does already exist (e.g., from a previous command
1537 you may have run), then @command{tar} will add this file to the archive.
1538 Because the @samp{-v} option did not get registered, @command{tar} will not
1539 run under @samp{verbose} mode, and will not report its progress.
1541 The end result is that you may be quite confused about what happened,
1542 and possibly overwrite a file. To illustrate this further, we will show
1543 you how an example we showed previously would look using short forms.
1548 $ @kbd{tar blues --create folk --file=collection.tar jazz}
1552 is confusing as it is. When shown using short forms, however, it
1553 becomes much more so:
1556 $ @kbd{tar blues -c folk -f collection.tar jazz}
1560 It would be very easy to put the wrong string of characters
1561 immediately following the @samp{-f}, but doing that could sacrifice
1564 For this reason, we recommend that you pay very careful attention to
1565 the order of options and placement of file and archive names,
1566 especially when using short option forms. Not having the option name
1567 written out mnemonically can affect how well you remember which option
1568 does what, and therefore where different names have to be placed.
1569 (Placing options in an unusual order can also cause @command{tar} to
1570 report an error if you have set the shell environment variable
1571 @env{POSIXLY_CORRECT}; @pxref{posix compliance} for more information
1575 @subsection Archiving Directories
1577 @cindex Archiving Directories
1578 @cindex Directories, Archiving
1579 You can archive a directory by specifying its directory name as a
1580 file name argument to @command{tar}. The files in the directory will be
1581 archived relative to the working directory, and the directory will be
1582 re-created along with its contents when the archive is extracted.
1584 To archive a directory, first move to its superior directory. If you
1585 have followed the previous instructions in this tutorial, you should
1594 This will put you into the directory which contains @file{practice},
1595 i.e. your home directory. Once in the superior directory, you can
1596 specify the subdirectory, @file{practice}, as a file name argument. To
1597 store @file{practice} in the new archive file @file{music.tar}, type:
1600 $ @kbd{tar --create --verbose --file=music.tar practice}
1604 @command{tar} should output:
1611 practice/collection.tar
1614 Note that the archive thus created is not in the subdirectory
1615 @file{practice}, but rather in the current working directory---the
1616 directory from which @command{tar} was invoked. Before trying to archive a
1617 directory from its superior directory, you should make sure you have
1618 write access to the superior directory itself, not only the directory
1619 you are trying archive with @command{tar}. For example, you will probably
1620 not be able to store your home directory in an archive by invoking
1621 @command{tar} from the root directory; @value{xref-absolute-names}. (Note
1622 also that @file{collection.tar}, the original archive file, has itself
1623 been archived. @command{tar} will accept any file as a file to be
1624 archived, regardless of its content. When @file{music.tar} is
1625 extracted, the archive file @file{collection.tar} will be re-written
1626 into the file system).
1628 If you give @command{tar} a command such as
1631 $ @kbd{tar --create --file=foo.tar .}
1635 @command{tar} will report @samp{tar: ./foo.tar is the archive; not dumped}.
1636 This happens because @command{tar} creates the archive @file{foo.tar} in
1637 the current directory before putting any files into it. Then, when
1638 @command{tar} attempts to add all the files in the directory @file{.} to
1639 the archive, it notices that the file @file{./foo.tar} is the same as the
1640 archive @file{foo.tar}, and skips it. (It makes no sense to put an archive
1641 into itself.) @sc{gnu} @command{tar} will continue in this case, and create the
1642 archive normally, except for the exclusion of that one file.
1643 (@emph{Please note:} Other versions of @command{tar} are not so clever;
1644 they will enter an infinite loop when this happens, so you should not
1645 depend on this behavior unless you are certain you are running @sc{gnu}
1646 @command{tar}.) @FIXME{bob doesn't like this sentence, since he does it
1647 all the time, and we've been doing it in the editing passes for this
1648 manual: In general, make sure that the archive is not inside a
1649 directory being dumped.}
1652 @section How to List Archives
1654 Frequently, you will find yourself wanting to determine exactly what a
1655 particular archive contains. You can use the @value{op-list} operation
1656 to get the member names as they currently appear in the archive, as well
1657 as various attributes of the files at the time they were archived. For
1658 example, you can examine the archive @file{collection.tar} that you
1659 created in the last section with the command,
1662 $ @kbd{tar --list --file=collection.tar}
1666 The output of @command{tar} would then be:
1674 @FIXME{we hope this will change. if it doesn't, need to show the
1675 creation of bfiles somewhere above!!! : }
1678 The archive @file{bfiles.tar} would list as follows:
1687 Be sure to use a @value{op-file} option just as with @value{op-create}
1688 to specify the name of the archive.
1690 If you use the @value{op-verbose} option with @samp{--list}, then
1691 @command{tar} will print out a listing reminiscent of @w{@samp{ls -l}},
1692 showing owner, file size, and so forth.
1694 If you had used @value{op-verbose} mode, the example above would look
1698 $ @kbd{tar --list --verbose --file=collection.tar folk}
1699 -rw-rw-rw- myself user 62 1990-05-23 10:55 folk
1702 @cindex File name arguments, using @code{--list} with
1703 @cindex @code{--list} with file name arguments
1704 You can specify one or more individual member names as arguments when
1705 using @samp{list}. In this case, @command{tar} will only list the
1706 names of members you identify. For example, @w{@kbd{tar --list
1707 --file=afiles.tar apple}} would only print @file{apple}.
1709 @FIXME{we hope the relevant aspects of this will change:}Because
1710 @command{tar} preserves paths, file names must be specified as they appear
1711 in the archive (ie., relative to the directory from which the archive
1712 was created). Therefore, it is essential when specifying member names
1713 to @command{tar} that you give the exact member names. For example,
1714 @w{@kbd{tar --list --file=bfiles birds}} would produce an error message
1715 something like @samp{tar: birds: Not found in archive}, because there is
1716 no member named @file{birds}, only one named @file{./birds}. While the
1717 names @file{birds} and @file{./birds} name the same file, @emph{member}
1718 names are compared using a simplistic name comparison, in which an exact
1719 match is necessary. @xref{absolute}.
1721 However, @w{@kbd{tar --list --file=collection.tar folk}} would respond
1722 with @file{folk}, because @file{folk} is in the archive file
1723 @file{collection.tar}. If you are not sure of the exact file name, try
1724 listing all the files in the archive and searching for the one you
1725 expect to find; remember that if you use @samp{--list} with no file
1726 names as arguments, @command{tar} will print the names of all the members
1727 stored in the specified archive.
1734 @unnumberedsubsec Listing the Contents of a Stored Directory
1737 @FIXME{i changed the order of these nodes around and haven't had a
1738 chance to play around with this node's example, yet. i have to play
1739 with it and see what it actually does for my own satisfaction, even if
1740 what it says *is* correct..}
1742 To get information about the contents of an archived directory,
1743 use the directory name as a file name argument in conjunction with
1744 @value{op-list}. To find out file attributes, include the
1745 @value{op-verbose} option.
1747 For example, to find out about files in the directory @file{practice}, in
1748 the archive file @file{music.tar}, type:
1751 $ @kbd{tar --list --verbose --file=music.tar practice}
1754 @command{tar} responds:
1757 drwxrwxrwx myself user 0 1990-05-31 21:49 practice/
1758 -rw-rw-rw- myself user 42 1990-05-21 13:29 practice/blues
1759 -rw-rw-rw- myself user 62 1990-05-23 10:55 practice/folk
1760 -rw-rw-rw- myself user 40 1990-05-21 13:30 practice/jazz
1761 -rw-rw-rw- myself user 10240 1990-05-31 21:49 practice/collection.tar
1764 When you use a directory name as a file name argument, @command{tar} acts on
1765 all the files (including sub-directories) in that directory.
1768 @section How to Extract Members from an Archive
1771 @cindex Retrieving files from an archive
1772 @cindex Resurrecting files from an archive
1774 Creating an archive is only half the job---there is no point in storing
1775 files in an archive if you can't retrieve them. The act of retrieving
1776 members from an archive so they can be used and manipulated as
1777 unarchived files again is called @dfn{extraction}. To extract files
1778 from an archive, use the @value{op-extract} operation. As with
1779 @value{op-create}, specify the name of the archive with @value{op-file}.
1780 Extracting an archive does not modify the archive in any way; you can
1781 extract it multiple times if you want or need to.
1783 Using @samp{--extract}, you can extract an entire archive, or specific
1784 files. The files can be directories containing other files, or not. As
1785 with @value{op-create} and @value{op-list}, you may use the short or the
1786 long form of the operation without affecting the performance.
1789 * extracting archives::
1790 * extracting files::
1792 * failing commands::
1795 @node extracting archives
1796 @subsection Extracting an Entire Archive
1798 To extract an entire archive, specify the archive file name only, with
1799 no individual file names as arguments. For example,
1802 $ @kbd{tar -xvf collection.tar}
1809 -rw-rw-rw- me user 28 1996-10-18 16:31 jazz
1810 -rw-rw-rw- me user 21 1996-09-23 16:44 blues
1811 -rw-rw-rw- me user 20 1996-09-23 16:44 folk
1814 @node extracting files
1815 @subsection Extracting Specific Files
1817 To extract specific archive members, give their exact member names as
1818 arguments, as printed by @value{op-list}. If you had mistakenly deleted
1819 one of the files you had placed in the archive @file{collection.tar}
1820 earlier (say, @file{blues}), you can extract it from the archive without
1821 changing the archive's structure. It will be identical to the original
1822 file @file{blues} that you deleted. @FIXME{check this; will the times,
1823 permissions, owner, etc be the same, also?}
1825 First, make sure you are in the @file{practice} directory, and list the
1826 files in the directory. Now, delete the file, @samp{blues}, and list
1827 the files in the directory again.
1829 You can now extract the member @file{blues} from the archive file
1830 @file{collection.tar} like this:
1833 $ @kbd{tar --extract --file=collection.tar blues}
1837 If you list the files in the directory again, you will see that the file
1838 @file{blues} has been restored, with its original permissions, creation
1839 times, and owner.@FIXME{This is only accidentally true, but not in
1840 general. In most cases, one has to be root for restoring the owner, and
1841 use a special option for restoring permissions. Here, it just happens
1842 that the restoring user is also the owner of the archived members, and
1843 that the current @code{umask} is compatible with original permissions.}
1844 (These parameters will be identical to those which
1845 the file had when you originally placed it in the archive; any changes
1846 you may have made before deleting the file from the file system,
1847 however, will @emph{not} have been made to the archive member.) The
1848 archive file, @samp{collection.tar}, is the same as it was before you
1849 extracted @samp{blues}. You can confirm this by running @command{tar} with
1852 @FIXME{we hope this will change:}Remember that as with other operations,
1853 specifying the exact member name is important. @w{@kbd{tar --extract
1854 --file=bfiles.tar birds}} will fail, because there is no member named
1855 @file{birds}. To extract the member named @file{./birds}, you must
1856 specify @w{@kbd{tar --extract --file=bfiles.tar ./birds}}. To find the
1857 exact member names of the members of an archive, use @value{op-list}
1860 If you give the @value{op-verbose} option, then @value{op-extract} will
1861 print the names of the archive members as it extracts them.
1864 @subsection Extracting Files that are Directories
1866 Extracting directories which are members of an archive is similar to
1867 extracting other files. The main difference to be aware of is that if
1868 the extracted directory has the same name as any directory already in
1869 the working directory, then files in the extracted directory will be
1870 placed into the directory of the same name. Likewise, if there are
1871 files in the pre-existing directory with the same names as the members
1872 which you extract, the files from the extracted archive will replace
1873 the files already in the working directory (and possible
1874 subdirectories). This will happen regardless of whether or not the
1875 files in the working directory were more recent than those extracted.
1877 However, if a file was stored with a directory name as part of its file
1878 name, and that directory does not exist under the working directory when
1879 the file is extracted, @command{tar} will create the directory.
1881 We can demonstrate how to use @samp{--extract} to extract a directory
1882 file with an example. Change to the @file{practice} directory if you
1883 weren't there, and remove the files @file{folk} and @file{jazz}. Then,
1884 go back to the parent directory and extract the archive
1885 @file{music.tar}. You may either extract the entire archive, or you may
1886 extract only the files you just deleted. To extract the entire archive,
1887 don't give any file names as arguments after the archive name
1888 @file{music.tar}. To extract only the files you deleted, use the
1892 $ @kbd{tar -xvf music.tar practice/folk practice/jazz}
1895 @FIXME{need to show tar's response; used verbose above. also, here's a
1896 good place to demonstrate the -v -v thing. have to write that up
1897 (should be trivial, but i'm too tired!).}
1900 Because you created the directory with @file{practice} as part of the
1901 file names of each of the files by archiving the @file{practice}
1902 directory as @file{practice}, you must give @file{practice} as part
1903 of the file names when you extract those files from the archive.
1905 @FIXME{IMPORTANT! show the final structure, here. figure out what it
1908 @node failing commands
1909 @subsection Commands That Will Fail
1911 Here are some sample commands you might try which will not work, and why
1914 If you try to use this command,
1917 $ @kbd{tar -xvf music.tar folk jazz}
1921 you will get the following response:
1924 tar: folk: Not found in archive
1925 tar: jazz: Not found in archive
1930 This is because these files were not originally @emph{in} the parent
1931 directory @file{..}, where the archive is located; they were in the
1932 @file{practice} directory, and their file names reflect this:
1935 $ @kbd{tar -tvf music.tar}
1941 @FIXME{make sure the above works when going through the examples in
1945 Likewise, if you try to use this command,
1948 $ @kbd{tar -tvf music.tar folk jazz}
1952 you would get a similar response. Members with those names are not in the
1953 archive. You must use the correct member names in order to extract the
1954 files from the archive.
1956 If you have forgotten the correct names of the files in the archive,
1957 use @w{@kbd{tar --list --verbose}} to list them correctly.
1959 @FIXME{more examples, here? hag thinks it's a good idea.}
1962 @section Going Further Ahead in this Manual
1964 @FIXME{need to write up a node here about the things that are going to
1965 be in the rest of the manual.}
1967 @node tar invocation
1968 @chapter Invoking @sc{gnu} @command{tar}
1971 This chapter is about how one invokes the @sc{gnu} @command{tar} command, from
1972 the command synopsis (@pxref{Synopsis}). There are numerous options,
1973 and many styles for writing them. One mandatory option specifies
1974 the operation @command{tar} should perform (@pxref{Operation Summary}),
1975 other options are meant to detail how this operation should be performed
1976 (@pxref{Option Summary}). Non-option arguments are not always interpreted
1977 the same way, depending on what the operation is.
1979 You will find in this chapter everything about option styles and rules for
1980 writing them (@pxref{Styles}). On the other hand, operations and options
1981 are fully described elsewhere, in other chapters. Here, you will find
1982 only synthetic descriptions for operations and options, together with
1983 pointers to other parts of the @command{tar} manual.
1985 Some options are so special they are fully described right in this
1986 chapter. They have the effect of inhibiting the normal operation of
1987 @command{tar} or else, they globally alter the amount of feedback the user
1988 receives about what is going on. These are the @value{op-help} and
1989 @value{op-version} (@pxref{help}), @value{op-verbose} (@pxref{verbose})
1990 and @value{op-interactive} options (@pxref{interactive}).
1994 * using tar options::
2003 @section General Synopsis of @command{tar}
2005 The @sc{gnu} @command{tar} program is invoked as either one of:
2008 @kbd{tar @var{option}@dots{} [@var{name}]@dots{}}
2009 @kbd{tar @var{letter}@dots{} [@var{argument}]@dots{} [@var{option}]@dots{} [@var{name}]@dots{}}
2012 The second form is for when old options are being used.
2014 You can use @command{tar} to store files in an archive, to extract them from
2015 an archive, and to do other types of archive manipulation. The primary
2016 argument to @command{tar}, which is called the @dfn{operation}, specifies
2017 which action to take. The other arguments to @command{tar} are either
2018 @dfn{options}, which change the way @command{tar} performs an operation,
2019 or file names or archive members, which specify the files or members
2020 @command{tar} is to act on.
2022 You can actually type in arguments in any order, even if in this manual
2023 the options always precede the other arguments, to make examples easier
2024 to understand. Further, the option stating the main operation mode
2025 (the @command{tar} main command) is usually given first.
2027 Each @var{name} in the synopsis above is interpreted as an archive member
2028 name when the main command is one of @value{op-compare}, @value{op-delete},
2029 @value{op-extract}, @value{op-list} or @value{op-update}. When naming
2030 archive members, you must give the exact name of the member in the
2031 archive, as it is printed by @value{op-list}. For @value{op-append}
2032 and @value{op-create}, these @var{name} arguments specify the names
2033 of either files or directory hierarchies to place in the archive.
2034 These files or hierarchies should already exist in the file system,
2035 prior to the execution of the @command{tar} command.
2037 @command{tar} interprets relative file names as being relative to the
2038 working directory. @command{tar} will make all file names relative
2039 (by removing leading slashes when archiving or restoring files),
2040 unless you specify otherwise (using the @value{op-absolute-names}
2041 option). @value{xref-absolute-names}, for more information about
2042 @value{op-absolute-names}.
2044 If you give the name of a directory as either a file name or a member
2045 name, then @command{tar} acts recursively on all the files and directories
2046 beneath that directory. For example, the name @file{/} identifies all
2047 the files in the filesystem to @command{tar}.
2049 The distinction between file names and archive member names is especially
2050 important when shell globbing is used, and sometimes a source of confusion
2051 for newcomers. @xref{Wildcards}, for more information about globbing.
2052 The problem is that shells may only glob using existing files in the
2053 file system. Only @command{tar} itself may glob on archive members, so when
2054 needed, you must ensure that wildcard characters reach @command{tar} without
2055 being interpreted by the shell first. Using a backslash before @samp{*}
2056 or @samp{?}, or putting the whole argument between quotes, is usually
2057 sufficient for this.
2059 Even if @var{name}s are often specified on the command line, they
2060 can also be read from a text file in the file system, using the
2061 @value{op-files-from} option.
2063 If you don't use any file name arguments, @value{op-append},
2064 @value{op-delete} and @value{op-concatenate} will do nothing, while
2065 @value{op-create} will usually yield a diagnostic and inhibit @command{tar}
2066 execution. The other operations of @command{tar} (@value{op-list},
2067 @value{op-extract}, @value{op-compare}, and @value{op-update}) will act
2068 on the entire contents of the archive.
2071 @cindex return status
2072 Besides successful exits, @sc{gnu} @command{tar} may fail for many reasons.
2073 Some reasons correspond to bad usage, that is, when the @command{tar}
2074 command is improperly written.
2075 Errors may be encountered later, while encountering an error
2076 processing the archive or the files. Some errors are recoverable,
2077 in which case the failure is delayed until @command{tar} has completed
2078 all its work. Some errors are such that it would not meaningful,
2079 or at least risky, to continue processing: @command{tar} then aborts
2080 processing immediately. All abnormal exits, whether immediate or
2081 delayed, should always be clearly diagnosed on @code{stderr}, after
2082 a line stating the nature of the error.
2084 @sc{gnu} @command{tar} returns only a few exit statuses. I'm really
2085 aiming simplicity in that area, for now. If you are not using the
2086 @value{op-compare} option, zero means that everything went well, besides
2087 maybe innocuous warnings. Nonzero means that something went wrong.
2088 Right now, as of today, ``nonzero'' is almost always 2, except for
2089 remote operations, where it may be 128.
2091 @node using tar options
2092 @section Using @command{tar} Options
2094 @sc{gnu} @command{tar} has a total of eight operating modes which allow you to
2095 perform a variety of tasks. You are required to choose one operating
2096 mode each time you employ the @command{tar} program by specifying one, and
2097 only one operation as an argument to the @command{tar} command (two lists
2098 of four operations each may be found at @ref{frequent operations} and
2099 @ref{Operations}). Depending on circumstances, you may also wish to
2100 customize how the chosen operating mode behaves. For example, you may
2101 wish to change the way the output looks, or the format of the files that
2102 you wish to archive may require you to do something special in order to
2103 make the archive look right.
2105 You can customize and control @command{tar}'s performance by running
2106 @command{tar} with one or more options (such as @value{op-verbose}, which
2107 we used in the tutorial). As we said in the tutorial, @dfn{options} are
2108 arguments to @command{tar} which are (as their name suggests) optional.
2109 Depending on the operating mode, you may specify one or more options.
2110 Different options will have different effects, but in general they all
2111 change details of the operation, such as archive format, archive name,
2112 or level of user interaction. Some options make sense with all
2113 operating modes, while others are meaningful only with particular modes.
2114 You will likely use some options frequently, while you will only use
2115 others infrequently, or not at all. (A full list of options is
2116 available in @pxref{All Options}.)
2118 The @env{TAR_OPTIONS} environment variable specifies default options to
2119 be placed in front of any explicit options. For example, if
2120 @code{TAR_OPTIONS} is @samp{-v --unlink-first}, @command{tar} behaves as
2121 if the two options @option{-v} and @option{--unlink-first} had been
2122 specified before any explicit options. Option specifications are
2123 separated by whitespace. A backslash escapes the next character, so it
2124 can be used to specify an option containing whitespace or a backslash.
2126 Note that @command{tar} options are case sensitive. For example, the
2127 options @samp{-T} and @samp{-t} are different; the first requires an
2128 argument for stating the name of a file providing a list of @var{name}s,
2129 while the second does not require an argument and is another way to
2130 write @value{op-list}.
2132 In addition to the eight operations, there are many options to
2133 @command{tar}, and three different styles for writing both: long (mnemonic)
2134 form, short form, and old style. These styles are discussed below.
2135 Both the options and the operations can be written in any of these three
2138 @FIXME{menu at end of this node. need to think of an actual outline
2139 for this chapter; probably do that after stuff from chap. 4 is
2143 @section The Three Option Styles
2145 There are three styles for writing operations and options to the command
2146 line invoking @command{tar}. The different styles were developed at
2147 different times during the history of @command{tar}. These styles will be
2148 presented below, from the most recent to the oldest.
2150 Some options must take an argument. (For example, @value{op-file} takes
2151 the name of an archive file as an argument. If you do not supply an
2152 archive file name, @command{tar} will use a default, but this can be
2153 confusing; thus, we recommend that you always supply a specific archive
2154 file name.) Where you @emph{place} the arguments generally depends on
2155 which style of options you choose. We will detail specific information
2156 relevant to each option style in the sections on the different option
2157 styles, below. The differences are subtle, yet can often be very
2158 important; incorrect option placement can cause you to overwrite a
2159 number of important files. We urge you to note these differences, and
2160 only use the option style(s) which makes the most sense to you until you
2161 feel comfortable with the others.
2163 @FIXME{hag to write a brief paragraph on the option(s) which can
2164 optionally take an argument}
2167 * Mnemonic Options:: Mnemonic Option Style
2168 * Short Options:: Short Option Style
2169 * Old Options:: Old Option Style
2170 * Mixing:: Mixing Option Styles
2173 @node Mnemonic Options
2174 @subsection Mnemonic Option Style
2176 @FIXME{have to decide whether or ot to replace other occurrences of
2177 "mnemonic" with "long", or *ugh* vice versa.}
2179 Each option has at least one long (or mnemonic) name starting with two
2180 dashes in a row, e.g.@: @samp{--list}. The long names are more clear than
2181 their corresponding short or old names. It sometimes happens that a
2182 single mnemonic option has many different different names which are
2183 synonymous, such as @samp{--compare} and @samp{--diff}. In addition,
2184 long option names can be given unique abbreviations. For example,
2185 @samp{--cre} can be used in place of @samp{--create} because there is no
2186 other mnemonic option which begins with @samp{cre}. (One way to find
2187 this out is by trying it and seeing what happens; if a particular
2188 abbreviation could represent more than one option, @command{tar} will tell
2189 you that that abbreviation is ambiguous and you'll know that that
2190 abbreviation won't work. You may also choose to run @samp{tar --help}
2191 to see a list of options. Be aware that if you run @command{tar} with a
2192 unique abbreviation for the long name of an option you didn't want to
2193 use, you are stuck; @command{tar} will perform the command as ordered.)
2195 Mnemonic options are meant to be obvious and easy to remember, and their
2196 meanings are generally easier to discern than those of their
2197 corresponding short options (see below). For example:
2200 $ @kbd{tar --create --verbose --blocking-factor=20 --file=/dev/rmt0}
2204 gives a fairly good set of hints about what the command does, even
2205 for those not fully acquainted with @command{tar}.
2207 Mnemonic options which require arguments take those arguments
2208 immediately following the option name; they are introduced by an equal
2209 sign. For example, the @samp{--file} option (which tells the name
2210 of the @command{tar} archive) is given a file such as @file{archive.tar}
2211 as argument by using the notation @samp{--file=archive.tar} for the
2215 @subsection Short Option Style
2217 Most options also have a short option name. Short options start with
2218 a single dash, and are followed by a single character, e.g.@: @samp{-t}
2219 (which is equivalent to @samp{--list}). The forms are absolutely
2220 identical in function; they are interchangeable.
2222 The short option names are faster to type than long option names.
2224 Short options which require arguments take their arguments immediately
2225 following the option, usually separated by white space. It is also
2226 possible to stick the argument right after the short option name, using
2227 no intervening space. For example, you might write @w{@samp{-f
2228 archive.tar}} or @samp{-farchive.tar} instead of using
2229 @samp{--file=archive.tar}. Both @samp{--file=@var{archive-name}} and
2230 @w{@samp{-f @var{archive-name}}} denote the option which indicates a
2231 specific archive, here named @file{archive.tar}.
2233 Short options' letters may be clumped together, but you are not
2234 required to do this (as compared to old options; see below). When short
2235 options are clumped as a set, use one (single) dash for them all, e.g.@:
2236 @w{@samp{@command{tar} -cvf}}. Only the last option in such a set is allowed
2237 to have an argument@footnote{Clustering many options, the last of which
2238 has an argument, is a rather opaque way to write options. Some wonder if
2239 @sc{gnu} @code{getopt} should not even be made helpful enough for considering
2240 such usages as invalid.}.
2242 When the options are separated, the argument for each option which requires
2243 an argument directly follows that option, as is usual for Unix programs.
2247 $ @kbd{tar -c -v -b 20 -f /dev/rmt0}
2250 If you reorder short options' locations, be sure to move any arguments
2251 that belong to them. If you do not move the arguments properly, you may
2252 end up overwriting files.
2255 @subsection Old Option Style
2258 Like short options, old options are single letters. However, old options
2259 must be written together as a single clumped set, without spaces separating
2260 them or dashes preceding them@footnote{Beware that if you precede options
2261 with a dash, you are announcing the short option style instead of the
2262 old option style; short options are decoded differently.}. This set
2263 of letters must be the first to appear on the command line, after the
2264 @command{tar} program name and some white space; old options cannot appear
2265 anywhere else. The letter of an old option is exactly the same letter as
2266 the corresponding short option. For example, the old option @samp{t} is
2267 the same as the short option @samp{-t}, and consequently, the same as the
2268 mnemonic option @samp{--list}. So for example, the command @w{@samp{tar
2269 cv}} specifies the option @samp{-v} in addition to the operation @samp{-c}.
2271 @FIXME{bob suggests having an uglier example. :-) }
2273 When options that need arguments are given together with the command,
2274 all the associated arguments follow, in the same order as the options.
2275 Thus, the example given previously could also be written in the old
2279 $ @kbd{tar cvbf 20 /dev/rmt0}
2283 Here, @samp{20} is the argument of @samp{-b} and @samp{/dev/rmt0} is
2284 the argument of @samp{-f}.
2286 On the other hand, this old style syntax makes it difficult to match
2287 option letters with their corresponding arguments, and is often
2288 confusing. In the command @w{@samp{tar cvbf 20 /dev/rmt0}}, for example,
2289 @samp{20} is the argument for @samp{-b}, @samp{/dev/rmt0} is the
2290 argument for @samp{-f}, and @samp{-v} does not have a corresponding
2291 argument. Even using short options like in @w{@samp{tar -c -v -b 20 -f
2292 /dev/rmt0}} is clearer, putting all arguments next to the option they
2295 If you want to reorder the letters in the old option argument, be
2296 sure to reorder any corresponding argument appropriately.
2298 This old way of writing @command{tar} options can surprise even experienced
2299 users. For example, the two commands:
2302 @kbd{tar cfz archive.tar.gz file}
2303 @kbd{tar -cfz archive.tar.gz file}
2307 are quite different. The first example uses @file{archive.tar.gz} as
2308 the value for option @samp{f} and recognizes the option @samp{z}. The
2309 second example, however, uses @file{z} as the value for option
2310 @samp{f}---probably not what was intended.
2312 Old options are kept for compatibility with old versions of @command{tar}.
2314 This second example could be corrected in many ways, among which the
2315 following are equivalent:
2318 @kbd{tar -czf archive.tar.gz file}
2319 @kbd{tar -cf archive.tar.gz -z file}
2320 @kbd{tar cf archive.tar.gz -z file}
2323 @FIXME{still could explain this better; it's redundant:}
2325 @cindex option syntax, traditional
2326 As far as we know, all @command{tar} programs, @sc{gnu} and non-@sc{gnu}, support
2327 old options. @sc{gnu} @command{tar} supports them not only for historical
2328 reasons, but also because many people are used to them. For
2329 compatibility with Unix @command{tar}, the first argument is always
2330 treated as containing command and option letters even if it doesn't
2331 start with @samp{-}. Thus, @samp{tar c} is equivalent to @w{@samp{tar
2332 -c}:} both of them specify the @value{op-create} command to create an
2336 @subsection Mixing Option Styles
2338 All three styles may be intermixed in a single @command{tar} command, so
2339 long as the rules for each style are fully respected@footnote{Before @sc{gnu}
2340 @command{tar} version 1.11.6, a bug prevented intermixing old style options
2341 with mnemonic options in some cases.}. Old style options and either of the
2342 modern styles of options may be mixed within a single @command{tar} command.
2343 However, old style options must be introduced as the first arguments only,
2344 following the rule for old options (old options must appear directly
2345 after the @command{tar} command and some white space). Modern options may
2346 be given only after all arguments to the old options have been collected.
2347 If this rule is not respected, a modern option might be falsely interpreted
2348 as the value of the argument to one of the old style options.
2350 For example, all the following commands are wholly equivalent, and
2351 illustrate the many combinations and orderings of option styles.
2354 @kbd{tar --create --file=archive.tar}
2355 @kbd{tar --create -f archive.tar}
2356 @kbd{tar --create -farchive.tar}
2357 @kbd{tar --file=archive.tar --create}
2358 @kbd{tar --file=archive.tar -c}
2359 @kbd{tar -c --file=archive.tar}
2360 @kbd{tar -c -f archive.tar}
2361 @kbd{tar -c -farchive.tar}
2362 @kbd{tar -cf archive.tar}
2363 @kbd{tar -cfarchive.tar}
2364 @kbd{tar -f archive.tar --create}
2365 @kbd{tar -f archive.tar -c}
2366 @kbd{tar -farchive.tar --create}
2367 @kbd{tar -farchive.tar -c}
2368 @kbd{tar c --file=archive.tar}
2369 @kbd{tar c -f archive.tar}
2370 @kbd{tar c -farchive.tar}
2371 @kbd{tar cf archive.tar}
2372 @kbd{tar f archive.tar --create}
2373 @kbd{tar f archive.tar -c}
2374 @kbd{tar fc archive.tar}
2377 On the other hand, the following commands are @emph{not} equivalent to
2381 @kbd{tar -f -c archive.tar}
2382 @kbd{tar -fc archive.tar}
2383 @kbd{tar -fcarchive.tar}
2384 @kbd{tar -farchive.tarc}
2385 @kbd{tar cfarchive.tar}
2389 These last examples mean something completely different from what the
2390 user intended (judging based on the example in the previous set which
2391 uses long options, whose intent is therefore very clear). The first
2392 four specify that the @command{tar} archive would be a file named
2393 @samp{-c}, @samp{c}, @samp{carchive.tar} or @samp{archive.tarc},
2394 respectively. The first two examples also specify a single non-option,
2395 @var{name} argument having the value @samp{archive.tar}. The last
2396 example contains only old style option letters (repeating option
2397 @samp{c} twice), not all of which are meaningful (eg., @samp{.},
2398 @samp{h}, or @samp{i}), with no argument value. @FIXME{not sure i liked
2399 the first sentence of this paragraph..}
2402 @section All @command{tar} Options
2404 The coming manual sections contain an alphabetical listing of all
2405 @command{tar} operations and options, with brief descriptions and cross
2406 references to more in-depth explanations in the body of the manual.
2407 They also contain an alphabetically arranged table of the short option
2408 forms with their corresponding long option. You can use this table as
2409 a reference for deciphering @command{tar} commands in scripts.
2412 * Operation Summary::
2414 * Short Option Summary::
2417 @node Operation Summary
2418 @subsection Operations
2425 Appends files to the end of the archive. @xref{append}.
2430 Same as @samp{--concatenate}. @xref{concatenate}.
2435 Compares archive members with their counterparts in the file
2436 system, and reports differences in file size, mode, owner,
2437 modification date and contents. @xref{compare}.
2442 Appends other @command{tar} archives to the end of the archive.
2448 Creates a new @command{tar} archive. @xref{create}.
2452 Deletes members from the archive. Don't try this on a archive on a
2453 tape! @xref{delete}.
2458 Same @samp{--compare}. @xref{compare}.
2463 Extracts members from the archive into the file system. @xref{extract}.
2468 Same as @samp{--extract}. @xref{extract}.
2473 Lists the members in an archive. @xref{list}.
2478 @FIXME{It was: A combination of the @samp{--compare} and @samp{--append} operations.
2479 This is not true and rather misleading, as @value{op-compare}
2480 does a lot more than @value{op-update} for ensuring files are identical.}
2481 Adds files to the end of the archive, but only if they are newer than
2482 their counterparts already in the archive, or if they do not already
2483 exist in the archive.
2488 @node Option Summary
2489 @subsection @command{tar} Options
2493 @item --absolute-names
2496 Normally when creating an archive, @command{tar} strips an initial @samp{/} from
2497 member names. This option disables that behavior. @FIXME-xref{}
2501 (See @samp{--newer}.) @FIXME-pxref{}
2503 @item --atime-preserve
2505 Tells @command{tar} to preserve the access time field in a file's inode when
2506 reading it. Due to limitations in the @code{utimes} system call, the
2507 modification time field is also preserved, which may cause problems if
2508 the file is simultaneously being modified by another program.
2509 This option is incompatible with incremental backups, because
2510 preserving the access time involves updating the last-changed time.
2511 Also, this option does not work on files that you do not own,
2515 @item --backup=@var{backup-type}
2517 Rather than deleting files from the file system, @command{tar} will back them up
2518 using simple or numbered backups, depending upon @var{backup-type}.
2521 @item --block-number
2524 With this option present, @command{tar} prints error messages for read errors
2525 with the block number in the archive file. @FIXME-xref{}
2527 @item --blocking-factor=@var{blocking}
2528 @itemx -b @var{blocking}
2530 Sets the blocking factor @command{tar} uses to @var{blocking} x 512 bytes per
2531 record. @FIXME-xref{}
2536 This option tells @command{tar} to read or write archives through @code{bzip2}.
2541 This option directs @command{tar} to print periodic checkpoint messages as it
2542 reads through the archive. Its intended for when you want a visual
2543 indication that @command{tar} is still running, but don't want to see
2544 @samp{--verbose} output. @FIXME-xref{}
2550 @command{tar} will use the @command{compress} program when reading or writing the
2551 archive. This allows you to directly act on archives while saving
2552 space. @FIXME-xref{}
2554 @item --confirmation
2556 (See @samp{--interactive}.) @FIXME-pxref{}
2561 When creating a @command{tar} archive, @command{tar} will archive the file that a symbolic
2562 link points to, rather than archiving the symlink. @FIXME-xref{}
2564 @item --directory=@var{dir}
2567 When this option is specified, @command{tar} will change its current directory
2568 to @var{dir} before performing any operations. When this option is used
2569 during archive creation, it is order sensitive. @FIXME-xref{}
2571 @item --exclude=@var{pattern}
2573 When performing operations, @command{tar} will skip files that match
2574 @var{pattern}. @FIXME-xref{}
2576 @item --exclude-from=@var{file}
2577 @itemx -X @var{file}
2579 Similar to @samp{--exclude}, except @command{tar} will use the list of patterns
2580 in the file @var{file}. @FIXME-xref{}
2582 @item --file=@var{archive}
2583 @itemx -f @var{archive}
2585 @command{tar} will use the file @var{archive} as the @command{tar} archive it
2586 performs operations on, rather than @command{tar}'s compilation dependent
2587 default. @FIXME-xref{}
2589 @item --files-from=@var{file}
2590 @itemx -I @var{file}
2591 @itemx -T @var{file}
2593 @command{tar} will use the contents of @var{file} as a list of archive members
2594 or files to operate on, in addition to those specified on the
2595 command-line. @FIXME-xref{}
2599 Forces @command{tar} to interpret the filename given to @samp{--file} as a local
2600 file, even if it looks like a remote tape drive name. @FIXME-xref{}
2602 @item --group=@var{group}
2604 Files added to the @command{tar} archive will have a group id of @var{group},
2605 rather than the group from the source file. @var{group} is first decoded
2606 as a group symbolic name, but if this interpretation fails, it has to be
2607 a decimal numeric group ID. @FIXME-xref{}
2609 Also see the comments for the @value{op-owner} option.
2613 (See @samp{--gzip}.) @FIXME-pxref{}
2620 This option tells @command{tar} to read or write archives through @command{gzip},
2621 allowing @command{tar} to directly operate on several kinds of compressed
2622 archives transparently. @FIXME-xref{}
2626 @command{tar} will print out a short message summarizing the operations and
2627 options to @command{tar} and exit. @FIXME-xref{}
2629 @item --ignore-failed-read
2631 Do not exit unsuccessfully merely because an unreadable file was encountered.
2634 @item --ignore-zeros
2637 With this option, @command{tar} will ignore zeroed blocks in the archive, which
2638 normally signals EOF. @xref{Reading}.
2643 Used to inform @command{tar} that it is working with an old @sc{gnu}-format
2644 incremental backup archive. It is intended primarily for backwards
2645 compatibility only. @FIXME-xref{}
2647 @item --info-script=@var{script-file}
2648 @itemx --new-volume-script=@var{script-file}
2649 @itemx -F @var{script-file}
2651 When @command{tar} is performing multi-tape backups, @var{script-file} is run
2652 at the end of each tape. @FIXME-xref{}
2655 @itemx --confirmation
2658 Specifies that @command{tar} should ask the user for confirmation before
2659 performing potentially destructive options, such as overwriting files.
2662 @item --keep-old-files
2665 Do not overwrite existing files when extracting files from an archive.
2668 @item --label=@var{name}
2669 @itemx -V @var{name}
2671 When creating an archive, instructs @command{tar} to write @var{name} as a name
2672 record in the archive. When extracting or listing archives, @command{tar} will
2673 only operate on archives that have a label matching the pattern
2674 specified in @var{name}. @FIXME-xref{}
2676 @item --listed-incremental=@var{snapshot-file}
2677 @itemx -g @var{snapshot-file}
2679 During a @samp{--create} operation, specifies that the archive that
2680 @command{tar} creates is a new @sc{gnu}-format incremental backup, using
2681 @var{snapshot-file} to determine which files to backup.
2682 With other operations, informs @command{tar} that the archive is in incremental
2683 format. @FIXME-xref{}
2685 @item --mode=@var{permissions}
2687 When adding files to an archive, @command{tar} will use @var{permissions}
2688 for the archive members, rather than the permissions from the files.
2689 The program @command{chmod} and this @command{tar} option share the same syntax
2690 for what @var{permissions} might be. @xref{File permissions, Permissions,
2691 File permissions, fileutils, @sc{gnu} file utilities}. This reference also
2692 has useful information for those not being overly familiar with the Unix
2695 Of course, @var{permissions} might be plainly specified as an octal number.
2696 However, by using generic symbolic modifications to mode bits, this allows
2697 more flexibility. For example, the value @samp{a+rw} adds read and write
2698 permissions for everybody, while retaining executable bits on directories
2699 or on any other file already marked as executable.
2701 @item --multi-volume
2704 Informs @command{tar} that it should create or otherwise operate on a
2705 multi-volume @command{tar} archive. @FIXME-xref{}
2707 @item --new-volume-script
2711 @item --newer=@var{date}
2712 @itemx --after-date=@var{date}
2715 When creating an archive, @command{tar} will only add files that have changed
2716 since @var{date}. @FIXME-xref{}
2720 In conjunction with @samp{--newer}, @command{tar} will only add files whose
2721 contents have changed (as opposed to just @samp{--newer}, which will
2722 also back up files for which any status information has changed).
2724 @item --no-recursion
2726 With this option, @command{tar} will not recurse into directories.
2729 @item --no-same-owner
2731 When extracting an archive, do not attempt to preserve the owner
2732 specified in the @command{tar} archive. This the default behavior
2733 for ordinary users; this option has an effect only for the superuser.
2735 @item --no-same-permissions
2737 When extracting an archive, subtract the user's umask from files from
2738 the permissions specified in the archive. This is the default behavior
2739 for ordinary users; this option has an effect only for the superuser.
2743 When @command{tar} is using the @samp{--files-from} option, this option
2744 instructs @command{tar} to expect filenames terminated with @kbd{NUL}, so
2745 @command{tar} can correctly work with file names that contain newlines.
2748 @item --numeric-owner
2750 This option will notify @command{tar} that it should use numeric user and group
2751 IDs when creating a @command{tar} file, rather than names. @FIXME-xref{}
2755 (See @samp{--portability}.) @FIXME-pxref{}
2757 @item --one-file-system
2760 Used when creating an archive. Prevents @command{tar} from recursing into
2761 directories that are on different file systems from the current
2762 directory. @FIXME-xref{}
2766 Overwrite existing files and directory metadata when extracting files
2767 from an archive. @xref{Overwrite Old Files}.
2769 @item --owner=@var{user}
2771 Specifies that @command{tar} should use @var{user} as the owner of members
2772 when creating archives, instead of the user associated with the source
2773 file. @var{user} is first decoded as a user symbolic name, but if
2774 this interpretation fails, it has to be a decimal numeric user ID.
2777 There is no value indicating a missing number, and @samp{0} usually means
2778 @code{root}. Some people like to force @samp{0} as the value to offer in
2779 their distributions for the owner of files, because the @code{root} user is
2780 anonymous anyway, so that might as well be the owner of anonymous archives.
2782 This option does not affect extraction from archives.
2785 @itemx --old-archive
2788 Tells @command{tar} to create an archive that is compatible with Unix V7
2789 @command{tar}. @FIXME-xref{}
2793 Instructs @command{tar} to create a @sc{posix} compliant @command{tar} archive. @FIXME-xref{}
2797 Synonymous with specifying both @samp{--preserve-permissions} and
2798 @samp{--same-order}. @FIXME-xref{}
2800 @item --preserve-order
2802 (See @samp{--same-order}; @pxref{Reading}.)
2804 @item --preserve-permissions
2805 @itemx --same-permissions
2808 When @command{tar} is extracting an archive, it normally subtracts the users'
2809 umask from the permissions specified in the archive and uses that
2810 number as the permissions to create the destination file. Specifying
2811 this option instructs @command{tar} that it should use the permissions directly
2812 from the archive. @xref{Writing}.
2814 @item --read-full-records
2817 Specifies that @command{tar} should reblock its input, for reading from pipes on
2818 systems with buggy implementations. @xref{Reading}.
2820 @item --record-size=@var{size}
2822 Instructs @command{tar} to use @var{size} bytes per record when accessing the
2823 archive. @FIXME-xref{}
2825 @item --recursive-unlink
2828 directory hierarchies before extracting directories of the same name
2829 from the archive. @xref{Writing}.
2831 @item --remove-files
2833 Directs @command{tar} to remove the source file from the file system after
2834 appending it to an archive. @FIXME-xref{}
2836 @item --rsh-command=@var{cmd}
2838 Notifies @command{tar} that is should use @var{cmd} to communicate with remote
2839 devices. @FIXME-xref{}
2842 @itemx --preserve-order
2845 This option is an optimization for @command{tar} when running on machines with
2846 small amounts of memory. It informs @command{tar} that the list of file
2847 arguments has already been sorted to match the order of files in the
2848 archive. @xref{Reading}.
2852 When extracting an archive, @command{tar} will attempt to preserve the owner
2853 specified in the @command{tar} archive with this option present.
2854 This is the default behavior for the superuser; this option has an
2855 effect only for ordinary users. @FIXME-xref{}
2857 @item --same-permissions
2859 (See @samp{--preserve-permissions}; @pxref{Writing}.)
2861 @item --show-omitted-dirs
2863 Instructs @command{tar} to mention directories its skipping over when operating
2864 on a @command{tar} archive. @FIXME-xref{}
2869 Invokes a @sc{gnu} extension when adding files to an archive that handles
2870 sparse files efficiently. @FIXME-xref{}
2872 @item --starting-file=@var{name}
2873 @itemx -K @var{name}
2875 This option affects extraction only; @command{tar} will skip extracting
2876 files in the archive until it finds one that matches @var{name}.
2879 @item --suffix=@var{suffix}
2881 Alters the suffix @command{tar} uses when backing up files from the default
2882 @samp{~}. @FIXME-xref{}
2884 @item --tape-length=@var{num}
2887 Specifies the length of tapes that @command{tar} is writing as being
2888 @w{@var{num} x 1024} bytes long. @FIXME-xref{}
2893 During extraction, @command{tar} will extract files to stdout rather than to the
2894 file system. @xref{Writing}.
2898 Displays the total number of bytes written after creating an archive.
2904 Sets the modification time of extracted files to the extraction time,
2905 rather than the modification time stored in the archive.
2910 (See @samp{--compress}.) @FIXME-pxref{}
2914 (See @samp{--gzip}.) @FIXME-pxref{}
2916 @item --unlink-first
2919 Directs @command{tar} to remove the corresponding file from the file
2920 system before extracting it from the archive. @xref{Writing}.
2922 @item --use-compress-program=@var{prog}
2924 Instructs @command{tar} to access the archive through @var{prog}, which is
2925 presumed to be a compression program of some sort. @FIXME-xref{}
2930 Specifies that @command{tar} should be more verbose about the operations its
2931 performing. This option can be specified multiple times for some
2932 operations to increase the amount of information displayed. @FIXME-xref{}
2937 Verifies that the archive was correctly written when creating an
2938 archive. @FIXME-xref{}
2942 @command{tar} will print an informational message about what version it is and a
2943 copyright message, some credits, and then exit. @FIXME-xref{}
2945 @item --volno-file=@var{file}
2947 Used in conjunction with @samp{--multi-volume}. @command{tar} will keep track
2948 of which volume of a multi-volume archive its working in @var{file}.
2952 @node Short Option Summary
2953 @subsection Short Options Cross Reference
2955 Here is an alphabetized list of all of the short option forms, matching
2956 them with the equivalent long option.
2962 @samp{--concatenate}
2966 @samp{--read-full-records}
2974 @samp{--info-script}
2978 @samp{--incremental}
2986 @samp{--starting-file}
2990 @samp{--tape-length}
2994 @samp{--multi-volume}
3006 @samp{--absolute-names}
3010 @samp{--block-number}
3022 @samp{--unlink-first}
3034 @samp{--exclude-from}
3042 @samp{--blocking-factor}
3058 @samp{--listed-incremental}
3062 @samp{--dereference}
3066 @samp{--ignore-zeros}
3070 @samp{--keep-old-files}
3074 @samp{--one-file-system}
3082 @samp{--portability}
3086 @samp{--preserve-permissions}
3110 @samp{--interactive}
3123 @section @sc{gnu} @command{tar} documentation
3125 Being careful, the first thing is really checking that you are using @sc{gnu}
3126 @command{tar}, indeed. The @value{op-version} option will generate a message
3127 giving confirmation that you are using @sc{gnu} @command{tar}, with the precise
3128 version of @sc{gnu} @command{tar} you are using. @command{tar} identifies itself
3129 and prints the version number to the standard output, then immediately
3130 exits successfully, without doing anything else, ignoring all other
3131 options. For example, @w{@samp{tar --version}} might return:
3134 tar (@sc{gnu} tar) @value{VERSION}
3138 The first occurrence of @samp{tar} in the result above is the program
3139 name in the package (for example, @command{rmt} is another program), while
3140 the second occurrence of @samp{tar} is the name of the package itself,
3141 containing possibly many programs. The package is currently named
3142 @samp{tar}, after the name of the main program it contains@footnote{There
3143 are plans to merge the @command{cpio} and @command{tar} packages into a single one
3144 which would be called @code{paxutils}. So, who knows if, one of this days,
3145 the @value{op-version} would not yield @w{@samp{tar (@sc{gnu} paxutils) 3.2}}}.
3147 Another thing you might want to do is checking the spelling or meaning
3148 of some particular @command{tar} option, without resorting to this manual,
3149 for once you have carefully read it. @sc{gnu} @command{tar} has a short help
3150 feature, triggerable through the @value{op-help} option. By using this
3151 option, @command{tar} will print a usage message listing all available
3152 options on standard output, then exit successfully, without doing
3153 anything else and ignoring all other options. Even if this is only a
3154 brief summary, it may be several screens long. So, if you are not
3155 using some kind of scrollable window, you might prefer to use something
3159 $ @kbd{tar --help | less}
3163 presuming, here, that you like using @command{less} for a pager. Other
3164 popular pagers are @command{more} and @command{pg}. If you know about some
3165 @var{keyword} which interests you and do not want to read all the
3166 @value{op-help} output, another common idiom is doing:
3169 tar --help | grep @var{keyword}
3173 for getting only the pertinent lines.
3175 The perceptive reader would have noticed some contradiction in the
3176 previous paragraphs. It is written that both @value{op-version} and
3177 @value{op-help} print something, and have all other options ignored. In
3178 fact, they cannot ignore each other, and one of them has to win. We do
3179 not specify which is stronger, here; experiment if you really wonder!
3181 The short help output is quite succinct, and you might have to get back
3182 to the full documentation for precise points. If you are reading this
3183 paragraph, you already have the @command{tar} manual in some form. This
3184 manual is available in printed form, as a kind of small book. It may
3185 printed out of the @sc{gnu} @command{tar} distribution, provided you have @TeX{}
3186 already installed somewhere, and a laser printer around. Just configure
3187 the distribution, execute the command @w{@samp{make dvi}}, then print
3188 @file{doc/tar.dvi} the usual way (contact your local guru to know how).
3189 If @sc{gnu} @command{tar} has been conveniently installed at your place, this
3190 manual is also available in interactive, hypertextual form as an Info
3191 file. Just call @w{@samp{info tar}} or, if you do not have the
3192 @command{info} program handy, use the Info reader provided within @sc{gnu}
3193 Emacs, calling @samp{tar} from the main Info menu.
3195 There is currently no @code{man} page for @sc{gnu} @command{tar}. If you observe
3196 such a @code{man} page on the system you are running, either it does not
3197 long to @sc{gnu} @command{tar}, or it has not been produced by @sc{gnu}. Currently,
3198 @sc{gnu} @command{tar} documentation is provided in Texinfo format only, if we
3199 except, of course, the short result of @kbd{tar --help}.
3202 @section Checking @command{tar} progress
3204 @cindex Progress information
3205 @cindex Status information
3206 @cindex Information on progress and status of operations
3207 @cindex Verbose operation
3208 @cindex Block number where error occurred
3209 @cindex Error message, block number of
3210 @cindex Version of the @command{tar} program
3212 @cindex Getting more information during the operation
3213 @cindex Information during operation
3214 @cindex Feedback from @command{tar}
3216 Typically, @command{tar} performs most operations without reporting any
3217 information to the user except error messages. When using @command{tar}
3218 with many options, particularly ones with complicated or
3219 difficult-to-predict behavior, it is possible to make serious mistakes.
3220 @command{tar} provides several options that make observing @command{tar}
3221 easier. These options cause @command{tar} to print information as it
3222 progresses in its job, and you might want to use them just for being
3223 more careful about what is going on, or merely for entertaining
3224 yourself. If you have encountered a problem when operating on an
3225 archive, however, you may need more information than just an error
3226 message in order to solve the problem. The following options can be
3227 helpful diagnostic tools.
3229 Normally, the @value{op-list} command to list an archive prints just
3230 the file names (one per line) and the other commands are silent.
3231 When used with most operations, the @value{op-verbose} option causes
3232 @command{tar} to print the name of each file or archive member as it
3233 is processed. This and the other options which make @command{tar} print
3234 status information can be useful in monitoring @command{tar}.
3236 With @value{op-create} or @value{op-extract}, @value{op-verbose} used once
3237 just prints the names of the files or members as they are processed.
3238 Using it twice causes @command{tar} to print a longer listing (reminiscent
3239 of @samp{ls -l}) for each member. Since @value{op-list} already prints
3240 the names of the members, @value{op-verbose} used once with @value{op-list}
3241 causes @command{tar} to print an @samp{ls -l} type listing of the files
3242 in the archive. The following examples both extract members with
3246 $ @kbd{tar --extract --file=archive.tar --verbose --verbose}
3247 $ @kbd{tar xvv archive.tar}
3250 Verbose output appears on the standard output except when an archive is
3251 being written to the standard output, as with @samp{tar --create
3252 --file=- --verbose} (@samp{tar cfv -}, or even @samp{tar cv}---if the
3253 installer let standard output be the default archive). In that case
3254 @command{tar} writes verbose output to the standard error stream.
3256 The @value{op-totals} option---which is only meaningful when used with
3257 @value{op-create}---causes @command{tar} to print the total
3258 amount written to the archive, after it has been fully created.
3260 The @value{op-checkpoint} option prints an occasional message
3261 as @command{tar} reads or writes the archive. In fact, it print
3262 directory names while reading the archive. It is designed for
3263 those who don't need the more detailed (and voluminous) output of
3264 @value{op-block-number}, but do want visual confirmation that @command{tar}
3265 is actually making forward progress.
3267 @FIXME{There is some confusion here. It seems that -R once wrote a
3268 message at @samp{every} record read or written.}
3270 The @value{op-show-omitted-dirs} option, when reading an archive---with
3271 @value{op-list} or @value{op-extract}, for example---causes a message
3272 to be printed for each directory in the archive which is skipped.
3273 This happens regardless of the reason for skipping: the directory might
3274 not have been named on the command line (implicitly or explicitly),
3275 it might be excluded by the use of the @value{op-exclude} option, or
3278 If @value{op-block-number} is used, @command{tar} prints, along with every
3279 message it would normally produce, the block number within the archive
3280 where the message was triggered. Also, supplementary messages are
3281 triggered when reading blocks full of NULs, or when hitting end of file on
3282 the archive. As of now, if the archive if properly terminated with a NUL
3283 block, the reading of the file may stop before end of file is met, so the
3284 position of end of file will not usually show when @value{op-block-number}
3285 is used. Note that @sc{gnu} @command{tar} drains the archive before exiting when
3286 reading the archive from a pipe.
3288 This option is especially useful when reading damaged archives, since
3289 it helps pinpoint the damaged sections. It can also be used with
3290 @value{op-list} when listing a file-system backup tape, allowing you to
3291 choose among several backup tapes when retrieving a file later, in
3292 favor of the tape where the file appears earliest (closest to the
3293 front of the tape). @FIXME-xref{when the node name is set and the
3294 backup section written.}
3297 @section Asking for Confirmation During Operations
3298 @cindex Interactive operation
3300 Typically, @command{tar} carries out a command without stopping for
3301 further instructions. In some situations however, you may want to
3302 exclude some files and archive members from the operation (for instance
3303 if disk or storage space is tight). You can do this by excluding
3304 certain files automatically (@pxref{Choosing}), or by performing
3305 an operation interactively, using the @value{op-interactive} option.
3306 @command{tar} also accepts @samp{--confirmation} for this option.
3308 When the @value{op-interactive} option is specified, before
3309 reading, writing, or deleting files, @command{tar} first prints a message
3310 for each such file, telling what operation it intends to take, then asks
3311 for confirmation on the terminal. The actions which require
3312 confirmation include adding a file to the archive, extracting a file
3313 from the archive, deleting a file from the archive, and deleting a file
3314 from disk. To confirm the action, you must type a line of input
3315 beginning with @samp{y}. If your input line begins with anything other
3316 than @samp{y}, @command{tar} skips that file.
3318 If @command{tar} is reading the archive from the standard input,
3319 @command{tar} opens the file @file{/dev/tty} to support the interactive
3322 Verbose output is normally sent to standard output, separate from
3323 other error messages. However, if the archive is produced directly
3324 on standard output, then verbose output is mixed with errors on
3325 @code{stderr}. Producing the archive on standard output may be used
3326 as a way to avoid using disk space, when the archive is soon to be
3327 consumed by another process reading it, say. Some people felt the need
3328 of producing an archive on stdout, still willing to segregate between
3329 verbose output and error output. A possible approach would be using a
3330 named pipe to receive the archive, and having the consumer process to
3331 read from that named pipe. This has the advantage of letting standard
3332 output free to receive verbose output, all separate from errors.
3335 @chapter @sc{gnu} @command{tar} Operations
3348 @section Basic @sc{gnu} @command{tar} Operations
3350 The basic @command{tar} operations, @value{op-create}, @value{op-list} and
3351 @value{op-extract}, are currently presented and described in the tutorial
3352 chapter of this manual. This section provides some complementary notes
3353 for these operations.
3356 @item @value{op-create}
3358 Creating an empty archive would have some kind of elegance. One can
3359 initialize an empty archive and later use @value{op-append} for adding
3360 all members. Some applications would not welcome making an exception
3361 in the way of adding the first archive member. On the other hand,
3362 many people reported that it is dangerously too easy for @command{tar}
3363 to destroy a magnetic tape with an empty archive@footnote{This is well
3364 described in @cite{Unix-haters Handbook}, by Simson Garfinkel, Daniel
3365 Weise & Steven Strassmann, IDG Books, ISBN 1-56884-203-1.}. The two most
3370 Mistakingly using @code{create} instead of @code{extract}, when the
3371 intent was to extract the full contents of an archive. This error
3372 is likely: keys @kbd{c} and @kbd{x} are right next ot each other on
3373 the QWERTY keyboard. Instead of being unpacked, the archive then
3374 gets wholly destroyed. When users speak about @dfn{exploding} an
3375 archive, they usually mean something else :-).
3378 Forgetting the argument to @code{file}, when the intent was to create
3379 an archive with a single file in it. This error is likely because a
3380 tired user can easily add the @kbd{f} key to the cluster of option
3381 letters, by the mere force of habit, without realizing the full
3382 consequence of doing so. The usual consequence is that the single
3383 file, which was meant to be saved, is rather destroyed.
3386 So, recognizing the likelihood and the catastrophical nature of these
3387 errors, @sc{gnu} @command{tar} now takes some distance from elegance, and
3388 cowardly refuses to create an archive when @value{op-create} option is
3389 given, there are no arguments besides options, and @value{op-files-from}
3390 option is @emph{not} used. To get around the cautiousness of @sc{gnu}
3391 @command{tar} and nevertheless create an archive with nothing in it,
3392 one may still use, as the value for the @value{op-files-from} option,
3393 a file with no names in it, as shown in the following commands:
3396 @kbd{tar --create --file=empty-archive.tar --files-from=/dev/null}
3397 @kbd{tar cfT empty-archive.tar /dev/null}
3400 @item @value{op-extract}
3402 A socket is stored, within a @sc{gnu} @command{tar} archive, as a pipe.
3404 @item @value{op-list}
3406 @sc{gnu} @command{tar} now shows dates as @samp{1996-08-30}, while it used to
3407 show them as @samp{Aug 30 1996}. (One can revert to the old behavior by
3408 defining @code{USE_OLD_CTIME} in @file{src/list.c} before reinstalling.)
3409 But preferably, people should get used to ISO 8601 dates. Local
3410 American dates should be made available again with full date localization
3411 support, once ready. In the meantime, programs not being localizable
3412 for dates should prefer international dates, that's really the way to go.
3414 Look up @url{http://www.ft.uni-erlangen.de/~mskuhn/iso-time.html} if you
3415 are curious, it contains a detailed explanation of the ISO 8601 standard.
3420 @section Advanced @sc{gnu} @command{tar} Operations
3422 Now that you have learned the basics of using @sc{gnu} @command{tar}, you may
3423 want to learn about further ways in which @command{tar} can help you.
3425 This chapter presents five, more advanced operations which you probably
3426 won't use on a daily basis, but which serve more specialized functions.
3427 We also explain the different styles of options and why you might want
3428 to use one or another, or a combination of them in your @command{tar}
3429 commands. Additionally, this chapter includes options which allow you to
3430 define the output from @command{tar} more carefully, and provide help and
3431 error correction in special circumstances.
3433 @FIXME{check this after the chapter is actually revised to make sure
3434 it still introduces the info in the chapter correctly : ).}
3447 @subsection The Five Advanced @command{tar} Operations
3450 In the last chapter, you learned about the first three operations to
3451 @command{tar}. This chapter presents the remaining five operations to
3452 @command{tar}: @samp{--append}, @samp{--update}, @samp{--concatenate},
3453 @samp{--delete}, and @samp{--compare}.
3455 You are not likely to use these operations as frequently as those
3456 covered in the last chapter; however, since they perform specialized
3457 functions, they are quite useful when you do need to use them. We
3458 will give examples using the same directory and files that you created
3459 in the last chapter. As you may recall, the directory is called
3460 @file{practice}, the files are @samp{jazz}, @samp{blues}, @samp{folk},
3461 @samp{rock}, and the two archive files you created are
3462 @samp{collection.tar} and @samp{music.tar}.
3464 We will also use the archive files @samp{afiles.tar} and
3465 @samp{bfiles.tar}. @samp{afiles.tar} contains the members @samp{apple},
3466 @samp{angst}, and @samp{aspic}. @samp{bfiles.tar} contains the members
3467 @samp{./birds}, @samp{baboon}, and @samp{./box}.
3469 Unless we state otherwise, all practicing you do and examples you follow
3470 in this chapter will take place in the @file{practice} directory that
3471 you created in the previous chapter; see @ref{prepare for examples}.
3472 (Below in this section, we will remind you of the state of the examples
3473 where the last chapter left them.)
3475 The five operations that we will cover in this chapter are:
3480 Add new entries to an archive that already exists.
3483 Add more recent copies of archive members to the end of an archive, if
3488 Add one or more pre-existing archives to the end of another archive.
3490 Delete items from an archive (does not work on tapes).
3494 Compare archive members to their counterparts in the file system.
3498 @subsection The Current State of the Practice Files
3500 Currently, the listing of the directory using @command{ls} is as follows:
3507 The archive file @samp{collection.tar} looks like this:
3510 $ @kbd{tar -tvf collection.tar}
3515 The archive file @samp{music.tar} looks like this:
3518 $ @kbd{tar -tvf music.tar}
3522 @FIXME{need to fill in the above!!!}
3525 @subsection How to Add Files to Existing Archives: @code{--append}
3528 If you want to add files to an existing archive, you don't need to
3529 create a new archive; you can use @value{op-append}. The archive must
3530 already exist in order to use @samp{--append}. (A related operation
3531 is the @samp{--update} operation; you can use this to add newer
3532 versions of archive members to an existing archive. To learn how to
3533 do this with @samp{--update}, @pxref{update}.)
3535 @FIXME{Explain in second paragraph whether you can get to the previous
3536 version -- explain whole situation somewhat more clearly.}
3538 If you use @value{op-append} to add a file that has the same name as an
3539 archive member to an archive containing that archive member, then the
3540 old member is not deleted. What does happen, however, is somewhat
3541 complex. @command{tar} @emph{allows} you to have infinite numbers of files
3542 with the same name. Some operations treat these same-named members no
3543 differently than any other set of archive members: for example, if you
3544 view an archive with @value{op-list}, you will see all of those members
3545 listed, with their modification times, owners, etc.
3547 Other operations don't deal with these members as perfectly as you might
3548 prefer; if you were to use @value{op-extract} to extract the archive,
3549 only the most recently added copy of a member with the same name as four
3550 other members would end up in the working directory. This is because
3551 @samp{--extract} extracts an archive in the order the members appeared
3552 in the archive; the most recently archived members will be extracted
3553 last. Additionally, an extracted member will @emph{replace} a file of
3554 the same name which existed in the directory already, and @command{tar}
3555 will not prompt you about this. Thus, only the most recently archived
3556 member will end up being extracted, as it will replace the one
3557 extracted before it, and so on.
3559 @FIXME{ hag -- you might want to incorporate some of the above into the
3560 MMwtSN node; not sure. i didn't know how to make it simpler...}
3562 There are a few ways to get around this. @FIXME-xref{Multiple Members
3563 with the Same Name.}
3565 @cindex Members, replacing with other members
3566 @cindex Replacing members with other members
3567 If you want to replace an archive member, use @value{op-delete} to
3568 delete the member you want to remove from the archive, , and then use
3569 @samp{--append} to add the member you want to be in the archive. Note
3570 that you can not change the order of the archive; the most recently
3571 added member will still appear last. In this sense, you cannot truly
3572 ``replace'' one member with another. (Replacing one member with another
3573 will not work on certain types of media, such as tapes; see @ref{delete}
3574 and @ref{Media}, for more information.)
3577 * appending files:: Appending Files to an Archive
3581 @node appending files
3582 @subsubsection Appending Files to an Archive
3584 @cindex Adding files to an Archive
3585 @cindex Appending files to an Archive
3586 @cindex Archives, Appending files to
3588 The simplest way to add a file to an already existing archive is the
3589 @value{op-append} operation, which writes specified files into the
3590 archive whether or not they are already among the archived files.
3591 When you use @samp{--append}, you @emph{must} specify file name
3592 arguments, as there is no default. If you specify a file that already
3593 exists in the archive, another copy of the file will be added to the
3594 end of the archive. As with other operations, the member names of the
3595 newly added files will be exactly the same as their names given on the
3596 command line. The @value{op-verbose} option will print out the names
3597 of the files as they are written into the archive.
3599 @samp{--append} cannot be performed on some tape drives, unfortunately,
3600 due to deficiencies in the formats those tape drives use. The archive
3601 must be a valid @command{tar} archive, or else the results of using this
3602 operation will be unpredictable. @xref{Media}.
3604 To demonstrate using @samp{--append} to add a file to an archive,
3605 create a file called @file{rock} in the @file{practice} directory.
3606 Make sure you are in the @file{practice} directory. Then, run the
3607 following @command{tar} command to add @file{rock} to
3608 @file{collection.tar}:
3611 $ @kbd{tar --append --file=collection.tar rock}
3615 If you now use the @value{op-list} operation, you will see that
3616 @file{rock} has been added to the archive:
3619 $ @kbd{tar --list --file=collection.tar}
3620 -rw-rw-rw- me user 28 1996-10-18 16:31 jazz
3621 -rw-rw-rw- me user 21 1996-09-23 16:44 blues
3622 -rw-rw-rw- me user 20 1996-09-23 16:44 folk
3623 -rw-rw-rw- me user 20 1996-09-23 16:44 rock
3626 @FIXME{in theory, dan will (soon) try to turn this node into what it's
3627 title claims it will become...}
3630 @subsubsection Multiple Files with the Same Name
3632 You can use @value{op-append} to add copies of files which have been
3633 updated since the archive was created. (However, we do not recommend
3634 doing this since there is another @command{tar} option called
3635 @samp{--update}; @pxref{update} for more information. We describe this
3636 use of @samp{--append} here for the sake of completeness.) @FIXME{is
3637 this really a good idea, to give this whole description for something
3638 which i believe is basically a Stupid way of doing something? certain
3639 aspects of it show ways in which tar is more broken than i'd personally
3640 like to admit to, specifically the last sentence. On the other hand, i
3641 don't think it's a good idea to be saying that re explicitly don't
3642 recommend using something, but i can't see any better way to deal with
3643 the situation.}When you extract the archive, the older version will be
3644 effectively lost. This works because files are extracted from an
3645 archive in the order in which they were archived. Thus, when the
3646 archive is extracted, a file archived later in time will replace a
3647 file of the same name which was archived earlier, even though the older
3648 version of the file will remain in the archive unless you delete all
3649 versions of the file.
3651 Supposing you change the file @file{blues} and then append the changed
3652 version to @file{collection.tar}. As you saw above, the original
3653 @file{blues} is in the archive @file{collection.tar}. If you change the
3654 file and append the new version of the file to the archive, there will
3655 be two copies in the archive. When you extract the archive, the older
3656 version of the file will be extracted first, and then replaced by the
3657 newer version when it is extracted.
3659 You can append the new, changed copy of the file @file{blues} to the
3660 archive in this way:
3663 $ @kbd{tar --append --verbose --file=collection.tar blues}
3668 Because you specified the @samp{--verbose} option, @command{tar} has
3669 printed the name of the file being appended as it was acted on. Now
3670 list the contents of the archive:
3673 $ @kbd{tar --list --verbose --file=collection.tar}
3674 -rw-rw-rw- me user 28 1996-10-18 16:31 jazz
3675 -rw-rw-rw- me user 21 1996-09-23 16:44 blues
3676 -rw-rw-rw- me user 20 1996-09-23 16:44 folk
3677 -rw-rw-rw- me user 20 1996-09-23 16:44 rock
3678 -rw-rw-rw- me user 58 1996-10-24 18:30 blues
3682 The newest version of @file{blues} is now at the end of the archive
3683 (note the different creation dates and file sizes). If you extract
3684 the archive, the older version of the file @file{blues} will be
3685 replaced by the newer version. You can confirm this by extracting
3686 the archive and running @samp{ls} on the directory. @xref{Writing},
3687 for more information. (@emph{Please note:} This is the case unless
3688 you employ the @value{op-backup} option. @FIXME-ref{Multiple Members
3689 with the Same Name}.)
3692 @subsection Updating an Archive
3694 @cindex Updating an archive
3696 In the previous section, you learned how to use @value{op-append} to add
3697 a file to an existing archive. A related operation is
3698 @value{op-update}. The @samp{--update} operation updates a @command{tar}
3699 archive by comparing the date of the specified archive members against
3700 the date of the file with the same name. If the file has been modified
3701 more recently than the archive member, then the newer version of the
3702 file is added to the archive (as with @value{op-append}).
3704 Unfortunately, you cannot use @samp{--update} with magnetic tape drives.
3705 The operation will fail.
3707 @FIXME{other examples of media on which --update will fail? need to ask
3708 charles and/or mib/thomas/dave shevett..}
3710 Both @samp{--update} and @samp{--append} work by adding to the end
3711 of the archive. When you extract a file from the archive, only the
3712 version stored last will wind up in the file system, unless you use
3713 the @value{op-backup} option. @FIXME-ref{Multiple Members with the
3721 @subsubsection How to Update an Archive Using @code{--update}
3723 You must use file name arguments with the @value{op-update} operation.
3724 If you don't specify any files, @command{tar} won't act on any files and
3725 won't tell you that it didn't do anything (which may end up confusing
3728 @FIXME{note: the above parenthetical added because in fact, this
3729 behavior just confused the author. :-) }
3731 To see the @samp{--update} option at work, create a new file,
3732 @file{classical}, in your practice directory, and some extra text to the
3733 file @file{blues}, using any text editor. Then invoke @command{tar} with
3734 the @samp{update} operation and the @value{op-verbose} option specified,
3735 using the names of all the files in the practice directory as file name
3739 $ @kbd{tar --update -v -f collection.tar blues folk rock classical}
3746 Because we have specified verbose mode, @command{tar} prints out the names
3747 of the files it is working on, which in this case are the names of the
3748 files that needed to be updated. If you run @samp{tar --list} and look
3749 at the archive, you will see @file{blues} and @file{classical} at its
3750 end. There will be a total of two versions of the member @samp{blues};
3751 the one at the end will be newer and larger, since you added text before
3754 (The reason @command{tar} does not overwrite the older file when updating
3755 it is because writing to the middle of a section of tape is a difficult
3756 process. Tapes are not designed to go backward. @xref{Media}, for more
3757 information about tapes.
3759 @value{op-update} is not suitable for performing backups for two
3760 reasons: it does not change directory content entries, and it lengthens
3761 the archive every time it is used. The @sc{gnu} @command{tar} options intended
3762 specifically for backups are more efficient. If you need to run
3763 backups, please consult @ref{Backups}.
3766 @subsection Combining Archives with @code{--concatenate}
3768 @cindex Adding archives to an archive
3769 @cindex Concatenating Archives
3770 Sometimes it may be convenient to add a second archive onto the end of
3771 an archive rather than adding individual files to the archive. To add
3772 one or more archives to the end of another archive, you should use the
3773 @value{op-concatenate} operation.
3775 To use @samp{--concatenate}, name the archives to be concatenated on the
3776 command line. (Nothing happens if you don't list any.) The members,
3777 and their member names, will be copied verbatim from those archives. If
3778 this causes multiple members to have the same name, it does not delete
3779 any members; all the members with the same name coexist. @FIXME-ref{For
3780 information on how this affects reading the archive, Multiple
3781 Members with the Same Name.}
3783 To demonstrate how @samp{--concatenate} works, create two small archives
3784 called @file{bluesrock.tar} and @file{folkjazz.tar}, using the relevant
3785 files from @file{practice}:
3788 $ @kbd{tar -cvf bluesrock.tar blues rock}
3791 $ @kbd{tar -cvf folkjazz.tar folk jazz}
3797 If you like, You can run @samp{tar --list} to make sure the archives
3798 contain what they are supposed to:
3801 $ @kbd{tar -tvf bluesrock.tar}
3802 -rw-rw-rw- melissa user 105 1997-01-21 19:42 blues
3803 -rw-rw-rw- melissa user 33 1997-01-20 15:34 rock
3804 $ @kbd{tar -tvf folkjazz.tar}
3805 -rw-rw-rw- melissa user 20 1996-09-23 16:44 folk
3806 -rw-rw-rw- melissa user 65 1997-01-30 14:15 jazz
3809 We can concatenate these two archives with @command{tar}:
3813 $ @kbd{tar --concatenate --file=bluesrock.tar jazzfolk.tar}
3816 If you now list the contents of the @file{bluesclass.tar}, you will see
3817 that now it also contains the archive members of @file{jazzfolk.tar}:
3820 $ @kbd{tar --list --file=bluesrock.tar}
3827 When you use @samp{--concatenate}, the source and target archives must
3828 already exist and must have been created using compatible format
3829 parameters. @FIXME-pxref{Matching Format Parameters}The new,
3830 concatenated archive will be called by the same name as the first
3831 archive listed on the command line. @FIXME{is there a way to specify a
3834 Like @value{op-append}, this operation cannot be performed on some
3835 tape drives, due to deficiencies in the formats those tape drives use.
3837 @cindex @code{concatenate} vs @command{cat}
3838 @cindex @command{cat} vs @code{concatenate}
3839 It may seem more intuitive to you to want or try to use @command{cat} to
3840 concatenate two archives instead of using the @samp{--concatenate}
3841 operation; after all, @command{cat} is the utility for combining files.
3843 However, @command{tar} archives incorporate an end-of-file marker which
3844 must be removed if the concatenated archives are to be read properly as
3845 one archive. @samp{--concatenate} removes the end-of-archive marker
3846 from the target archive before each new archive is appended. If you use
3847 @command{cat} to combine the archives, the result will not be a valid
3848 @command{tar} format archive. If you need to retrieve files from an
3849 archive that was added to using the @command{cat} utility, use the
3850 @value{op-ignore-zeros} option. @xref{Ignore Zeros}, for further
3851 information on dealing with archives improperly combined using the
3852 @command{cat} shell utility.
3854 @FIXME{this shouldn't go here. where should it go?} You must specify
3855 the source archives using @value{op-file} (@value{pxref-file}). If you
3856 do not specify the target archive, @command{tar} uses the value of the
3857 environment variable @env{TAPE}, or, if this has not been set, the
3858 default archive name.
3861 @subsection Removing Archive Members Using @samp{--delete}
3863 @cindex Deleting files from an archive
3864 @cindex Removing files from an archive
3866 You can remove members from an archive by using the @value{op-delete}
3867 option. Specify the name of the archive with @value{op-file} and then
3868 specify the names of the members to be deleted; if you list no member
3869 names, nothing will be deleted. The @value{op-verbose} option will
3870 cause @command{tar} to print the names of the members as they are deleted.
3871 As with @value{op-extract}, you must give the exact member names when
3872 using @samp{tar --delete}. @samp{--delete} will remove all versions of
3873 the named file from the archive. The @samp{--delete} operation can run
3876 Unlike other operations, @samp{--delete} has no short form.
3878 @cindex Tapes, using @code{--delete} and
3879 @cindex Deleting from tape archives
3880 This operation will rewrite the archive. You can only use
3881 @samp{--delete} on an archive if the archive device allows you to
3882 write to any point on the media, such as a disk; because of this, it
3883 does not work on magnetic tapes. Do not try to delete an archive member
3884 from a magnetic tape; the action will not succeed, and you will be
3885 likely to scramble the archive and damage your tape. There is no safe
3886 way (except by completely re-writing the archive) to delete files from
3887 most kinds of magnetic tape. @xref{Media}.
3889 To delete all versions of the file @file{blues} from the archive
3890 @file{collection.tar} in the @file{practice} directory, make sure you
3891 are in that directory, and then,
3894 $ @kbd{tar --list --file=collection.tar}
3904 $ @kbd{tar --delete --file=collection.tar blues}
3905 $ @kbd{tar --list --file=collection.tar}
3912 @FIXME{I changed the order of these nodes around and haven't had a chance
3913 to fix the above example's results, yet. I have to play with this and
3914 follow it and see what it actually does!}
3916 The @value{op-delete} option has been reported to work properly when
3917 @command{tar} acts as a filter from @code{stdin} to @code{stdout}.
3920 @subsection Comparing Archive Members with the File System
3921 @cindex Verifying the currency of an archive
3924 The @samp{--compare} (@samp{-d}), or @samp{--diff} operation compares
3925 specified archive members against files with the same names, and then
3926 reports differences in file size, mode, owner, modification date and
3927 contents. You should @emph{only} specify archive member names, not file
3928 names. If you do not name any members, then @command{tar} will compare the
3929 entire archive. If a file is represented in the archive but does not
3930 exist in the file system, @command{tar} reports a difference.
3932 You have to specify the record size of the archive when modifying an
3933 archive with a non-default record size.
3935 @command{tar} ignores files in the file system that do not have
3936 corresponding members in the archive.
3938 The following example compares the archive members @file{rock},
3939 @file{blues} and @file{funk} in the archive @file{bluesrock.tar} with
3940 files of the same name in the file system. (Note that there is no file,
3941 @file{funk}; @command{tar} will report an error message.)
3944 $ @kbd{tar --compare --file=bluesrock.tar rock blues funk}
3947 tar: funk not found in archive
3951 @FIXME{what does this actually depend on? i'm making a guess,
3952 here.}Depending on the system where you are running @command{tar} and the
3953 version you are running, @command{tar} may have a different error message,
3957 funk: does not exist
3960 @FIXME-xref{somewhere, for more information about format parameters.
3961 Melissa says: such as "format variations"? But why? Clearly I don't
3962 get it yet; I'll deal when I get to that section.}
3964 The spirit behind the @value{op-compare} option is to check whether the
3965 archive represents the current state of files on disk, more than validating
3966 the integrity of the archive media. For this later goal, @xref{verify}.
3968 @node create options
3969 @section Options Used by @code{--create}
3971 The previous chapter described the basics of how to use
3972 @value{op-create} to create an archive from a set of files.
3973 @xref{create}. This section described advanced options to be used with
3977 * Ignore Failed Read::
3980 @node Ignore Failed Read
3981 @subsection Ignore Fail Read
3984 @item --ignore-failed-read
3985 Do not exit with nonzero on unreadable files or directories.
3988 @node extract options
3989 @section Options Used by @code{--extract}
3992 @FIXME{i need to get dan to go over these options with me and see if
3993 there's a better way of organizing them.}
3995 The previous chapter showed how to use @value{op-extract} to extract
3996 an archive into the filesystem. Various options cause @command{tar} to
3997 extract more information than just file contents, such as the owner,
3998 the permissions, the modification date, and so forth. This section
3999 presents options to be used with @samp{--extract} when certain special
4000 considerations arise. You may review the information presented in
4001 @ref{extract} for more basic information about the
4002 @samp{--extract} operation.
4005 * Reading:: Options to Help Read Archives
4006 * Writing:: Changing How @command{tar} Writes Files
4007 * Scarce:: Coping with Scarce Resources
4011 @subsection Options to Help Read Archives
4012 @cindex Options when reading archives
4013 @cindex Reading incomplete records
4014 @cindex Records, incomplete
4015 @cindex End-of-archive entries, ignoring
4016 @cindex Ignoring end-of-archive entries
4017 @cindex Large lists of file names on small machines
4018 @cindex Small memory
4019 @cindex Running out of space
4022 Normally, @command{tar} will request data in full record increments from
4023 an archive storage device. If the device cannot return a full record,
4024 @command{tar} will report an error. However, some devices do not always
4025 return full records, or do not require the last record of an archive to
4026 be padded out to the next record boundary. To keep reading until you
4027 obtain a full record, or to accept an incomplete record if it contains
4028 an end-of-archive marker, specify the @value{op-read-full-records} option
4029 in conjunction with the @value{op-extract} or @value{op-list} operations.
4030 @value{xref-read-full-records}.
4032 The @value{op-read-full-records} option is turned on by default when
4033 @command{tar} reads an archive from standard input, or from a remote
4034 machine. This is because on BSD Unix systems, attempting to read a
4035 pipe returns however much happens to be in the pipe, even if it is
4036 less than was requested. If this option were not enabled, @command{tar}
4037 would fail as soon as it read an incomplete record from the pipe.
4039 If you're not sure of the blocking factor of an archive, you can
4040 read the archive by specifying @value{op-read-full-records} and
4041 @value{op-blocking-factor}, using a blocking factor larger than what the
4042 archive uses. This lets you avoid having to determine the blocking factor
4043 of an archive. @value{xref-blocking-factor}.
4046 * read full records::
4050 @node read full records
4051 @unnumberedsubsubsec Reading Full Records
4053 @FIXME{need sentence or so of intro here}
4056 @item --read-full-records
4058 Use in conjunction with @value{op-extract} to read an archive which
4059 contains incomplete records, or one which has a blocking factor less
4060 than the one specified.
4064 @unnumberedsubsubsec Ignoring Blocks of Zeros
4066 Normally, @command{tar} stops reading when it encounters a block of zeros
4067 between file entries (which usually indicates the end of the archive).
4068 @value{op-ignore-zeros} allows @command{tar} to completely read an archive
4069 which contains a block of zeros before the end (i.e.@: a damaged
4070 archive, or one which was created by concatenating several archives
4073 The @value{op-ignore-zeros} option is turned off by default because many
4074 versions of @command{tar} write garbage after the end-of-archive entry,
4075 since that part of the media is never supposed to be read. @sc{gnu}
4076 @command{tar} does not write after the end of an archive, but seeks to
4077 maintain compatiblity among archiving utilities.
4080 @item --ignore-zeros
4082 To ignore blocks of zeros (ie.@: end-of-archive entries) which may be
4083 encountered while reading an archive. Use in conjunction with
4084 @value{op-extract} or @value{op-list}.
4088 @subsection Changing How @command{tar} Writes Files
4089 @cindex Overwriting old files, prevention
4090 @cindex Protecting old files
4091 @cindex Modification times of extracted files
4092 @cindex Permissions of extracted files
4093 @cindex Modes of extracted files
4094 @cindex Writing extracted files to standard output
4095 @cindex Standard output, writing extracted files to
4098 @FIXME{need to mention the brand new option, --backup}
4101 * Dealing with Old Files::
4102 * Overwrite Old Files::
4105 * Recursive Unlink::
4106 * Modification Times::
4107 * Setting Access Permissions::
4108 * Writing to Standard Output::
4112 @node Dealing with Old Files
4113 @unnumberedsubsubsec Options Controlling the Overwriting of Existing Files
4115 When extracting files, if @command{tar} discovers that the extracted
4116 file already exists, it normally replaces the file by removing it before
4117 extracting it, to prevent confusion in the presence of hard or symbolic
4118 links. (If the existing file is a symbolic link, it is removed, not
4119 followed.) However, if a directory cannot be removed because it is
4120 nonempty, @command{tar} neither removes it nor modifies its ownership,
4121 permissions, or time stamps.
4123 To be more cautious and prevent existing files from being replaced, use
4124 the @value{op-keep-old-files} option. It causes @command{tar} to refuse
4125 to replace or update a file that already exists, i.e., a file with the
4126 same name as an archive member prevents extraction of that archive
4129 To be more aggressive about altering existing files, use the
4130 @value{op-overwrite} option. It causes @command{tar} to overwrite
4131 existing files and to follow existing symbolic links when extracting.
4133 Some people argue that @sc{gnu} @command{tar} should not hesitate to overwrite
4134 files with other files when extracting. When extracting a @command{tar}
4135 archive, they expect to see a faithful copy of the state of the filesystem
4136 when the archive was created. It is debatable that this would always
4137 be a proper behavior. For example, suppose one has an archive in
4138 which @file{usr/local} is a link to @file{usr/local2}. Since then,
4139 maybe the site removed the link and renamed the whole hierarchy from
4140 @file{/usr/local2} to @file{/usr/local}. Such things happen all the time.
4141 I guess it would not be welcome at all that @sc{gnu} @command{tar} removes the
4142 whole hierarchy just to make room for the link to be reinstated (unless it
4143 @emph{also} simultaneously restores the full @file{/usr/local2}, of course!
4144 @sc{gnu} @command{tar} is indeed able to remove a whole hierarchy to reestablish a
4145 symbolic link, for example, but @emph{only if} @value{op-recursive-unlink}
4146 is specified to allow this behavior. In any case, single files are
4149 Finally, the @value{op-unlink-first} option can improve performance in
4150 some cases by causing @command{tar} to remove files unconditionally
4151 before extracting them.
4153 @node Overwrite Old Files
4154 @unnumberedsubsubsec Overwrite Old Files
4158 Overwrite existing files and directory metadata when extracting files
4162 causes @command{tar} to write extracted files into the file system without
4163 regard to the files already on the system; i.e., files with the same
4164 names as archive members are overwritten when the archive is extracted.
4165 It also causes @command{tar} to extract the ownership, permissions,
4166 and time stamps onto any preexisting files or directories.
4167 If the name of a corresponding file name is a symbolic link, the file
4168 pointed to by the symbolic link will be overwritten instead of the
4169 symbolic link itself (if this is possible). Moreover, special devices,
4170 empty directories and even symbolic links are automatically removed if
4171 they are in the way of extraction.
4173 Be careful when using the @value{op-overwrite} option, particularly when
4174 combined with the @value{op-absolute-names} option, as this combination
4175 can change the contents, ownership or permissions of any file on your
4176 system. Also, many systems do not take kindly to overwriting files that
4177 are currently being executed.
4180 @node Keep Old Files
4181 @unnumberedsubsubsec Keep Old Files
4184 @item --keep-old-files
4186 Do not replace existing files from archive. The
4187 @value{op-keep-old-files} option prevents @command{tar} from replacing
4188 existing files with files with the same name from the archive.
4189 The @value{op-keep-old-files} option is meaningless with @value{op-list}.
4190 Prevents @command{tar} from replacing files in the file system during
4195 @unnumberedsubsubsec Unlink First
4198 @item --unlink-first
4200 Remove files before extracting over them.
4201 This can make @command{tar} run a bit faster if you know in advance
4202 that the extracted files all need to be removed. Normally this option
4203 slows @command{tar} down slightly, so it is disabled by default.
4206 @node Recursive Unlink
4207 @unnumberedsubsubsec Recursive Unlink
4210 @item --recursive-unlink
4211 When this option is specified, try removing files and directory hierarchies
4212 before extracting over them. @emph{This is a dangerous option!}
4215 If you specify the @value{op-recursive-unlink} option,
4216 @command{tar} removes @emph{anything} that keeps you from extracting a file
4217 as far as current permissions will allow it. This could include removal
4218 of the contents of a full directory hierarchy.
4220 @node Modification Times
4221 @unnumberedsubsubsec Setting Modification Times
4223 Normally, @command{tar} sets the modification times of extracted files to
4224 the modification times recorded for the files in the archive, but
4225 limits the permissions of extracted files by the current @code{umask}
4228 To set the modification times of extracted files to the time when
4229 the files were extracted, use the @value{op-touch} option in
4230 conjunction with @value{op-extract}.
4235 Sets the modification time of extracted archive members to the time
4236 they were extracted, not the time recorded for them in the archive.
4237 Use in conjunction with @value{op-extract}.
4240 @node Setting Access Permissions
4241 @unnumberedsubsubsec Setting Access Permissions
4243 To set the modes (access permissions) of extracted files to those
4244 recorded for those files in the archive, use @samp{--same-permissions}
4245 in conjunction with the @value{op-extract} operation. @FIXME{Should be
4246 aliased to ignore-umask.}
4249 @item --preserve-permission
4250 @itemx --same-permission
4251 @itemx --ignore-umask
4253 Set modes of extracted archive members to those recorded in the
4254 archive, instead of current umask settings. Use in conjunction with
4258 @FIXME{Following paragraph needs to be rewritten: why doesn't this cat
4259 files together, why is this useful. is it really useful with
4260 more than one file?}
4262 @node Writing to Standard Output
4263 @unnumberedsubsubsec Writing to Standard Output
4265 To write the extracted files to the standard output, instead of
4266 creating the files on the file system, use @value{op-to-stdout} in
4267 conjunction with @value{op-extract}. This option is useful if you are
4268 extracting files to send them through a pipe, and do not need to
4269 preserve them in the file system. If you extract multiple members,
4270 they appear on standard output concatenated, in the order they are
4271 found in the archive.
4276 Writes files to the standard output. Used in conjunction with
4277 @value{op-extract}. Extract files to standard output. When this option
4278 is used, instead of creating the files specified, @command{tar} writes
4279 the contents of the files extracted to its standard output. This may
4280 be useful if you are only extracting the files in order to send them
4281 through a pipe. This option is meaningless with @value{op-list}.
4284 @FIXME{Why would you want to do such a thing, how are files separated on
4285 the standard output? is this useful with more that one file? Are
4286 pipes the real reason?}
4289 @unnumberedsubsubsec Removing Files
4291 @FIXME{the various macros in the front of the manual think that this
4292 option goes in this section. i have no idea; i only know it's nowhere
4293 else in the book...}
4296 @item --remove-files
4297 Remove files after adding them to the archive.
4301 @subsection Coping with Scarce Resources
4302 @cindex Middle of the archive, starting in the
4303 @cindex Running out of space during extraction
4304 @cindex Disk space, running out of
4305 @cindex Space on the disk, recovering from lack of
4314 @unnumberedsubsubsec Starting File
4317 @item --starting-file=@var{name}
4318 @itemx -K @var{name}
4319 Starts an operation in the middle of an archive. Use in conjunction
4320 with @value{op-extract} or @value{op-list}.
4323 If a previous attempt to extract files failed due to lack of disk
4324 space, you can use @value{op-starting-file} to start extracting only
4325 after member @var{name} of the archive. This assumes, of course, that
4326 there is now free space, or that you are now extracting into a
4327 different file system. (You could also choose to suspend @command{tar},
4328 remove unnecessary files from the file system, and then restart the
4329 same @command{tar} operation. In this case, @value{op-starting-file} is
4330 not necessary. @value{xref-incremental}, @value{xref-interactive},
4331 and @value{ref-exclude}.)
4334 @unnumberedsubsubsec Same Order
4338 @itemx --preserve-order
4340 To process large lists of file names on machines with small amounts of
4341 memory. Use in conjunction with @value{op-compare},
4343 or @value{op-extract}.
4346 @FIXME{we don't need/want --preserve to exist any more (from melissa:
4347 ie, don't want that *version* of the option to exist, or don't want
4348 the option to exist in either version?}
4350 @FIXME{i think this explanation is lacking.}
4352 The @value{op-same-order} option tells @command{tar} that the list of file
4353 names to be listed or extracted is sorted in the same order as the
4354 files in the archive. This allows a large list of names to be used,
4355 even on a small machine that would not otherwise be able to hold all
4356 the names in memory at the same time. Such a sorted list can easily be
4357 created by running @samp{tar -t} on the archive and editing its output.
4359 This option is probably never needed on modern computer systems.
4362 @section Backup options
4364 @cindex backup options
4366 @sc{gnu} @command{tar} offers options for making backups of files before writing
4367 new versions. These options control the details of these backups.
4368 They may apply to the archive itself before it is created or rewritten,
4369 as well as individual extracted members. Other @sc{gnu} programs (@command{cp},
4370 @command{install}, @command{ln}, and @command{mv}, for example) offer similar
4373 Backup options may prove unexpectedly useful when extracting archives
4374 containing many members having identical name, or when extracting archives
4375 on systems having file name limitations, making different members appear
4376 has having similar names through the side-effect of name truncation.
4377 (This is true only if we have a good scheme for truncated backup names,
4378 which I'm not sure at all: I suspect work is needed in this area.)
4379 When any existing file is backed up before being overwritten by extraction,
4380 then clashing files are automatically be renamed to be unique, and the
4381 true name is kept for only the last file of a series of clashing files.
4382 By using verbose mode, users may track exactly what happens.
4384 At the detail level, some decisions are still experimental, and may
4385 change in the future, we are waiting comments from our users. So, please
4386 do not learn to depend blindly on the details of the backup features.
4387 For example, currently, directories themselves are never renamed through
4388 using these options, so, extracting a file over a directory still has
4389 good chances to fail. Also, backup options apply to created archives,
4390 not only to extracted members. For created archives, backups will not
4391 be attempted when the archive is a block or character device, or when it
4392 refers to a remote file.
4394 For the sake of simplicity and efficiency, backups are made by renaming old
4395 files prior to creation or extraction, and not by copying. The original
4396 name is restored if the file creation fails. If a failure occurs after a
4397 partial extraction of a file, both the backup and the partially extracted
4402 @item --backup[=@var{method}]
4404 @vindex VERSION_CONTROL
4406 Back up files that are about to be overwritten or removed.
4407 Without this option, the original versions are destroyed.
4409 Use @var{method} to determine the type of backups made.
4410 If @var{method} is not specified, use the value of the @env{VERSION_CONTROL}
4411 environment variable. And if @env{VERSION_CONTROL} is not set,
4412 use the @samp{existing} method.
4414 @vindex version-control @r{Emacs variable}
4415 This option corresponds to the Emacs variable @samp{version-control};
4416 the same values for @var{method} are accepted as in Emacs. This option
4417 also allows more descriptive names. The valid @var{method}s are:
4422 @opindex numbered @r{backup method}
4423 Always make numbered backups.
4427 @opindex existing @r{backup method}
4428 Make numbered backups of files that already have them, simple backups
4433 @opindex simple @r{backup method}
4434 Always make simple backups.
4438 @item --suffix=@var{suffix}
4440 @cindex backup suffix
4441 @vindex SIMPLE_BACKUP_SUFFIX
4442 Append @var{suffix} to each backup file made with @samp{--backup}. If this
4443 option is not specified, the value of the @env{SIMPLE_BACKUP_SUFFIX}
4444 environment variable is used. And if @env{SIMPLE_BACKUP_SUFFIX} is not
4445 set, the default is @samp{~}, just as in Emacs.
4449 Some people express the desire to @emph{always} use the @value{op-backup}
4450 option, by defining some kind of alias or script. This is not as easy
4451 as one may think, due to the fact that old style options should appear first
4452 and consume arguments a bit unpredictably for an alias or script. But,
4453 if you are ready to give up using old style options, you may resort to
4454 using something like (a Bourne shell function here):
4457 tar () @{ /usr/local/bin/tar --backup $*; @}
4461 @section Notable @command{tar} Usages
4464 @FIXME{Using Unix file linking capability to recreate directory
4465 structures---linking files into one subdirectory and then
4466 @command{tar}ring that directory.}
4468 @FIXME{Nice hairy example using absolute-names, newer, etc.}
4471 You can easily use archive files to transport a group of files from
4472 one system to another: put all relevant files into an archive on one
4473 computer system, transfer the archive to another system, and extract
4474 the contents there. The basic transfer medium might be magnetic tape,
4475 Internet FTP, or even electronic mail (though you must encode the
4476 archive with @command{uuencode} in order to transport it properly by
4477 mail). Both machines do not have to use the same operating system, as
4478 long as they both support the @command{tar} program.
4480 For example, here is how you might copy a directory's contents from
4481 one disk to another, while preserving the dates, modes, owners and
4482 link-structure of all the files therein. In this case, the transfer
4483 medium is a @dfn{pipe}, which is one a Unix redirection mechanism:
4486 $ @kbd{cd sourcedir; tar -cf - . | (cd targetdir; tar -xf -)}
4490 The command also works using short option forms:
4492 @FIXME{The following using standard input/output correct??}
4494 $ @w{@kbd{cd sourcedir; tar --create --file=- . | (cd targetdir; tar --extract --file=-)}}
4498 This is one of the easiest methods to transfer a @command{tar} archive.
4501 @section Looking Ahead: The Rest of this Manual
4503 You have now seen how to use all eight of the operations available to
4504 @command{tar}, and a number of the possible options. The next chapter
4505 explains how to choose and change file and archive names, how to use
4506 files to store names of other files which you can then call as
4507 arguments to @command{tar} (this can help you save time if you expect to
4508 archive the same list of files a number of times), and so forth.
4509 @FIXME{in case it's not obvious, i'm making this up in some sense
4510 based on my imited memory of what the next chapter *really* does. i
4511 just wanted to flesh out this final section a little bit so i'd
4512 remember to sitck it in here. :-)}
4514 If there are too many files to conveniently list on the command line,
4515 you can list the names in a file, and @command{tar} will read that file.
4516 @value{xref-files-from}.
4518 There are various ways of causing @command{tar} to skip over some files,
4519 and not archive them. @xref{Choosing}.
4522 @chapter Performing Backups and Restoring Files
4525 @sc{gnu} @command{tar} is distributed along with the scripts which the Free
4526 Software Foundation uses for performing backups. There is no corresponding
4527 scripts available yet for doing restoration of files. Even if there is
4528 a good chance those scripts may be satisfying to you, they are not the
4529 only scripts or methods available for doing backups and restore. You may
4530 well create your own, or use more sophisticated packages dedicated to
4533 Some users are enthusiastic about @code{Amanda} (The Advanced Maryland
4534 Automatic Network Disk Archiver), a backup system developed by James
4535 da Silva @file{jds@@cs.umd.edu} and available on many Unix systems.
4536 This is free software, and it is available at these places:
4539 http://www.cs.umd.edu/projects/amanda/amanda.html
4540 ftp://ftp.cs.umd.edu/pub/amanda
4545 Here is a possible plan for a future documentation about the backuping
4546 scripts which are provided within the @sc{gnu} @command{tar} distribution.
4552 . + different levels of dumps
4553 . - full dump = dump everything
4554 . - level 1, level 2 dumps etc, -
4555 A level n dump dumps everything changed since the last level
4558 . + how to use scripts for dumps (ie, the concept)
4559 . - scripts to run after editing backup specs (details)
4561 . + Backup Specs, what is it.
4562 . - how to customize
4563 . - actual text of script [/sp/dump/backup-specs]
4566 . - rsh doesn't work
4567 . - rtape isn't installed
4570 . + the --incremental option of tar
4573 . - write protection
4575 . : different sizes and types, useful for different things
4576 . - files and tape marks
4577 one tape mark between files, two at end.
4578 . - positioning the tape
4579 MT writes two at end of write,
4580 backspaces over one when writing again.
4585 This chapter documents both the provided FSF scripts and @command{tar}
4586 options which are more specific to usage as a backup tool.
4588 To @dfn{back up} a file system means to create archives that contain
4589 all the files in that file system. Those archives can then be used to
4590 restore any or all of those files (for instance if a disk crashes or a
4591 file is accidentally deleted). File system @dfn{backups} are also
4595 * Full Dumps:: Using @command{tar} to Perform Full Dumps
4596 * Inc Dumps:: Using @command{tar} to Perform Incremental Dumps
4597 * incremental and listed-incremental:: The Incremental Options
4598 * Backup Levels:: Levels of Backups
4599 * Backup Parameters:: Setting Parameters for Backups and Restoration
4600 * Scripted Backups:: Using the Backup Scripts
4601 * Scripted Restoration:: Using the Restore Script
4605 @section Using @command{tar} to Perform Full Dumps
4611 @cindex corrupted archives
4612 Full dumps should only be made when no other people or programs
4613 are modifying files in the filesystem. If files are modified while
4614 @command{tar} is making the backup, they may not be stored properly in
4615 the archive, in which case you won't be able to restore them if you
4616 have to. (Files not being modified are written with no trouble, and do
4617 not corrupt the entire archive.)
4619 You will want to use the @value{op-label} option to give the archive a
4620 volume label, so you can tell what this archive is even if the label
4621 falls off the tape, or anything like that.
4623 Unless the filesystem you are dumping is guaranteed to fit on
4624 one volume, you will need to use the @value{op-multi-volume} option.
4625 Make sure you have enough tapes on hand to complete the backup.
4627 If you want to dump each filesystem separately you will need to use
4628 the @value{op-one-file-system} option to prevent @command{tar} from crossing
4629 filesystem boundaries when storing (sub)directories.
4631 The @value{op-incremental} option is not needed, since this is a complete
4632 copy of everything in the filesystem, and a full restore from this
4633 backup would only be done onto a completely empty disk.
4635 Unless you are in a hurry, and trust the @command{tar} program (and your
4636 tapes), it is a good idea to use the @value{op-verify} option, to make
4637 sure your files really made it onto the dump properly. This will
4638 also detect cases where the file was modified while (or just after)
4639 it was being archived. Not all media (notably cartridge tapes) are
4640 capable of being verified, unfortunately.
4642 @value{op-listed-incremental} take a file name argument always. If the
4643 file doesn't exist, run a level zero dump, creating the file. If the
4644 file exists, uses that file to see what has changed.
4646 @value{op-incremental} @FIXME{look it up}
4648 @value{op-incremental} handle old @sc{gnu}-format incremental backup.
4650 This option should only be used when creating an incremental backup of
4651 a filesystem. When the @value{op-incremental} option is used, @command{tar}
4652 writes, at the beginning of the archive, an entry for each of the
4653 directories that will be operated on. The entry for a directory
4654 includes a list of all the files in the directory at the time the
4655 dump was done, and a flag for each file indicating whether the file
4656 is going to be put in the archive. This information is used when
4657 doing a complete incremental restore.
4659 Note that this option causes @command{tar} to create a non-standard
4660 archive that may not be readable by non-@sc{gnu} versions of the @command{tar}
4663 The @value{op-incremental} option means the archive is an incremental
4664 backup. Its meaning depends on the command that it modifies.
4666 If the @value{op-incremental} option is used with @value{op-list}, @command{tar}
4667 will list, for each directory in the archive, the list of files in
4668 that directory at the time the archive was created. This information
4669 is put out in a format that is not easy for humans to read, but which
4670 is unambiguous for a program: each file name is preceded by either a
4671 @samp{Y} if the file is present in the archive, an @samp{N} if the
4672 file is not included in the archive, or a @samp{D} if the file is
4673 a directory (and is included in the archive). Each file name is
4674 terminated by a null character. The last file is followed by an
4675 additional null and a newline to indicate the end of the data.
4677 If the @value{op-incremental} option is used with @value{op-extract}, then
4678 when the entry for a directory is found, all files that currently
4679 exist in that directory but are not listed in the archive @emph{are
4680 deleted from the directory}.
4682 This behavior is convenient when you are restoring a damaged file
4683 system from a succession of incremental backups: it restores the
4684 entire state of the file system to that which obtained when the backup
4685 was made. If you don't use @value{op-incremental}, the file system will
4686 probably fill up with files that shouldn't exist any more.
4688 @value{op-listed-incremental} handle new @sc{gnu}-format incremental backup.
4689 This option handles new @sc{gnu}-format incremental backup. It has much the
4690 same effect as @value{op-incremental}, but also the time when the dump
4691 is done and the list of directories dumped is written to the given
4692 @var{file}. When restoring, only files newer than the saved time are
4693 restored, and the directory list is used to speed up operations.
4695 @value{op-listed-incremental} acts like @value{op-incremental}, but when
4696 used in conjunction with @value{op-create} will also cause @command{tar} to
4697 use the file @var{file}, which contains information about the state
4698 of the filesystem at the time of the last backup, to decide which
4699 files to include in the archive being created. That file will then
4700 be updated by @command{tar}. If the file @var{file} does not exist when
4701 this option is specified, @command{tar} will create it, and include all
4702 appropriate files in the archive.
4704 The file, which is archive independent, contains the date it was last
4705 modified and a list of devices, inode numbers and directory names.
4706 @command{tar} will archive files with newer mod dates or inode change
4707 times, and directories with an unchanged inode number and device but
4708 a changed directory name. The file is updated after the files to
4709 be archived are determined, but before the new archive is actually
4712 @sc{gnu} @command{tar} actually writes the file twice: once before the data
4713 and written, and once after.
4716 @section Using @command{tar} to Perform Incremental Dumps
4719 @cindex incremental dumps
4720 @cindex dumps, incremental
4722 Performing incremental dumps is similar to performing full dumps,
4723 although a few more options will usually be needed.
4725 A standard scheme is to do a @emph{monthly} (full) dump once a month,
4726 a @emph{weekly} dump once a week of everything since the last monthly
4727 and a @emph{daily} every day of everything since the last (weekly or
4730 Here is a sample script to dump the directory hierarchies @samp{/usr}
4736 --blocking-factor=126 \
4738 --label="`hostname` /usr /var `date +%Y-%m-%d`" \
4739 --listed-incremental=/var/log/usr-var.snar \
4744 This script uses the file @file{/var/log/usr-var.snar} as a snapshot to
4745 store information about the previous tar dump.
4747 The blocking factor 126 is an attempt to make the tape drive stream.
4748 Some tape devices cannot handle 64 kB blocks or larger, and require the
4749 block size to be a multiple of 1 kB; for these devices, 126 is the
4750 largest blocking factor that can be used.
4752 @node incremental and listed-incremental
4753 @section The Incremental Options
4756 @value{op-incremental} is used in conjunction with @value{op-create},
4757 @value{op-extract} or @value{op-list} when backing up and restoring file
4758 systems. An archive cannot be extracted or listed with the
4759 @value{op-incremental} option specified unless it was created with the
4760 option specified. This option should only be used by a script, not by
4761 the user, and is usually disregarded in favor of
4762 @value{op-listed-incremental}, which is described below.
4764 @value{op-incremental} in conjunction with @value{op-create} causes
4765 @command{tar} to write, at the beginning of the archive, an entry for
4766 each of the directories that will be archived. The entry for a
4767 directory includes a list of all the files in the directory at the
4768 time the archive was created and a flag for each file indicating
4769 whether or not the file is going to be put in the archive.
4771 Note that this option causes @command{tar} to create a non-standard
4772 archive that may not be readable by non-@sc{gnu} versions of the @command{tar}
4775 @value{op-incremental} in conjunction with @value{op-extract} causes
4776 @command{tar} to read the lists of directory contents previously stored
4777 in the archive, @emph{delete} files in the file system that did not
4778 exist in their directories when the archive was created, and then
4779 extract the files in the archive.
4781 This behavior is convenient when restoring a damaged file system from
4782 a succession of incremental backups: it restores the entire state of
4783 the file system to that which obtained when the backup was made. If
4784 @value{op-incremental} isn't specified, the file system will probably
4785 fill up with files that shouldn't exist any more.
4787 @value{op-incremental} in conjunction with @value{op-list} causes
4788 @command{tar} to print, for each directory in the archive, the list of
4789 files in that directory at the time the archive was created. This
4790 information is put out in a format that is not easy for humans to
4791 read, but which is unambiguous for a program: each file name is
4792 preceded by either a @samp{Y} if the file is present in the archive,
4793 an @samp{N} if the file is not included in the archive, or a @samp{D}
4794 if the file is a directory (and is included in the archive). Each
4795 file name is terminated by a null character. The last file is followed
4796 by an additional null and a newline to indicate the end of the data.
4798 @value{op-listed-incremental} acts like @value{op-incremental}, but when
4799 used in conjunction with @value{op-create} will also cause @command{tar}
4800 to use the file @var{snapshot-file}, which contains information about
4801 the state of the file system at the time of the last backup, to decide
4802 which files to include in the archive being created. That file will
4803 then be updated by @command{tar}. If the file @var{file} does not exist
4804 when this option is specified, @command{tar} will create it, and include
4805 all appropriate files in the archive.
4807 The file @var{file}, which is archive independent, contains the date
4808 it was last modified and a list of devices, inode numbers and
4809 directory names. @command{tar} will archive files with newer mod dates
4810 or inode change times, and directories with an unchanged inode number
4811 and device but a changed directory name. The file is updated after
4812 the files to be archived are determined, but before the new archive is
4815 Incremental dumps depend crucially on time stamps, so the results are
4816 unreliable if you modify a file's time stamps during dumping (e.g.@:
4817 with the @samp{--atime-preserve} option), or if you set the clock
4820 Despite it should be obvious that a device has a non-volatile value, NFS
4821 devices have non-dependable values when an automounter gets in the picture.
4822 This led to a great deal of spurious redumping in incremental dumps,
4823 so it is somewhat useless to compare two NFS devices numbers over time.
4824 So @command{tar} now considers all NFS devices as being equal when it comes
4825 to comparing directories; this is fairly gross, but there does not seem
4826 to be a better way to go.
4828 @FIXME{this section needs to be written}
4831 @section Levels of Backups
4834 An archive containing all the files in the file system is called a
4835 @dfn{full backup} or @dfn{full dump}. You could insure your data by
4836 creating a full dump every day. This strategy, however, would waste a
4837 substantial amount of archive media and user time, as unchanged files
4838 are daily re-archived.
4840 It is more efficient to do a full dump only occasionally. To back up
4841 files between full dumps, you can a incremental dump. A @dfn{level
4842 one} dump archives all the files that have changed since the last full
4845 A typical dump strategy would be to perform a full dump once a week,
4846 and a level one dump once a day. This means some versions of files
4847 will in fact be archived more than once, but this dump strategy makes
4848 it possible to restore a file system to within one day of accuracy by
4849 only extracting two archives---the last weekly (full) dump and the
4850 last daily (level one) dump. The only information lost would be in
4851 files changed or created since the last daily backup. (Doing dumps
4852 more than once a day is usually not worth the trouble).
4854 @sc{gnu} @command{tar} comes with scripts you can use to do full and level-one
4855 dumps. Using scripts (shell programs) to perform backups and
4856 restoration is a convenient and reliable alternative to typing out
4857 file name lists and @command{tar} commands by hand.
4859 Before you use these scripts, you need to edit the file
4860 @file{backup-specs}, which specifies parameters used by the backup
4861 scripts and by the restore script. @FIXME{There is no such restore
4862 script!}@FIXME-xref{Script Syntax}Once the backup parameters
4863 are set, you can perform backups or restoration by running the
4866 The name of the restore script is @code{restore}. @FIXME{There is
4867 no such restore script!}The names of the level one and full backup
4868 scripts are, respectively, @code{level-1} and @code{level-0}.
4869 The @code{level-0} script also exists under the name @code{weekly}, and
4870 the @code{level-1} under the name @code{daily}---these additional names
4871 can be changed according to your backup schedule. @FIXME-xref{Scripted
4872 Restoration, for more information on running the restoration script.}
4873 @FIXME-xref{Scripted Backups, for more information on running the
4876 @emph{Please Note:} The backup scripts and the restoration scripts are
4877 designed to be used together. While it is possible to restore files by
4878 hand from an archive which was created using a backup script, and to create
4879 an archive by hand which could then be extracted using the restore script,
4880 it is easier to use the scripts.@FIXME{There is no such restore script!}
4881 @value{xref-incremental}, and @value{xref-listed-incremental},
4882 before making such an attempt.
4884 @FIXME{shorten node names}
4886 @node Backup Parameters
4887 @section Setting Parameters for Backups and Restoration
4890 The file @file{backup-specs} specifies backup parameters for the
4891 backup and restoration scripts provided with @command{tar}. You must
4892 edit @file{backup-specs} to fit your system configuration and schedule
4893 before using these scripts.
4895 @FIXME{This about backup scripts needs to be written: BS is a shell
4896 script .... thus ... @file{backup-specs} is in shell script syntax.}
4898 @FIXME-xref{Script Syntax, for an explanation of this syntax.}
4900 @FIXME{Whats a parameter .... looked at by the backup scripts
4901 ... which will be expecting to find ... now syntax ... value is linked
4902 to lame ... @file{backup-specs} specifies the following parameters:}
4906 The user name of the backup administrator.
4909 The hour at which the backups are done. This can be a number from 0
4910 to 23, or the string @samp{now}.
4913 The device @command{tar} writes the archive to. This device should be
4914 attached to the host on which the dump scripts are run.
4916 @FIXME{examples for all ...}
4919 The command to use to obtain the status of the archive device,
4920 including error count. On some tape drives there may not be such a
4921 command; in that case, simply use @samp{TAPE_STATUS=false}.
4924 The blocking factor @command{tar} will use when writing the dump archive.
4925 @value{xref-blocking-factor}.
4928 A list of file systems to be dumped. You can include any directory
4929 name in the list---subdirectories on that file system will be
4930 included, regardless of how they may look to other networked machines.
4931 Subdirectories on other file systems will be ignored.
4933 The host name specifies which host to run @command{tar} on, and should
4934 normally be the host that actually contains the file system. However,
4935 the host machine must have @sc{gnu} @command{tar} installed, and must be able
4936 to access the directory containing the backup scripts and their
4937 support files using the same file name that is used on the machine
4938 where the scripts are run (ie. what @command{pwd} will print when in that
4939 directory on that machine). If the host that contains the file system
4940 does not have this capability, you can specify another host as long as
4941 it can access the file system through NFS.
4944 A list of individual files to be dumped. These should be accessible
4945 from the machine on which the backup script is run.
4947 @FIXME{Same file name, be specific. Through NFS ...}
4952 * backup-specs example:: An Example Text of @file{Backup-specs}
4953 * Script Syntax:: Syntax for @file{Backup-specs}
4956 @node backup-specs example
4957 @subsection An Example Text of @file{Backup-specs}
4960 The following is the text of @file{backup-specs} as it appears at FSF:
4963 # site-specific parameters for file system backup.
4965 ADMINISTRATOR=friedman
4967 TAPE_FILE=/dev/nrsmt0
4968 TAPE_STATUS="mts -t $TAPE_FILE"
4983 apple-gunkies:/com/mailer/gnu
4984 apple-gunkies:/com/archive/gnu"
4986 BACKUP_FILES="/com/mailer/aliases /com/mailer/league*[a-z]"
4991 @subsection Syntax for @file{Backup-specs}
4994 @file{backup-specs} is in shell script syntax. The following
4995 conventions should be considered when editing the script:
4996 @FIXME{"conventions?"}
4998 A quoted string is considered to be contiguous, even if it is on more
4999 than one line. Therefore, you cannot include commented-out lines
5000 within a multi-line quoted string. BACKUP_FILES and BACKUP_DIRS are
5001 the two most likely parameters to be multi-line.
5003 A quoted string typically cannot contain wildcards. In
5004 @file{backup-specs}, however, the parameters BACKUP_DIRS and
5005 BACKUP_FILES can contain wildcards.
5007 @node Scripted Backups
5008 @section Using the Backup Scripts
5011 The syntax for running a backup script is:
5014 @file{script-name} [@var{time-to-be-run}]
5017 where @var{time-to-be-run} can be a specific system time, or can be
5018 @kbd{now}. If you do not specify a time, the script runs at the time
5019 specified in @file{backup-specs}. @FIXME-pxref{Script Syntax}
5021 You should start a script with a tape or disk mounted. Once you
5022 start a script, it prompts you for new tapes or disks as it
5023 needs them. Media volumes don't have to correspond to archive
5024 files---a multi-volume archive can be started in the middle of a
5025 tape that already contains the end of another multi-volume archive.
5026 The @code{restore} script prompts for media by its archive volume,
5027 so to avoid an error message you should keep track of which tape
5028 (or disk) contains which volume of the archive. @FIXME{There is
5029 no such restore script!} @FIXME-xref{Scripted Restoration}
5030 @FIXME{Have file names changed?}
5032 The backup scripts write two files on the file system. The first is a
5033 record file in @file{/etc/tar-backup/}, which is used by the scripts
5034 to store and retrieve information about which files were dumped. This
5035 file is not meant to be read by humans, and should not be deleted by
5036 them. @FIXME-xref{incremental and listed-incremental, for a more
5037 detailed explanation of this file.}
5039 The second file is a log file containing the names of the file systems
5040 and files dumped, what time the backup was made, and any error
5041 messages that were generated, as well as how much space was left in
5042 the media volume after the last volume of the archive was written.
5043 You should check this log file after every backup. The file name is
5044 @file{log-@var{mmm-ddd-yyyy}-level-1} or
5045 @file{log-@var{mmm-ddd-yyyy}-full}.
5047 The script also prints the name of each system being dumped to the
5050 @node Scripted Restoration
5051 @section Using the Restore Script
5056 The @command{tar} distribution does not provide restoring scripts.
5063 @strong{Warning:} The @sc{gnu} @command{tar} distribution does @emph{not}
5064 provide any such @code{restore} script yet. This section is only
5065 listed here for documentation maintenance purposes. In any case,
5066 all contents is subject to change as things develop.
5069 @FIXME{A section on non-scripted restore may be a good idea.}
5071 To restore files that were archived using a scripted backup, use the
5072 @code{restore} script. The syntax for the script is:
5074 where ***** are the file systems to restore from, and
5075 ***** is a regular expression which specifies which files to
5076 restore. If you specify --all, the script restores all the files
5079 You should start the restore script with the media containing the
5080 first volume of the archive mounted. The script will prompt for other
5081 volumes as they are needed. If the archive is on tape, you don't need
5082 to rewind the tape to to its beginning---if the tape head is
5083 positioned past the beginning of the archive, the script will rewind
5084 the tape as needed. @FIXME-xref{Media, for a discussion of tape
5087 If you specify @samp{--all} as the @var{files} argument, the
5088 @code{restore} script extracts all the files in the archived file
5089 system into the active file system.
5092 @strong{Warning:} The script will delete files from the active file
5093 system if they were not in the file system when the archive was made.
5096 @value{xref-incremental}, and @value{ref-listed-incremental},
5097 for an explanation of how the script makes that determination.
5099 @FIXME{this may be an option, not a given}
5104 @chapter Choosing Files and Names for @command{tar}
5107 @FIXME{Melissa (still) Doesn't Really Like This ``Intro'' Paragraph!!!}
5109 Certain options to @command{tar} enable you to specify a name for your
5110 archive. Other options let you decide which files to include or exclude
5111 from the archive, based on when or whether files were modified, whether
5112 the file names do or don't match specified patterns, or whether files
5113 are in specified directories.
5116 * file:: Choosing the Archive's Name
5117 * Selecting Archive Members::
5118 * files:: Reading Names from a File
5119 * exclude:: Excluding Some Files
5121 * after:: Operating Only on New Files
5122 * recurse:: Descending into Directories
5123 * one:: Crossing Filesystem Boundaries
5127 @section Choosing and Naming Archive Files
5128 @cindex Naming an archive
5129 @cindex Archive Name
5130 @cindex Directing output
5131 @cindex Choosing an archive file
5132 @cindex Where is the archive?
5135 @FIXME{should the title of this section actually be, "naming an
5138 By default, @command{tar} uses an archive file name that was compiled when
5139 it was built on the system; usually this name refers to some physical
5140 tape drive on the machine. However, the person who installed @command{tar}
5141 on the system may not set the default to a meaningful value as far as
5142 most users are concerned. As a result, you will usually want to tell
5143 @command{tar} where to find (or create) the archive. The @value{op-file}
5144 option allows you to either specify or name a file to use as the archive
5145 instead of the default archive file location.
5148 @item --file=@var{archive-name}
5149 @itemx -f @var{archive-name}
5150 Name the archive to create or operate on. Use in conjunction with
5154 For example, in this @command{tar} command,
5157 $ @kbd{tar -cvf collection.tar blues folk jazz}
5161 @file{collection.tar} is the name of the archive. It must directly
5162 follow the @samp{-f} option, since whatever directly follows @samp{-f}
5163 @emph{will} end up naming the archive. If you neglect to specify an
5164 archive name, you may end up overwriting a file in the working directory
5165 with the archive you create since @command{tar} will use this file's name
5166 for the archive name.
5168 An archive can be saved as a file in the file system, sent through a
5169 pipe or over a network, or written to an I/O device such as a tape,
5170 floppy disk, or CD write drive.
5172 @cindex Writing new archives
5173 @cindex Archive creation
5174 If you do not name the archive, @command{tar} uses the value of the
5175 environment variable @env{TAPE} as the file name for the archive. If
5176 that is not available, @command{tar} uses a default, compiled-in archive
5177 name, usually that for tape unit zero (ie. @file{/dev/tu00}).
5178 @command{tar} always needs an archive name.
5180 If you use @file{-} as an @var{archive-name}, @command{tar} reads the
5181 archive from standard input (when listing or extracting files), or
5182 writes it to standard output (when creating an archive). If you use
5183 @file{-} as an @var{archive-name} when modifying an archive,
5184 @command{tar} reads the original archive from its standard input and
5185 writes the entire new archive to its standard output.
5187 @FIXME{might want a different example here; this is already used in
5188 "notable tar usages".}
5191 $ @kbd{cd sourcedir; tar -cf - . | (cd targetdir; tar -xf -)}
5196 @cindex Standard input and output
5197 @cindex tar to standard input and output
5198 To specify an archive file on a device attached to a remote machine,
5202 @kbd{--file=@var{hostname}:/@var{dev}/@var{file name}}
5206 @command{tar} will complete the remote connection, if possible, and
5207 prompt you for a username and password. If you use
5208 @samp{--file=@@@var{hostname}:/@var{dev}/@var{file name}}, @command{tar}
5209 will complete the remote connection, if possible, using your username
5210 as the username on the remote machine.
5212 If the archive file name includes a colon (@samp{:}), then it is assumed
5213 to be a file on another machine. If the archive file is
5214 @samp{@var{user}@@@var{host}:@var{file}}, then @var{file} is used on the
5215 host @var{host}. The remote host is accessed using the @command{rsh}
5216 program, with a username of @var{user}. If the username is omitted
5217 (along with the @samp{@@} sign), then your user name will be used.
5218 (This is the normal @command{rsh} behavior.) It is necessary for the
5219 remote machine, in addition to permitting your @command{rsh} access, to
5220 have the @file{/usr/ucb/rmt} program installed. If you need to use a
5221 file whose name includes a colon, then the remote tape drive behavior
5222 can be inhibited by using the @value{op-force-local} option.
5224 @FIXME{i know we went over this yesterday, but bob (and now i do again,
5225 too) thinks it's out of the middle of nowhere. it doesn't seem to tie
5226 into what came before it well enough <<i moved it now, is it better
5227 here?>>. bob also comments that if Amanda isn't free software, we
5228 shouldn't mention it..}
5230 When the archive is being created to @file{/dev/null}, @sc{gnu} @command{tar}
5231 tries to minimize input and output operations. The Amanda backup
5232 system, when used with @sc{gnu} @command{tar}, has an initial sizing pass which
5235 @node Selecting Archive Members
5236 @section Selecting Archive Members
5237 @cindex Specifying files to act on
5238 @cindex Specifying archive members
5240 @dfn{File Name arguments} specify which files in the file system
5241 @command{tar} operates on, when creating or adding to an archive, or which
5242 archive members @command{tar} operates on, when reading or deleting from
5243 an archive. @xref{Operations}.
5245 To specify file names, you can include them as the last arguments on
5246 the command line, as follows:
5248 @kbd{tar} @var{operation} [@var{option1} @var{option2} @dots{}] [@var{file name-1} @var{file name-2} @dots{}]
5251 If you specify a directory name as a file name argument, all the files
5252 in that directory are operated on by @command{tar}.
5254 If you do not specify files when @command{tar} is invoked with
5255 @value{op-create}, @command{tar} operates on all the non-directory files in
5256 the working directory. If you specify either @value{op-list} or
5257 @value{op-extract}, @command{tar} operates on all the archive members in the
5258 archive. If you specify any operation other than one of these three,
5259 @command{tar} does nothing.
5261 By default, @command{tar} takes file names from the command line. However,
5262 there are other ways to specify file or member names, or to modify the
5263 manner in which @command{tar} selects the files or members upon which to
5264 operate. @FIXME{add xref here}In general, these methods work both for
5265 specifying the names of files and archive members.
5268 @section Reading Names from a File
5271 @cindex Reading file names from a file
5272 @cindex Lists of file names
5273 @cindex File Name arguments, alternatives
5274 Instead of giving the names of files or archive members on the command
5275 line, you can put the names into a file, and then use the
5276 @value{op-files-from} option to @command{tar}. Give the name of the file
5277 which contains the list of files to include as the argument to
5278 @samp{--files-from}. In the list, the file names should be separated by
5279 newlines. You will frequently use this option when you have generated
5280 the list of files to archive with the @command{find} utility.
5283 @item --files-from=@var{file name}
5284 @itemx -I @var{file name}
5285 @itemx -T @var{file name}
5286 Get names to extract or create from file @var{file name}.
5289 If you give a single dash as a file name for @samp{--files-from}, (i.e.,
5290 you specify either @samp{--files-from=-} or @samp{-I -}) or @samp{-T
5291 -}), then the file names are read from standard input.
5293 Unless you are running @command{tar} with @samp{--create}, you can not use
5294 both @samp{--files-from=-} and @samp{--file=-} (@samp{-f -}) in the same
5297 @FIXME{add bob's example, from his message on 2-10-97}
5299 The following example shows how to use @command{find} to generate a list of
5300 files smaller than 400K in length and put that list into a file
5301 called @file{small-files}. You can then use the @samp{-T} option to
5302 @command{tar} to specify the files from that file, @file{small-files}, to
5303 create the archive @file{little.tgz}. (The @samp{-z} option to
5304 @command{tar} compresses the archive with @command{gzip}; @pxref{gzip} for
5308 $ @kbd{find . -size -400 -print > small-files}
5309 $ @kbd{tar -c -v -z -T small-files -f little.tgz}
5313 @FIXME{say more here to conclude the example/section?}
5320 @subsection @kbd{NUL} Terminated File Names
5322 @cindex File names, terminated by @kbd{NUL}
5323 @cindex @kbd{NUL} terminated file names
5324 The @value{op-null} option causes @value{op-files-from} to read file
5325 names terminated by a @code{NUL} instead of a newline, so files whose
5326 names contain newlines can be archived using @samp{--files-from}.
5330 Only consider @kbd{NUL} terminated file names, instead of files that
5331 terminate in a newline.
5334 The @samp{--null} option is just like the one in @sc{gnu} @command{xargs} and
5335 @command{cpio}, and is useful with the @samp{-print0} predicate of @sc{gnu}
5336 @command{find}. In @command{tar}, @samp{--null} also causes
5337 @value{op-directory} options to be treated as file names to archive, in
5338 case there are any files out there called @file{-C}.
5340 This example shows how to use @command{find} to generate a list of files
5341 larger than 800K in length and put that list into a file called
5342 @file{long-files}. The @samp{-print0} option to @command{find} just just
5343 like @samp{-print}, except that it separates files with a @kbd{NUL}
5344 rather than with a newline. You can then run @command{tar} with both the
5345 @samp{--null} and @samp{-T} options to specify that @command{tar} get the
5346 files from that file, @file{long-files}, to create the archive
5347 @file{big.tgz}. The @samp{--null} option to @command{tar} will cause
5348 @command{tar} to recognize the @kbd{NUL} separator between files.
5351 $ @kbd{find . -size +800 -print0 > long-files}
5352 $ @kbd{tar -c -v --null --files-from=long-files --file=big.tar}
5355 @FIXME{say anything else here to conclude the section?}
5358 @section Excluding Some Files
5359 @cindex File names, excluding files by
5360 @cindex Excluding files by name and pattern
5361 @cindex Excluding files by file system
5364 To avoid operating on files whose names match a particular pattern,
5365 use the @value{op-exclude} or @value{op-exclude-from} options.
5368 @item --exclude=@var{pattern}
5369 Causes @command{tar} to ignore files that match the @var{pattern}.
5373 The @value{op-exclude} option prevents any file or member whose name
5374 matches the shell wildcard (@var{pattern}) from being operated on.
5375 For example, to create an archive with all the contents of the directory
5376 @file{src} except for files whose names end in @file{.o}, use the
5377 command @samp{tar -cf src.tar --exclude='*.o' src}.
5379 A @var{pattern} containing @samp{/} excludes a name if an initial
5380 subsequence of the name's components matches @var{pattern}; a
5381 @var{pattern} without @samp{/} excludes a name if it matches any of its
5382 name components. For example, the pattern @samp{*b/RCS} contains
5383 @samp{/}, so it excludes @file{blob/RCS} and @file{.blob/RCS/f} but not
5384 @file{blob/RCSit/RCS} or @file{/blob/RCS}, whereas the pattern
5385 @samp{RCS} excludes all these names. Conversely, the pattern @samp{*.o}
5386 lacks @samp{/}, so it excludes @file{.f.o}, @file{d/f.o}, and
5389 Other than optionally stripping leading @samp{/} from names
5390 (@pxref{absolute}), patterns and candidate names are used as-is. For
5391 example, trailing @samp{/} is not trimmed from a user-specified name
5392 before deciding whether to exclude it.
5394 You may give multiple @samp{--exclude} options.
5397 @item --exclude-from=@var{file}
5398 @itemx -X @var{file}
5399 Causes @command{tar} to ignore files that match the patterns listed in
5403 @findex exclude-from
5404 Use the @samp{--exclude-from=@var{file-of-patterns}} option to read a
5405 list of shell wildcards, one per line, from @var{file}; @command{tar} will
5406 ignore files matching those regular expressions. Thus if @command{tar} is
5407 called as @w{@samp{tar -c -X foo .}} and the file @file{foo} contains a
5408 single line @file{*.o}, no files whose names end in @file{.o} will be
5409 added to the archive.
5411 @FIXME{do the exclude options files need to have stuff separated by
5412 newlines the same as the files-from option does?}
5415 * problems with exclude::
5418 @node problems with exclude
5419 @unnumberedsubsec Problems with Using the @code{exclude} Options
5421 Some users find @samp{exclude} options confusing. Here are some common
5426 The main operating mode of @command{tar} does not act on a path name
5427 explicitly listed on the command line if one of its file name
5428 components is excluded. In the example above, if
5429 you create an archive and exclude files that end with @samp{*.o}, but
5430 explicitly name the file @samp{dir.o/foo} after all the options have been
5431 listed, @samp{dir.o/foo} will be excluded from the archive.
5434 You can sometimes confuse the meanings of @value{op-exclude} and
5435 @value{op-exclude-from}. Be careful: use @value{op-exclude} when files
5436 to be excluded are given as a pattern on the command line. Use
5437 @samp{--exclude-from=@var{file-of-patterns}} to introduce the name of a
5438 file which contains a list of patterns, one per line; each of these
5439 patterns can exclude zero, one, or many files.
5442 When you use @value{op-exclude}, be sure to quote the @var{pattern}
5443 parameter, so @sc{gnu} @command{tar} sees wildcard characters like @samp{*}.
5444 If you do not do this, the shell might expand the @samp{*} itself
5445 using files at hand, so @command{tar} might receive a list of files
5446 instead of one pattern, or none at all, making the command somewhat
5447 illegal. This might not correspond to what you want.
5452 $ @kbd{tar -c -f @var{archive.tar} --exclude '*.o' @var{directory}}
5459 $ @kbd{tar -c -f @var{archive.tar} --exclude *.o @var{directory}}
5463 You must use use shell syntax, or globbing, rather than @code{regexp}
5464 syntax, when using exclude options in @command{tar}. If you try to use
5465 @code{regexp} syntax to describe files to be excluded, your command
5469 In earlier versions of @command{tar}, what is now the
5470 @samp{--exclude-from=@var{file-of-patterns}} option was called
5471 @samp{--exclude=@var{pattern}} instead. Now,
5472 @samp{--exclude=@var{pattern}} applies to patterns listed on the command
5473 line and @samp{--exclude-from=@var{file-of-patterns}} applies to
5474 patterns listed in a file.
5479 @section Wildcards Patterns and Matching
5481 @dfn{Globbing} is the operation by which @dfn{wildcard} characters,
5482 @samp{*} or @samp{?} for example, are replaced and expanded into all
5483 existing files matching the given pattern. However, @command{tar} often
5484 uses wildcard patterns for matching (or globbing) archive members instead
5485 of actual files in the filesystem. Wildcard patterns are also used for
5486 verifying volume labels of @command{tar} archives. This section has the
5487 purpose of explaining wildcard syntax for @command{tar}.
5489 @FIXME{the next few paragraphs need work.}
5491 A @var{pattern} should be written according to shell syntax, using wildcard
5492 characters to effect globbing. Most characters in the pattern stand
5493 for themselves in the matched string, and case is significant: @samp{a}
5494 will match only @samp{a}, and not @samp{A}. The character @samp{?} in the
5495 pattern matches any single character in the matched string. The character
5496 @samp{*} in the pattern matches zero, one, or more single characters in
5497 the matched string. The character @samp{\} says to take the following
5498 character of the pattern @emph{literally}; it is useful when one needs to
5499 match the @samp{?}, @samp{*}, @samp{[} or @samp{\} characters, themselves.
5501 The character @samp{[}, up to the matching @samp{]}, introduces a character
5502 class. A @dfn{character class} is a list of acceptable characters
5503 for the next single character of the matched string. For example,
5504 @samp{[abcde]} would match any of the first five letters of the alphabet.
5505 Note that within a character class, all of the ``special characters''
5506 listed above other than @samp{\} lose their special meaning; for example,
5507 @samp{[-\\[*?]]} would match any of the characters, @samp{-}, @samp{\},
5508 @samp{[}, @samp{*}, @samp{?}, or @samp{]}. (Due to parsing constraints,
5509 the characters @samp{-} and @samp{]} must either come @emph{first} or
5510 @emph{last} in a character class.)
5512 @cindex Excluding characters from a character class
5513 @cindex Character class, excluding characters from
5514 If the first character of the class after the opening @samp{[}
5515 is @samp{!} or @samp{^}, then the meaning of the class is reversed.
5516 Rather than listing character to match, it lists those characters which
5517 are @emph{forbidden} as the next single character of the matched string.
5519 Other characters of the class stand for themselves. The special
5520 construction @samp{[@var{a}-@var{e}]}, using an hyphen between two
5521 letters, is meant to represent all characters between @var{a} and
5524 @FIXME{need to add a sentence or so here to make this clear for those
5525 who don't have dan around.}
5527 Periods (@samp{.}) or forward slashes (@samp{/}) are not considered
5528 special for wildcard matches. However, if a pattern completely matches
5529 a directory prefix of a matched string, then it matches the full matched
5530 string: excluding a directory also excludes all the files beneath it.
5532 There are some discussions floating in the air and asking for modifications
5533 in the way @sc{gnu} @command{tar} accomplishes wildcard matches. We perceive
5534 any change of semantics in this area as a delicate thing to impose on
5535 @sc{gnu} @command{tar} users. On the other hand, the @sc{gnu} project should be
5536 progressive enough to correct any ill design: compatibility at all price
5537 is not always a good attitude. In conclusion, it is @emph{possible}
5538 that slight amendments be later brought to the previous description.
5539 Your opinions on the matter are welcome.
5542 @section Operating Only on New Files
5543 @cindex Excluding file by age
5544 @cindex Modification time, excluding files by
5545 @cindex Age, excluding files by
5548 The @value{op-after-date} option causes @command{tar} to only work on files
5549 whose modification or inode-changed times are newer than the @var{date}
5550 given. If you use this option when creating or appending to an archive,
5551 the archive will only include new files. If you use @samp{--after-date}
5552 when extracting an archive, @command{tar} will only extract files newer
5553 than the @var{date} you specify.
5555 If you only want @command{tar} to make the date comparison based on
5556 modification of the actual contents of the file (rather than inode
5557 changes), then use the @value{op-newer-mtime} option.
5559 You may use these options with any operation. Note that these options
5560 differ from the @value{op-update} operation in that they allow you to
5561 specify a particular date against which @command{tar} can compare when
5562 deciding whether or not to archive the files.
5565 @item --after-date=@var{date}
5566 @itemx --newer=@var{date}
5567 @itemx -N @var{date}
5568 Only store files newer than @var{date}.
5570 Acts on files only if their modification or inode-changed times are
5571 later than @var{date}. Use in conjunction with any operation.
5573 @item --newer-mtime=@var{date}
5574 Acts like @value{op-after-date}, but only looks at modification times.
5577 These options limit @command{tar} to only operating on files which have
5578 been modified after the date specified. A file is considered to have
5579 changed if the contents have been modified, or if the owner,
5580 permissions, and so forth, have been changed. (For more information on
5581 how to specify a date, see @ref{Date input formats}; remember that the
5582 entire date argument must be quoted if it contains any spaces.)
5584 Gurus would say that @value{op-after-date} tests both the @code{mtime}
5585 (time the contents of the file were last modified) and @code{ctime}
5586 (time the file's status was last changed: owner, permissions, etc)
5587 fields, while @value{op-newer-mtime} tests only @code{mtime} field.
5589 To be precise, @value{op-after-date} checks @emph{both} @code{mtime} and
5590 @code{ctime} and processes the file if either one is more recent than
5591 @var{date}, while @value{op-newer-mtime} only checks @code{mtime} and
5592 disregards @code{ctime}. Neither uses @code{atime} (the last time the
5593 contents of the file were looked at).
5595 Date specifiers can have embedded spaces. Because of this, you may need
5596 to quote date arguments to keep the shell from parsing them as separate
5599 @FIXME{Need example of --newer-mtime with quoted argument.}
5602 @strong{Please Note:} @value{op-after-date} and @value{op-newer-mtime}
5603 should not be used for incremental backups. Some files (such as those
5604 in renamed directories) are not selected properly by these options.
5605 @xref{incremental and listed-incremental}.
5608 To select files newer than the modification time of a file that already
5609 exists, you can use the @samp{--reference} (@samp{-r}) option of @sc{gnu}
5610 @command{date}, available in @sc{gnu} shell utilities 1.13 or later. It returns
5611 the time stamp of the already-existing file; this time stamp expands to
5612 become the referent date which @samp{--newer} uses to determine which
5613 files to archive. For example, you could say,
5616 $ @kbd{tar -cf @var{archive.tar} --newer="`date -r @var{file}`" /home}
5620 @FIXME{which tells -- need to fill this in!}
5623 @section Descending into Directories
5624 @cindex Avoiding recursion in directories
5625 @cindex Descending directories, avoiding
5626 @cindex Directories, avoiding recursion
5627 @cindex Recursion in directories, avoiding
5630 @FIXME{arrggh! this is still somewhat confusing to me. :-< }
5632 @FIXME{show dan bob's comments, from 2-10-97}
5634 Usually, @command{tar} will recursively explore all directories (either
5635 those given on the command line or through the @value{op-files-from}
5636 option) for the various files they contain. However, you may not always
5637 want @command{tar} to act this way.
5639 The @value{op-no-recursion} option inhibits @command{tar}'s recursive descent
5640 into specified directories. If you specify @samp{--no-recursion}, you can
5641 use the @command{find} utility for hunting through levels of directories to
5642 construct a list of file names which you could then pass to @command{tar}.
5643 @command{find} allows you to be more selective when choosing which files to
5644 archive; see @ref{files} for more information on using @command{find} with
5645 @command{tar}, or look.
5648 @item --no-recursion
5649 Prevents @command{tar} from recursively descending directories.
5652 When you use @samp{--no-recursion}, @sc{gnu} @command{tar} grabs directory entries
5653 themselves, but does not descend on them recursively. Many people use
5654 @command{find} for locating files they want to back up, and since
5655 @command{tar} @emph{usually} recursively descends on directories, they have
5656 to use the @samp{@w{! -d}} option to @command{find} @FIXME{needs more
5657 explanation or a cite to another info file}as they usually do not want
5658 all the files in a directory. They then use the @value{op-files-from}
5659 option to archive the files located via @command{find}.
5661 The problem when restoring files archived in this manner is that the
5662 directories themselves are not in the archive; so the
5663 @value{op-same-permissions} option does not affect them---while users
5664 might really like it to. Specifying @value{op-no-recursion} is a way to
5665 tell @command{tar} to grab only the directory entries given to it, adding
5666 no new files on its own.
5668 The @value{op-no-recursion} option also applies when extracting: it
5669 causes @command{tar} to extract only the matched directory entries, not
5670 the files under those directories.
5672 @FIXME{example here}
5675 @section Crossing Filesystem Boundaries
5676 @cindex File system boundaries, not crossing
5679 @command{tar} will normally automatically cross file system boundaries in
5680 order to archive files which are part of a directory tree. You can
5681 change this behavior by running @command{tar} and specifying
5682 @value{op-one-file-system}. This option only affects files that are
5683 archived because they are in a directory that is being archived;
5684 @command{tar} will still archive files explicitly named on the command line
5685 or through @value{op-files-from}, regardless of where they reside.
5688 @item --one-file-system
5690 Prevents @command{tar} from crossing file system boundaries when
5691 archiving. Use in conjunction with any write operation.
5694 The @samp{--one-file-system} option causes @command{tar} to modify its
5695 normal behavior in archiving the contents of directories. If a file in
5696 a directory is not on the same filesystem as the directory itself, then
5697 @command{tar} will not archive that file. If the file is a directory
5698 itself, @command{tar} will not archive anything beneath it; in other words,
5699 @command{tar} will not cross mount points.
5701 It is reported that using this option, the mount point is is archived,
5702 but nothing under it.
5704 This option is useful for making full or incremental archival backups of
5705 a file system. If this option is used in conjunction with
5706 @value{op-verbose}, files that are excluded are mentioned by name on the
5710 * directory:: Changing Directory
5711 * absolute:: Absolute File Names
5715 @subsection Changing the Working Directory
5717 @FIXME{need to read over this node now for continuity; i've switched
5718 things around some.}
5720 @cindex Changing directory mid-stream
5721 @cindex Directory, changing mid-stream
5722 @cindex Working directory, specifying
5725 To change the working directory in the middle of a list of file names,
5726 either on the command line or in a file specified using
5727 @value{op-files-from}, use @value{op-directory}. This will change the
5728 working directory to the directory @var{directory} after that point in
5732 @item --directory=@var{directory}
5733 @itemx -C @var{directory}
5734 Changes the working directory in the middle of a command line.
5740 $ @kbd{tar -c -f jams.tar grape prune -C food cherry}
5744 will place the files @file{grape} and @file{prune} from the current
5745 directory into the archive @file{jams.tar}, followed by the file
5746 @file{cherry} from the directory @file{food}. This option is especially
5747 useful when you have several widely separated files that you want to
5748 store in the same archive.
5750 Note that the file @file{cherry} is recorded in the archive under the
5751 precise name @file{cherry}, @emph{not} @file{food/cherry}. Thus, the
5752 archive will contain three files that all appear to have come from the
5753 same directory; if the archive is extracted with plain @samp{tar
5754 --extract}, all three files will be written in the current directory.
5756 Contrast this with the command,
5759 $ @kbd{tar -c -f jams.tar grape prune -C food red/cherry}
5763 which records the third file in the archive under the name
5764 @file{red/cherry} so that, if the archive is extracted using
5765 @samp{tar --extract}, the third file will be written in a subdirectory
5766 named @file{orange-colored}.
5768 You can use the @samp{--directory} option to make the archive
5769 independent of the original name of the directory holding the files.
5770 The following command places the files @file{/etc/passwd},
5771 @file{/etc/hosts}, and @file{/lib/libc.a} into the archive
5775 $ @kbd{tar -c -f foo.tar -C /etc passwd hosts -C /lib libc.a}
5779 However, the names of the archive members will be exactly what they were
5780 on the command line: @file{passwd}, @file{hosts}, and @file{libc.a}.
5781 They will not appear to be related by file name to the original
5782 directories where those files were located.
5784 Note that @samp{--directory} options are interpreted consecutively. If
5785 @samp{--directory} specifies a relative file name, it is interpreted
5786 relative to the then current directory, which might not be the same as
5787 the original current working directory of @command{tar}, due to a previous
5788 @samp{--directory} option.
5790 @FIXME{dan: does this mean that you *can* use the short option form, but
5791 you can *not* use the long option form with --files-from? or is this
5794 When using @samp{--files-from} (@pxref{files}), you can put @samp{-C}
5795 options in the file list. Unfortunately, you cannot put
5796 @samp{--directory} options in the file list. (This interpretation can
5797 be disabled by using the @value{op-null} option.)
5800 @subsection Absolute File Names
5805 @itemx --absolute-names
5806 Do not strip leading slashes from file names, and permit file names
5807 containing a @file{..} file name component.
5810 By default, @sc{gnu} @command{tar} drops a leading @samp{/} on input or output,
5811 and complains about file names containing a @file{..} component.
5812 This option turns off this behavior.
5814 When @command{tar} extracts archive members from an archive, it strips any
5815 leading slashes (@samp{/}) from the member name. This causes absolute
5816 member names in the archive to be treated as relative file names. This
5817 allows you to have such members extracted wherever you want, instead of
5818 being restricted to extracting the member in the exact directory named
5819 in the archive. For example, if the archive member has the name
5820 @file{/etc/passwd}, @command{tar} will extract it as if the name were
5821 really @file{etc/passwd}.
5823 File names containing @file{..} can cause problems when extracting, so
5824 @command{tar} normally warns you about such files when creating an
5825 archive, and rejects attempts to extracts such files.
5827 Other @command{tar} programs do not do this. As a result, if you create an
5828 archive whose member names start with a slash, they will be difficult
5829 for other people with a non-@sc{gnu} @command{tar} program to use. Therefore,
5830 @sc{gnu} @command{tar} also strips leading slashes from member names when
5831 putting members into the archive. For example, if you ask @command{tar} to
5832 add the file @file{/bin/ls} to an archive, it will do so, but the member
5833 name will be @file{bin/ls}.
5835 If you use the @value{op-absolute-names} option, @command{tar} will do
5836 none of these transformations.
5838 To archive or extract files relative to the root directory, specify
5839 the @value{op-absolute-names} option.
5841 Normally, @command{tar} acts on files relative to the working
5842 directory---ignoring superior directory names when archiving, and
5843 ignoring leading slashes when extracting.
5845 When you specify @value{op-absolute-names}, @command{tar} stores file names
5846 including all superior directory names, and preserves leading slashes.
5847 If you only invoked @command{tar} from the root directory you would never
5848 need the @value{op-absolute-names} option, but using this option may be
5849 more convenient than switching to root.
5851 @FIXME{Should be an example in the tutorial/wizardry section using this
5852 to transfer files between systems.}
5854 @FIXME{Is write access an issue?}
5857 @item --absolute-names
5858 Preserves full file names (including superior directory names) when
5859 archiving files. Preserves leading slash when extracting files.
5863 @FIXME{this is still horrible; need to talk with dan on monday.}
5865 @command{tar} prints out a message about removing the @samp{/} from file
5866 names. This message appears once per @sc{gnu} @command{tar} invocation. It
5867 represents something which ought to be told; ignoring what it means can
5868 cause very serious surprises, later.
5870 Some people, nevertheless, do not want to see this message. Wanting to
5871 play really dangerously, one may of course redirect @command{tar} standard
5872 error to the sink. For example, under @command{sh}:
5875 $ @kbd{tar -c -f archive.tar /home 2> /dev/null}
5879 Another solution, both nicer and simpler, would be to change to
5880 the @file{/} directory first, and then avoid absolute notation.
5884 $ @kbd{(cd / && tar -c -f archive.tar home)}
5885 $ @kbd{tar -c -f archive.tar -C / home}
5888 @include getdate.texi
5891 @chapter Controlling the Archive Format
5893 @FIXME{need an intro here}
5896 * Portability:: Making @command{tar} Archives More Portable
5897 * Compression:: Using Less Space through Compression
5898 * Attributes:: Handling File Attributes
5899 * Standard:: The Standard Format
5900 * Extensions:: @sc{gnu} Extensions to the Archive Format
5901 * cpio:: Comparison of @command{tar} and @command{cpio}
5905 @section Making @command{tar} Archives More Portable
5907 Creating a @command{tar} archive on a particular system that is meant to be
5908 useful later on many other machines and with other versions of @command{tar}
5909 is more challenging than you might think. @command{tar} archive formats
5910 have been evolving since the first versions of Unix. Many such formats
5911 are around, and are not always compatible with each other. This section
5912 discusses a few problems, and gives some advice about making @command{tar}
5913 archives more portable.
5915 One golden rule is simplicity. For example, limit your @command{tar}
5916 archives to contain only regular files and directories, avoiding
5917 other kind of special files. Do not attempt to save sparse files or
5918 contiguous files as such. Let's discuss a few more problems, in turn.
5921 * Portable Names:: Portable Names
5922 * dereference:: Symbolic Links
5923 * old:: Old V7 Archives
5924 * posix:: @sc{posix} archives
5925 * Checksumming:: Checksumming Problems
5926 * Large or Negative Values:: Large files, negative time stamps, etc.
5929 @node Portable Names
5930 @subsection Portable Names
5932 Use portable file and member names. A name is portable if it contains
5933 only ASCII letters and digits, @samp{/}, @samp{.}, @samp{_}, and
5934 @samp{-}; it cannot be empty, start with @samp{-} or @samp{//}, or
5935 contain @samp{/-}. Avoid deep directory nesting. For portability to
5936 old Unix hosts, limit your file name components to 14 characters or
5939 If you intend to have your @command{tar} archives to be read under MSDOS,
5940 you should not rely on case distinction for file names, and you might
5941 use the @sc{gnu} @command{doschk} program for helping you further diagnosing
5942 illegal MSDOS names, which are even more limited than System V's.
5945 @subsection Symbolic Links
5946 @cindex File names, using symbolic links
5947 @cindex Symbolic link as file name
5949 Normally, when @command{tar} archives a symbolic link, it writes a
5950 block to the archive naming the target of the link. In that way, the
5951 @command{tar} archive is a faithful record of the filesystem contents.
5952 @value{op-dereference} is used with @value{op-create}, and causes @command{tar}
5953 to archive the files symbolic links point to, instead of the links
5954 themselves. When this option is used, when @command{tar} encounters a
5955 symbolic link, it will archive the linked-to file, instead of simply
5956 recording the presence of a symbolic link.
5958 The name under which the file is stored in the file system is not
5959 recorded in the archive. To record both the symbolic link name and
5960 the file name in the system, archive the file under both names. If
5961 all links were recorded automatically by @command{tar}, an extracted file
5962 might be linked to a file name that no longer exists in the file
5965 If a linked-to file is encountered again by @command{tar} while creating
5966 the same archive, an entire second copy of it will be stored. (This
5967 @emph{might} be considered a bug.)
5969 So, for portable archives, do not archive symbolic links as such,
5970 and use @value{op-dereference}: many systems do not support
5971 symbolic links, and moreover, your distribution might be unusable if
5972 it contains unresolved symbolic links.
5975 @subsection Old V7 Archives
5976 @cindex Format, old style
5977 @cindex Old style format
5978 @cindex Old style archives
5980 Certain old versions of @command{tar} cannot handle additional
5981 information recorded by newer @command{tar} programs. To create an
5982 archive in V7 format (not ANSI), which can be read by these old
5983 versions, specify the @value{op-old-archive} option in
5984 conjunction with the @value{op-create}. @command{tar} also
5985 accepts @samp{--portability} for this option. When you specify it,
5986 @command{tar} leaves out information about directories, pipes, fifos,
5987 contiguous files, and device files, and specifies file ownership by
5988 group and user IDs instead of group and user names.
5990 When updating an archive, do not use @value{op-old-archive}
5991 unless the archive was created with using this option.
5993 In most cases, a @emph{new} format archive can be read by an @emph{old}
5994 @command{tar} program without serious trouble, so this option should
5995 seldom be needed. On the other hand, most modern @command{tar}s are
5996 able to read old format archives, so it might be safer for you to
5997 always use @value{op-old-archive} for your distributions.
6000 @subsection @sc{gnu} @command{tar} and @sc{posix} @command{tar}
6002 @sc{gnu} @command{tar} was based on an early draft of the @sc{posix} 1003.1
6003 @code{ustar} standard. @sc{gnu} extensions to @command{tar}, such as the
6004 support for file names longer than 100 characters, use portions of the
6005 @command{tar} header record which were specified in that @sc{posix} draft as
6006 unused. Subsequent changes in @sc{posix} have allocated the same parts of
6007 the header record for other purposes. As a result, @sc{gnu} @command{tar} is
6008 incompatible with the current @sc{posix} spec, and with @command{tar} programs
6011 We plan to reimplement these @sc{gnu} extensions in a new way which is
6012 upward compatible with the latest @sc{posix} @command{tar} format, but we
6013 don't know when this will be done.
6015 In the mean time, there is simply no telling what might happen if you
6016 read a @sc{gnu} @command{tar} archive, which uses the @sc{gnu} extensions, using
6017 some other @command{tar} program. So if you want to read the archive
6018 with another @command{tar} program, be sure to write it using the
6019 @samp{--old-archive} option (@samp{-o}).
6021 @FIXME{is there a way to tell which flavor of tar was used to write a
6022 particular archive before you try to read it?}
6024 Traditionally, old @command{tar}s have a limit of 100 characters. @sc{gnu}
6025 @command{tar} attempted two different approaches to overcome this limit,
6026 using and extending a format specified by a draft of some P1003.1.
6027 The first way was not that successful, and involved @file{@@MaNgLeD@@}
6028 file names, or such; while a second approach used @file{././@@LongLink}
6029 and other tricks, yielding better success. In theory, @sc{gnu} @command{tar}
6030 should be able to handle file names of practically unlimited length.
6031 So, if @sc{gnu} @command{tar} fails to dump and retrieve files having more
6032 than 100 characters, then there is a bug in @sc{gnu} @command{tar}, indeed.
6034 But, being strictly @sc{posix}, the limit was still 100 characters.
6035 For various other purposes, @sc{gnu} @command{tar} used areas left unassigned
6036 in the @sc{posix} draft. @sc{posix} later revised P1003.1 @code{ustar} format by
6037 assigning previously unused header fields, in such a way that the upper
6038 limit for file name length was raised to 256 characters. However, the
6039 actual @sc{posix} limit oscillates between 100 and 256, depending on the
6040 precise location of slashes in full file name (this is rather ugly).
6041 Since @sc{gnu} @command{tar} use the same fields for quite other purposes,
6042 it became incompatible with the latest @sc{posix} standards.
6044 For longer or non-fitting file names, we plan to use yet another set
6045 of @sc{gnu} extensions, but this time, complying with the provisions @sc{posix}
6046 offers for extending the format, rather than conflicting with it.
6047 Whenever an archive uses old @sc{gnu} @command{tar} extension format or @sc{posix}
6048 extensions, would it be for very long file names or other specialities,
6049 this archive becomes non-portable to other @command{tar} implementations.
6050 In fact, anything can happen. The most forgiving @command{tar}s will
6051 merely unpack the file using a wrong name, and maybe create another
6052 file named something like @file{@@LongName}, with the true file name
6053 in it. @command{tar}s not protecting themselves may segment violate!
6055 Compatibility concerns make all this thing more difficult, as we
6056 will have to support @emph{all} these things together, for a while.
6057 @sc{gnu} @command{tar} should be able to produce and read true @sc{posix} format
6058 files, while being able to detect old @sc{gnu} @command{tar} formats, besides
6059 old V7 format, and process them conveniently. It would take years
6060 before this whole area stabilizes@dots{}
6062 There are plans to raise this 100 limit to 256, and yet produce @sc{posix}
6063 conforming archives. Past 256, I do not know yet if @sc{gnu} @command{tar}
6064 will go non-@sc{posix} again, or merely refuse to archive the file.
6066 There are plans so @sc{gnu} @command{tar} support more fully the latest @sc{posix}
6067 format, while being able to read old V7 format, @sc{gnu} (semi-@sc{posix} plus
6068 extension), as well as full @sc{posix}. One may ask if there is part of
6069 the @sc{posix} format that we still cannot support. This simple question
6070 has a complex answer. Maybe that, on intimate look, some strong
6071 limitations will pop up, but until now, nothing sounds too difficult
6072 (but see below). I only have these few pages of @sc{posix} telling about
6073 ``Extended tar Format'' (P1003.1-1990 -- section 10.1.1), and there are
6074 references to other parts of the standard I do not have, which should
6075 normally enforce limitations on stored file names (I suspect things
6076 like fixing what @kbd{/} and @kbd{@key{NUL}} means). There are also
6077 some points which the standard does not make clear, Existing practice
6078 will then drive what I should do.
6080 @sc{posix} mandates that, when a file name cannot fit within 100 to
6081 256 characters (the variance comes from the fact a @kbd{/} is
6082 ideally needed as the 156'th character), or a link name cannot
6083 fit within 100 characters, a warning should be issued and the file
6084 @emph{not} be stored. Unless some @value{op-posix} option is given
6085 (or @env{POSIXLY_CORRECT} is set), I suspect that @sc{gnu} @command{tar}
6086 should disobey this specification, and automatically switch to using
6087 @sc{gnu} extensions to overcome file name or link name length limitations.
6089 There is a problem, however, which I did not intimately studied yet.
6090 Given a truly @sc{posix} archive with names having more than 100 characters,
6091 I guess that @sc{gnu} @command{tar} up to 1.11.8 will process it as if it were an
6092 old V7 archive, and be fooled by some fields which are coded differently.
6093 So, the question is to decide if the next generation of @sc{gnu} @command{tar}
6094 should produce @sc{posix} format by default, whenever possible, producing
6095 archives older versions of @sc{gnu} @command{tar} might not be able to read
6096 correctly. I fear that we will have to suffer such a choice one of these
6097 days, if we want @sc{gnu} @command{tar} to go closer to @sc{posix}. We can rush it.
6098 Another possibility is to produce the current @sc{gnu} @command{tar} format
6099 by default for a few years, but have @sc{gnu} @command{tar} versions from some
6100 1.@var{POSIX} and up able to recognize all three formats, and let older
6101 @sc{gnu} @command{tar} fade out slowly. Then, we could switch to producing @sc{posix}
6102 format by default, with not much harm to those still having (very old at
6103 that time) @sc{gnu} @command{tar} versions prior to 1.@var{POSIX}.
6105 @sc{posix} format cannot represent very long names, volume headers,
6106 splitting of files in multi-volumes, sparse files, and incremental
6107 dumps; these would be all disallowed if @value{op-posix} or
6108 @env{POSIXLY_CORRECT}. Otherwise, if @command{tar} is given long
6109 names, or @samp{-[VMSgG]}, then it should automatically go non-@sc{posix}.
6110 I think this is easily granted without much discussion.
6112 Another point is that only @code{mtime} is stored in @sc{posix}
6113 archives, while @sc{gnu} @command{tar} currently also store @code{atime}
6114 and @code{ctime}. If we want @sc{gnu} @command{tar} to go closer to @sc{posix},
6115 my choice would be to drop @code{atime} and @code{ctime} support on
6116 average. On the other hand, I perceive that full dumps or incremental
6117 dumps need @code{atime} and @code{ctime} support, so for those special
6118 applications, @sc{posix} has to be avoided altogether.
6120 A few users requested that @value{op-sparse} be always active by
6121 default, I think that before replying to them, we have to decide
6122 if we want @sc{gnu} @command{tar} to go closer to @sc{posix} on average, while
6123 producing files. My choice would be to go closer to @sc{posix} in the
6124 long run. Besides possible double reading, I do not see any point
6125 of not trying to save files as sparse when creating archives which
6126 are neither @sc{posix} nor old-V7, so the actual @value{op-sparse} would
6127 become selected by default when producing such archives, whatever
6128 the reason is. So, @value{op-sparse} alone might be redefined to force
6129 @sc{gnu}-format archives, and recover its previous meaning from this fact.
6131 @sc{gnu}-format as it exists now can easily fool other @sc{posix} @command{tar},
6132 as it uses fields which @sc{posix} considers to be part of the file name
6133 prefix. I wonder if it would not be a good idea, in the long run,
6134 to try changing @sc{gnu}-format so any added field (like @code{ctime},
6135 @code{atime}, file offset in subsequent volumes, or sparse file
6136 descriptions) be wholly and always pushed into an extension block,
6137 instead of using space in the @sc{posix} header block. I could manage
6138 to do that portably between future @sc{gnu} @command{tar}s. So other @sc{posix}
6139 @command{tar}s might be at least able to provide kind of correct listings
6140 for the archives produced by @sc{gnu} @command{tar}, if not able to process
6143 Using these projected extensions might induce older @command{tar}s to fail.
6144 We would use the same approach as for @sc{posix}. I'll put out a @command{tar}
6145 capable of reading @sc{posix}ier, yet extended archives, but will not produce
6146 this format by default, in @sc{gnu} mode. In a few years, when newer @sc{gnu}
6147 @command{tar}s will have flooded out @command{tar} 1.11.X and previous, we
6148 could switch to producing @sc{posix}ier extended archives, with no real harm
6149 to users, as almost all existing @sc{gnu} @command{tar}s will be ready to read
6150 @sc{posix}ier format. In fact, I'll do both changes at the same time, in a
6151 few years, and just prepare @command{tar} for both changes, without effecting
6152 them, from 1.@var{POSIX}. (Both changes: 1---using @sc{posix} convention for
6153 getting over 100 characters; 2---avoiding mangling @sc{posix} headers for @sc{gnu}
6154 extensions, using only @sc{posix} mandated extension techniques).
6156 So, a future @command{tar} will have a @value{op-posix}
6157 flag forcing the usage of truly @sc{posix} headers, and so, producing
6158 archives previous @sc{gnu} @command{tar} will not be able to read.
6159 So, @emph{once} pretest will announce that feature, it would be
6160 particularly useful that users test how exchangeable will be archives
6161 between @sc{gnu} @command{tar} with @value{op-posix} and other @sc{posix} @command{tar}.
6163 In a few years, when @sc{gnu} @command{tar} will produce @sc{posix} headers by
6164 default, @value{op-posix} will have a strong meaning and will disallow
6165 @sc{gnu} extensions. But in the meantime, for a long while, @value{op-posix}
6166 in @sc{gnu} tar will not disallow @sc{gnu} extensions like @value{op-label},
6167 @value{op-multi-volume}, @value{op-sparse}, or very long file or link names.
6168 However, @value{op-posix} with @sc{gnu} extensions will use @sc{posix}
6169 headers with reserved-for-users extensions to headers, and I will be
6170 curious to know how well or bad @sc{posix} @command{tar}s will react to these.
6172 @sc{gnu} @command{tar} prior to 1.@var{POSIX}, and after 1.@var{POSIX} without
6173 @value{op-posix}, generates and checks @samp{ustar@w{ }@w{ }}, with two
6174 suffixed spaces. This is sufficient for older @sc{gnu} @command{tar} not to
6175 recognize @sc{posix} archives, and consequently, wrongly decide those archives
6176 are in old V7 format. It is a useful bug for me, because @sc{gnu} @command{tar}
6177 has other @sc{posix} incompatibilities, and I need to segregate @sc{gnu} @command{tar}
6178 semi-@sc{posix} archives from truly @sc{posix} archives, for @sc{gnu} @command{tar} should
6179 be somewhat compatible with itself, while migrating closer to latest
6180 @sc{posix} standards. So, I'll be very careful about how and when I will do
6184 @subsection Checksumming Problems
6186 SunOS and HP-UX @command{tar} fail to accept archives created using @sc{gnu}
6187 @command{tar} and containing non-ASCII file names, that is, file names
6188 having characters with the eight bit set, because they use signed
6189 checksums, while @sc{gnu} @command{tar} uses unsigned checksums while creating
6190 archives, as per @sc{posix} standards. On reading, @sc{gnu} @command{tar} computes
6191 both checksums and accept any. It is somewhat worrying that a lot of
6192 people may go around doing backup of their files using faulty (or at
6193 least non-standard) software, not learning about it until it's time
6194 to restore their missing files with an incompatible file extractor,
6197 @sc{gnu} @command{tar} compute checksums both ways, and accept any on read,
6198 so @sc{gnu} tar can read Sun tapes even with their wrong checksums.
6199 @sc{gnu} @command{tar} produces the standard checksum, however, raising
6200 incompatibilities with Sun. That is to say, @sc{gnu} @command{tar} has not
6201 been modified to @emph{produce} incorrect archives to be read by buggy
6202 @command{tar}'s. I've been told that more recent Sun @command{tar} now
6203 read standard archives, so maybe Sun did a similar patch, after all?
6205 The story seems to be that when Sun first imported @command{tar}
6206 sources on their system, they recompiled it without realizing that
6207 the checksums were computed differently, because of a change in
6208 the default signing of @code{char}'s in their compiler. So they
6209 started computing checksums wrongly. When they later realized their
6210 mistake, they merely decided to stay compatible with it, and with
6211 themselves afterwards. Presumably, but I do not really know, HP-UX
6212 has chosen that their @command{tar} archives to be compatible with Sun's.
6213 The current standards do not favor Sun @command{tar} format. In any
6214 case, it now falls on the shoulders of SunOS and HP-UX users to get
6215 a @command{tar} able to read the good archives they receive.
6217 @node Large or Negative Values
6218 @subsection Large or Negative Values
6219 @cindex large values
6220 @cindex future time stamps
6221 @cindex negative time stamps
6223 @sc{posix} @command{tar} format uses fixed-sized unsigned octal strings
6224 to represent numeric values. User and group IDs and device major and
6225 minor numbers have unsigned 21-bit representations, and file sizes and
6226 times have unsigned 33-bit representations. @sc{gnu} @command{tar}
6227 generates @sc{posix} representations when possible, but for values
6228 outside the @sc{posix} range it generates two's-complement base-256
6229 strings: uids, gids, and device numbers have signed 57-bit
6230 representations, and file sizes and times have signed 89-bit
6231 representations. These representations are an extension to @sc{posix}
6232 @command{tar} format, so they are not universally portable.
6234 The most common portability problems with out-of-range numeric values
6235 are large files and future or negative time stamps.
6237 Portable archives should avoid members of 8 GB or larger, as @sc{posix}
6238 @command{tar} format cannot represent them.
6240 Portable archives should avoid time stamps from the future. @sc{posix}
6241 @command{tar} format can represent time stamps in the range 1970-01-01
6242 00:00:00 through 2242-03-16 12:56:31 @sc{utc}. However, many current
6243 hosts use a signed 32-bit @code{time_t}, or internal time stamp format,
6244 and cannot represent time stamps after 2038-01-19 03:14:07 @sc{utc}; so
6245 portable archives must avoid these time stamps for many years to come.
6247 Portable archives should also avoid time stamps before 1970. These time
6248 stamps are a common @sc{posix} extension but their @code{time_t}
6249 representations are negative. Many traditional @command{tar}
6250 implementations generate a two's complement representation for negative
6251 time stamps that assumes a signed 32-bit @code{time_t}; hence they
6252 generate archives that are not portable to hosts with differing
6253 @code{time_t} representations. @sc{gnu} @command{tar} recognizes this
6254 situation when it is run on host with a signed 32-bit @code{time_t}, but
6255 it issues a warning, as these time stamps are nonstandard and unportable.
6258 @section Using Less Space through Compression
6261 * gzip:: Creating and Reading Compressed Archives
6262 * sparse:: Archiving Sparse Files
6266 @subsection Creating and Reading Compressed Archives
6267 @cindex Compressed archives
6268 @cindex Storing archives in compressed format
6275 Filter the archive through @command{gzip}.
6278 @FIXME{ach; these two bits orig from "compare" (?). where to put?} Some
6279 format parameters must be taken into consideration when modifying an
6280 archive.@FIXME{???} Compressed archives cannot be modified.
6282 You can use @samp{--gzip} and @samp{--gunzip} on physical devices
6283 (tape drives, etc.) and remote files as well as on normal files; data
6284 to or from such devices or remote files is reblocked by another copy
6285 of the @command{tar} program to enforce the specified (or default) record
6286 size. The default compression parameters are used; if you need to
6287 override them, avoid the @value{op-gzip} option and run @command{gzip}
6288 explicitly. (Or set the @env{GZIP} environment variable.)
6290 The @value{op-gzip} option does not work with the @value{op-multi-volume}
6291 option, or with the @value{op-update}, @value{op-append},
6292 @value{op-concatenate}, or @value{op-delete} operations.
6294 It is not exact to say that @sc{gnu} @command{tar} is to work in concert
6295 with @command{gzip} in a way similar to @command{zip}, say. Surely, it is
6296 possible that @command{tar} and @command{gzip} be done with a single call,
6300 $ @kbd{tar cfz archive.tar.gz subdir}
6304 to save all of @samp{subdir} into a @code{gzip}'ed archive. Later you
6308 $ @kbd{tar xfz archive.tar.gz}
6312 to explode and unpack.
6314 The difference is that the whole archive is compressed. With
6315 @command{zip}, archive members are archived individually. @command{tar}'s
6316 method yields better compression. On the other hand, one can view the
6317 contents of a @command{zip} archive without having to decompress it. As
6318 for the @command{tar} and @command{gzip} tandem, you need to decompress the
6319 archive to see its contents. However, this may be done without needing
6320 disk space, by using pipes internally:
6323 $ @kbd{tar tfz archive.tar.gz}
6326 @cindex corrupted archives
6327 About corrupted compressed archives: @command{gzip}'ed files have no
6328 redundancy, for maximum compression. The adaptive nature of the
6329 compression scheme means that the compression tables are implicitly
6330 spread all over the archive. If you lose a few blocks, the dynamic
6331 construction of the compression tables becomes unsynchronized, and there
6332 is little chance that you could recover later in the archive.
6334 There are pending suggestions for having a per-volume or per-file
6335 compression in @sc{gnu} @command{tar}. This would allow for viewing the
6336 contents without decompression, and for resynchronizing decompression at
6337 every volume or file, in case of corrupted archives. Doing so, we might
6338 lose some compressibility. But this would have make recovering easier.
6339 So, there are pros and cons. We'll see!
6344 Filter the archive through @code{bzip2}. Otherwise like @value{op-gzip}.
6349 Filter the archive through @command{compress}. Otherwise like @value{op-gzip}.
6351 @item --use-compress-program=@var{prog}
6352 Filter through @var{prog} (must accept @samp{-d}).
6355 @value{op-compress} stores an archive in compressed format. This
6356 option is useful in saving time over networks and space in pipes, and
6357 when storage space is at a premium. @value{op-compress} causes
6358 @command{tar} to compress when writing the archive, or to uncompress when
6359 reading the archive.
6361 To perform compression and uncompression on the archive, @command{tar}
6362 runs the @command{compress} utility. @command{tar} uses the default
6363 compression parameters; if you need to override them, avoid the
6364 @value{op-compress} option and run the @command{compress} utility
6365 explicitly. It is useful to be able to call the @command{compress}
6366 utility from within @command{tar} because the @command{compress} utility by
6367 itself cannot access remote tape drives.
6369 The @value{op-compress} option will not work in conjunction with the
6370 @value{op-multi-volume} option or the @value{op-append}, @value{op-update}
6371 and @value{op-delete} operations. @xref{Operations}, for
6372 more information on these operations.
6374 If there is no compress utility available, @command{tar} will report an error.
6375 @strong{Please note} that the @command{compress} program may be covered by
6376 a patent, and therefore we recommend you stop using it.
6378 @value{op-bzip2} acts like @value{op-compress}, except that it uses
6379 the @code{bzip2} utility.
6386 When this option is specified, @command{tar} will compress (when writing
6387 an archive), or uncompress (when reading an archive). Used in
6388 conjunction with the @value{op-create}, @value{op-extract}, @value{op-list} and
6389 @value{op-compare} operations.
6392 You can have archives be compressed by using the @value{op-gzip} option.
6393 This will arrange for @command{tar} to use the @command{gzip} program to be
6394 used to compress or uncompress the archive wren writing or reading it.
6396 To use the older, obsolete, @command{compress} program, use the
6397 @value{op-compress} option. The @sc{gnu} Project recommends you not use
6398 @command{compress}, because there is a patent covering the algorithm it
6399 uses. You could be sued for patent infringement merely by running
6402 I have one question, or maybe it's a suggestion if there isn't a way
6403 to do it now. I would like to use @value{op-gzip}, but I'd also like the
6404 output to be fed through a program like @sc{gnu} @command{ecc} (actually, right
6405 now that's @samp{exactly} what I'd like to use :-)), basically adding
6406 ECC protection on top of compression. It seems as if this should be
6407 quite easy to do, but I can't work out exactly how to go about it.
6408 Of course, I can pipe the standard output of @command{tar} through
6409 @command{ecc}, but then I lose (though I haven't started using it yet,
6410 I confess) the ability to have @command{tar} use @command{rmt} for it's I/O
6413 I think the most straightforward thing would be to let me specify a
6414 general set of filters outboard of compression (preferably ordered,
6415 so the order can be automatically reversed on input operations, and
6416 with the options they require specifiable), but beggars shouldn't be
6417 choosers and anything you decide on would be fine with me.
6419 By the way, I like @command{ecc} but if (as the comments say) it can't
6420 deal with loss of block sync, I'm tempted to throw some time at adding
6421 that capability. Supposing I were to actually do such a thing and
6422 get it (apparently) working, do you accept contributed changes to
6423 utilities like that? (Leigh Clayton @file{loc@@soliton.com}, May 1995).
6425 Isn't that exactly the role of the @value{op-use-compress-prog} option?
6426 I never tried it myself, but I suspect you may want to write a
6427 @var{prog} script or program able to filter stdin to stdout to
6428 way you want. It should recognize the @samp{-d} option, for when
6429 extraction is needed rather than creation.
6431 It has been reported that if one writes compressed data (through the
6432 @value{op-gzip} or @value{op-compress} options) to a DLT and tries to use
6433 the DLT compression mode, the data will actually get bigger and one will
6434 end up with less space on the tape.
6437 @subsection Archiving Sparse Files
6438 @cindex Sparse Files
6444 Handle sparse files efficiently.
6447 This option causes all files to be put in the archive to be tested for
6448 sparseness, and handled specially if they are. The @value{op-sparse}
6449 option is useful when many @code{dbm} files, for example, are being
6450 backed up. Using this option dramatically decreases the amount of
6451 space needed to store such a file.
6453 In later versions, this option may be removed, and the testing and
6454 treatment of sparse files may be done automatically with any special
6455 @sc{gnu} options. For now, it is an option needing to be specified on
6456 the command line with the creation or updating of an archive.
6458 Files in the filesystem occasionally have ``holes.'' A hole in a file
6459 is a section of the file's contents which was never written. The
6460 contents of a hole read as all zeros. On many operating systems,
6461 actual disk storage is not allocated for holes, but they are counted
6462 in the length of the file. If you archive such a file, @command{tar}
6463 could create an archive longer than the original. To have @command{tar}
6464 attempt to recognize the holes in a file, use @value{op-sparse}. When
6465 you use the @value{op-sparse} option, then, for any file using less
6466 disk space than would be expected from its length, @command{tar} searches
6467 the file for consecutive stretches of zeros. It then records in the
6468 archive for the file where the consecutive stretches of zeros are, and
6469 only archives the ``real contents'' of the file. On extraction (using
6470 @value{op-sparse} is not needed on extraction) any such files have
6471 hols created wherever the continuous stretches of zeros were found.
6472 Thus, if you use @value{op-sparse}, @command{tar} archives won't take
6473 more space than the original.
6475 A file is sparse if it contains blocks of zeros whose existence is
6476 recorded, but that have no space allocated on disk. When you specify
6477 the @value{op-sparse} option in conjunction with the @value{op-create}
6478 operation, @command{tar} tests all files for sparseness while archiving.
6479 If @command{tar} finds a file to be sparse, it uses a sparse representation of
6480 the file in the archive. @value{xref-create}, for more information
6481 about creating archives.
6483 @value{op-sparse} is useful when archiving files, such as dbm files,
6484 likely to contain many nulls. This option dramatically
6485 decreases the amount of space needed to store such an archive.
6488 @strong{Please Note:} Always use @value{op-sparse} when performing file
6489 system backups, to avoid archiving the expanded forms of files stored
6490 sparsely in the system.
6492 Even if your system has no sparse files currently, some may be
6493 created in the future. If you use @value{op-sparse} while making file
6494 system backups as a matter of course, you can be assured the archive
6495 will never take more space on the media than the files take on disk
6496 (otherwise, archiving a disk filled with sparse files might take
6497 hundreds of tapes). @FIXME-xref{incremental when node name is set.}
6500 @command{tar} ignores the @value{op-sparse} option when reading an archive.
6505 Files stored sparsely in the file system are represented sparsely in
6506 the archive. Use in conjunction with write operations.
6509 However, users should be well aware that at archive creation time, @sc{gnu}
6510 @command{tar} still has to read whole disk file to locate the @dfn{holes}, and
6511 so, even if sparse files use little space on disk and in the archive, they
6512 may sometimes require inordinate amount of time for reading and examining
6513 all-zero blocks of a file. Although it works, it's painfully slow for a
6514 large (sparse) file, even though the resulting tar archive may be small.
6515 (One user reports that dumping a @file{core} file of over 400 megabytes,
6516 but with only about 3 megabytes of actual data, took about 9 minutes on
6517 a Sun Sparcstation ELC, with full CPU utilization.)
6519 This reading is required in all cases and is not related to the fact
6520 the @value{op-sparse} option is used or not, so by merely @emph{not}
6521 using the option, you are not saving time@footnote{Well! We should say
6522 the whole truth, here. When @value{op-sparse} is selected while creating
6523 an archive, the current @command{tar} algorithm requires sparse files to be
6524 read twice, not once. We hope to develop a new archive format for saving
6525 sparse files in which one pass will be sufficient.}.
6527 Programs like @command{dump} do not have to read the entire file; by examining
6528 the file system directly, they can determine in advance exactly where the
6529 holes are and thus avoid reading through them. The only data it need read
6530 are the actual allocated data blocks. @sc{gnu} @command{tar} uses a more portable
6531 and straightforward archiving approach, it would be fairly difficult that
6532 it does otherwise. Elizabeth Zwicky writes to @file{comp.unix.internals},
6536 What I did say is that you cannot tell the difference between a hole and an
6537 equivalent number of nulls without reading raw blocks. @code{st_blocks} at
6538 best tells you how many holes there are; it doesn't tell you @emph{where}.
6539 Just as programs may, conceivably, care what @code{st_blocks} is (care
6540 to name one that does?), they may also care where the holes are (I have
6541 no examples of this one either, but it's equally imaginable).
6543 I conclude from this that good archivers are not portable. One can
6544 arguably conclude that if you want a portable program, you can in good
6545 conscience restore files with as many holes as possible, since you can't
6550 @section Handling File Attributes
6553 When @command{tar} reads files, this causes them to have the access
6554 times updated. To have @command{tar} attempt to set the access times
6555 back to what they were before they were read, use the
6556 @value{op-atime-preserve} option.
6558 Handling of file attributes
6561 @item --atime-preserve
6562 Preserve access times on files that are read.
6563 This doesn't work for files that
6564 you don't own, unless you're root, and it doesn't interact with
6565 incremental dumps nicely (@pxref{Backups}), and it can set access or
6566 modification times incorrectly if other programs access the file while
6567 @command{tar} is running; but it is good enough for some purposes.
6571 Do not extract file modified time.
6573 When this option is used, @command{tar} leaves the modification times
6574 of the files it extracts as the time when the files were extracted,
6575 instead of setting it to the time recorded in the archive.
6577 This option is meaningless with @value{op-list}.
6580 Create extracted files with the same ownership they have in the
6583 This is the default behavior for the superuser,
6584 so this option is meaningful only for non-root users, when @command{tar}
6585 is executed on those systems able to give files away. This is
6586 considered as a security flaw by many people, at least because it
6587 makes quite difficult to correctly account users for the disk space
6588 they occupy. Also, the @code{suid} or @code{sgid} attributes of
6589 files are easily and silently lost when files are given away.
6591 When writing an archive, @command{tar} writes the user id and user name
6592 separately. If it can't find a user name (because the user id is not
6593 in @file{/etc/passwd}), then it does not write one. When restoring,
6594 and doing a @code{chmod} like when you use @value{op-same-permissions},
6595 @FIXME{same-owner?}it tries to look the name (if one was written)
6596 up in @file{/etc/passwd}. If it fails, then it uses the user id
6597 stored in the archive instead.
6599 @item --no-same-owner
6600 Do not attempt to restore ownership when extracting. This is the
6601 default behavior for ordinary users, so this option has an effect
6602 only for the superuser.
6604 @item --numeric-owner
6605 The @value{op-numeric-owner} option allows (ANSI) archives to be written
6606 without user/group name information or such information to be ignored
6607 when extracting. It effectively disables the generation and/or use
6608 of user/group name information. This option forces extraction using
6609 the numeric ids from the archive, ignoring the names.
6611 This is useful in certain circumstances, when restoring a backup from
6612 an emergency floppy with different passwd/group files for example.
6613 It is otherwise impossible to extract files with the right ownerships
6614 if the password file in use during the extraction does not match the
6615 one belonging to the filesystem(s) being extracted. This occurs,
6616 for example, if you are restoring your files after a major crash and
6617 had booted from an emergency floppy with no password file or put your
6618 disk into another machine to do the restore.
6620 The numeric ids are @emph{always} saved into @command{tar} archives.
6621 The identifying names are added at create time when provided by the
6622 system, unless @value{op-old-archive} is used. Numeric ids could be
6623 used when moving archives between a collection of machines using
6624 a centralized management for attribution of numeric ids to users
6625 and groups. This is often made through using the NIS capabilities.
6627 When making a @command{tar} file for distribution to other sites, it
6628 is sometimes cleaner to use a single owner for all files in the
6629 distribution, and nicer to specify the write permission bits of the
6630 files as stored in the archive independently of their actual value on
6631 the file system. The way to prepare a clean distribution is usually
6632 to have some Makefile rule creating a directory, copying all needed
6633 files in that directory, then setting ownership and permissions as
6634 wanted (there are a lot of possible schemes), and only then making a
6635 @command{tar} archive out of this directory, before cleaning everything
6636 out. Of course, we could add a lot of options to @sc{gnu} @command{tar} for
6637 fine tuning permissions and ownership. This is not the good way,
6638 I think. @sc{gnu} @command{tar} is already crowded with options and moreover,
6639 the approach just explained gives you a great deal of control already.
6642 @itemx --same-permissions
6643 @itemx --preserve-permissions
6644 Extract all protection information.
6646 This option causes @command{tar} to set the modes (access permissions) of
6647 extracted files exactly as recorded in the archive. If this option
6648 is not used, the current @code{umask} setting limits the permissions
6651 This option is meaningless with @value{op-list}.
6654 Same as both @value{op-same-permissions} and @value{op-same-order}.
6656 The @value{op-preserve} option has no equivalent short option name.
6657 It is equivalent to @value{op-same-permissions} plus @value{op-same-order}.
6659 @FIXME{I do not see the purpose of such an option. (Neither I. FP.)}
6664 @section The Standard Format
6667 While an archive may contain many files, the archive itself is a
6668 single ordinary file. Like any other file, an archive file can be
6669 written to a storage device such as a tape or disk, sent through a
6670 pipe or over a network, saved on the active file system, or even
6671 stored in another archive. An archive file is not easy to read or
6672 manipulate without using the @command{tar} utility or Tar mode in @sc{gnu}
6675 Physically, an archive consists of a series of file entries terminated
6676 by an end-of-archive entry, which consists of 512 zero bytes. A file
6677 entry usually describes one of the files in the archive (an
6678 @dfn{archive member}), and consists of a file header and the contents
6679 of the file. File headers contain file names and statistics, checksum
6680 information which @command{tar} uses to detect file corruption, and
6681 information about file types.
6683 Archives are permitted to have more than one member with the same
6684 member name. One way this situation can occur is if more than one
6685 version of a file has been stored in the archive. For information
6686 about adding new versions of a file to an archive, see @ref{update}.
6687 @FIXME-xref{To learn more about having more than one archive member with the
6688 same name, see -backup node, when it's written.}
6690 In addition to entries describing archive members, an archive may
6691 contain entries which @command{tar} itself uses to store information.
6692 @value{xref-label}, for an example of such an archive entry.
6694 A @command{tar} archive file contains a series of blocks. Each block
6695 contains @code{BLOCKSIZE} bytes. Although this format may be thought
6696 of as being on magnetic tape, other media are often used.
6698 Each file archived is represented by a header block which describes
6699 the file, followed by zero or more blocks which give the contents
6700 of the file. At the end of the archive file there may be a block
6701 filled with binary zeros as an end-of-file marker. A reasonable system
6702 should write a block of zeros at the end, but must not assume that
6703 such a block exists when reading an archive.
6705 The blocks may be @dfn{blocked} for physical I/O operations.
6706 Each record of @var{n} blocks (where @var{n} is set by the
6707 @value{op-blocking-factor} option to @command{tar}) is written with a single
6708 @w{@samp{write ()}} operation. On magnetic tapes, the result of
6709 such a write is a single record. When writing an archive,
6710 the last record of blocks should be written at the full size, with
6711 blocks after the zero block containing all zeros. When reading
6712 an archive, a reasonable system should properly handle an archive
6713 whose last record is shorter than the rest, or which contains garbage
6714 records after a zero block.
6716 The header block is defined in C as follows. In the @sc{gnu} @command{tar}
6717 distribution, this is part of file @file{src/tar.h}:
6720 @include header.texi
6723 All characters in header blocks are represented by using 8-bit
6724 characters in the local variant of ASCII. Each field within the
6725 structure is contiguous; that is, there is no padding used within
6726 the structure. Each character on the archive medium is stored
6729 Bytes representing the contents of files (after the header block
6730 of each file) are not translated in any way and are not constrained
6731 to represent characters in any character set. The @command{tar} format
6732 does not distinguish text files from binary files, and no translation
6733 of file contents is performed.
6735 The @code{name}, @code{linkname}, @code{magic}, @code{uname}, and
6736 @code{gname} are null-terminated character strings. All other fileds
6737 are zero-filled octal numbers in ASCII. Each numeric field of width
6738 @var{w} contains @var{w} minus 2 digits, a space, and a null, except
6739 @code{size}, and @code{mtime}, which do not contain the trailing null.
6741 The @code{name} field is the file name of the file, with directory names
6742 (if any) preceding the file name, separated by slashes.
6744 @FIXME{how big a name before field overflows?}
6746 The @code{mode} field provides nine bits specifying file permissions
6747 and three bits to specify the Set UID, Set GID, and Save Text
6748 (@dfn{sticky}) modes. Values for these bits are defined above.
6749 When special permissions are required to create a file with a given
6750 mode, and the user restoring files from the archive does not hold such
6751 permissions, the mode bit(s) specifying those special permissions
6752 are ignored. Modes which are not supported by the operating system
6753 restoring files from the archive will be ignored. Unsupported modes
6754 should be faked up when creating or updating an archive; e.g.@: the
6755 group permission could be copied from the @emph{other} permission.
6757 The @code{uid} and @code{gid} fields are the numeric user and group
6758 ID of the file owners, respectively. If the operating system does
6759 not support numeric user or group IDs, these fields should be ignored.
6761 The @code{size} field is the size of the file in bytes; linked files
6762 are archived with this field specified as zero. @FIXME-xref{Modifiers, in
6763 particular the @value{op-incremental} option.}
6765 The @code{mtime} field is the modification time of the file at the time
6766 it was archived. It is the ASCII representation of the octal value of
6767 the last time the file was modified, represented as an integer number of
6768 seconds since January 1, 1970, 00:00 Coordinated Universal Time.
6770 The @code{chksum} field is the ASCII representation of the octal value
6771 of the simple sum of all bytes in the header block. Each 8-bit
6772 byte in the header is added to an unsigned integer, initialized to
6773 zero, the precision of which shall be no less than seventeen bits.
6774 When calculating the checksum, the @code{chksum} field is treated as
6775 if it were all blanks.
6777 The @code{typeflag} field specifies the type of file archived. If a
6778 particular implementation does not recognize or permit the specified
6779 type, the file will be extracted as if it were a regular file. As this
6780 action occurs, @command{tar} issues a warning to the standard error.
6782 The @code{atime} and @code{ctime} fields are used in making incremental
6783 backups; they store, respectively, the particular file's access time
6784 and last inode-change time.
6786 The @code{offset} is used by the @value{op-multi-volume} option, when
6787 making a multi-volume archive. The offset is number of bytes into
6788 the file that we need to restart at to continue the file on the next
6789 tape, i.e., where we store the location that a continued file is
6792 The following fields were added to deal with sparse files. A file
6793 is @dfn{sparse} if it takes in unallocated blocks which end up being
6794 represented as zeros, i.e., no useful data. A test to see if a file
6795 is sparse is to look at the number blocks allocated for it versus the
6796 number of characters in the file; if there are fewer blocks allocated
6797 for the file than would normally be allocated for a file of that
6798 size, then the file is sparse. This is the method @command{tar} uses to
6799 detect a sparse file, and once such a file is detected, it is treated
6800 differently from non-sparse files.
6802 Sparse files are often @code{dbm} files, or other database-type files
6803 which have data at some points and emptiness in the greater part of
6804 the file. Such files can appear to be very large when an @samp{ls
6805 -l} is done on them, when in truth, there may be a very small amount
6806 of important data contained in the file. It is thus undesirable
6807 to have @command{tar} think that it must back up this entire file, as
6808 great quantities of room are wasted on empty blocks, which can lead
6809 to running out of room on a tape far earlier than is necessary.
6810 Thus, sparse files are dealt with so that these empty blocks are
6811 not written to the tape. Instead, what is written to the tape is a
6812 description, of sorts, of the sparse file: where the holes are, how
6813 big the holes are, and how much data is found at the end of the hole.
6814 This way, the file takes up potentially far less room on the tape,
6815 and when the file is extracted later on, it will look exactly the way
6816 it looked beforehand. The following is a description of the fields
6817 used to handle a sparse file:
6819 The @code{sp} is an array of @code{struct sparse}. Each @code{struct
6820 sparse} contains two 12-character strings which represent an offset
6821 into the file and a number of bytes to be written at that offset.
6822 The offset is absolute, and not relative to the offset in preceding
6825 The header can hold four of these @code{struct sparse} at the moment;
6826 if more are needed, they are not stored in the header.
6828 The @code{isextended} flag is set when an @code{extended_header}
6829 is needed to deal with a file. Note that this means that this flag
6830 can only be set when dealing with a sparse file, and it is only set
6831 in the event that the description of the file will not fit in the
6832 allotted room for sparse structures in the header. In other words,
6833 an extended_header is needed.
6835 The @code{extended_header} structure is used for sparse files which
6836 need more sparse structures than can fit in the header. The header can
6837 fit 4 such structures; if more are needed, the flag @code{isextended}
6838 gets set and the next block is an @code{extended_header}.
6840 Each @code{extended_header} structure contains an array of 21
6841 sparse structures, along with a similar @code{isextended} flag
6842 that the header had. There can be an indeterminate number of such
6843 @code{extended_header}s to describe a sparse file.
6847 @item @code{REGTYPE}
6848 @itemx @code{AREGTYPE}
6849 These flags represent a regular file. In order to be compatible
6850 with older versions of @command{tar}, a @code{typeflag} value of
6851 @code{AREGTYPE} should be silently recognized as a regular file.
6852 New archives should be created using @code{REGTYPE}. Also, for
6853 backward compatibility, @command{tar} treats a regular file whose name
6854 ends with a slash as a directory.
6856 @item @code{LNKTYPE}
6857 This flag represents a file linked to another file, of any type,
6858 previously archived. Such files are identified in Unix by each
6859 file having the same device and inode number. The linked-to name is
6860 specified in the @code{linkname} field with a trailing null.
6862 @item @code{SYMTYPE}
6863 This represents a symbolic link to another file. The linked-to name
6864 is specified in the @code{linkname} field with a trailing null.
6866 @item @code{CHRTYPE}
6867 @itemx @code{BLKTYPE}
6868 These represent character special files and block special files
6869 respectively. In this case the @code{devmajor} and @code{devminor}
6870 fields will contain the major and minor device numbers respectively.
6871 Operating systems may map the device specifications to their own
6872 local specification, or may ignore the entry.
6874 @item @code{DIRTYPE}
6875 This flag specifies a directory or sub-directory. The directory
6876 name in the @code{name} field should end with a slash. On systems where
6877 disk allocation is performed on a directory basis, the @code{size} field
6878 will contain the maximum number of bytes (which may be rounded to
6879 the nearest disk block allocation unit) which the directory may
6880 hold. A @code{size} field of zero indicates no such limiting. Systems
6881 which do not support limiting in this manner should ignore the
6884 @item @code{FIFOTYPE}
6885 This specifies a FIFO special file. Note that the archiving of a
6886 FIFO file archives the existence of this file and not its contents.
6888 @item @code{CONTTYPE}
6889 This specifies a contiguous file, which is the same as a normal
6890 file except that, in operating systems which support it, all its
6891 space is allocated contiguously on the disk. Operating systems
6892 which do not allow contiguous allocation should silently treat this
6893 type as a normal file.
6895 @item @code{A} @dots{} @code{Z}
6896 These are reserved for custom implementations. Some of these are
6897 used in the @sc{gnu} modified format, as described below.
6901 Other values are reserved for specification in future revisions of
6902 the P1003 standard, and should not be used by any @command{tar} program.
6904 The @code{magic} field indicates that this archive was output in
6905 the P1003 archive format. If this field contains @code{TMAGIC},
6906 the @code{uname} and @code{gname} fields will contain the ASCII
6907 representation of the owner and group of the file respectively.
6908 If found, the user and group IDs are used rather than the values in
6909 the @code{uid} and @code{gid} fields.
6911 For references, see ISO/IEC 9945-1:1990 or IEEE Std 1003.1-1990, pages
6912 169-173 (section 10.1) for @cite{Archive/Interchange File Format}; and
6913 IEEE Std 1003.2-1992, pages 380-388 (section 4.48) and pages 936-940
6914 (section E.4.48) for @cite{pax - Portable archive interchange}.
6917 @section @sc{gnu} Extensions to the Archive Format
6920 The @sc{gnu} format uses additional file types to describe new types of
6921 files in an archive. These are listed below.
6924 @item GNUTYPE_DUMPDIR
6926 This represents a directory and a list of files created by the
6927 @value{op-incremental} option. The @code{size} field gives the total
6928 size of the associated list of files. Each file name is preceded by
6929 either a @samp{Y} (the file should be in this archive) or an @samp{N}.
6930 (The file is a directory, or is not stored in the archive.) Each file
6931 name is terminated by a null. There is an additional null after the
6934 @item GNUTYPE_MULTIVOL
6936 This represents a file continued from another volume of a multi-volume
6937 archive created with the @value{op-multi-volume} option. The original
6938 type of the file is not given here. The @code{size} field gives the
6939 maximum size of this piece of the file (assuming the volume does
6940 not end before the file is written out). The @code{offset} field
6941 gives the offset from the beginning of the file where this part of
6942 the file begins. Thus @code{size} plus @code{offset} should equal
6943 the original size of the file.
6945 @item GNUTYPE_SPARSE
6947 This flag indicates that we are dealing with a sparse file. Note
6948 that archiving a sparse file requires special operations to find
6949 holes in the file, which mark the positions of these holes, along
6950 with the number of bytes of data to be found after the hole.
6952 @item GNUTYPE_VOLHDR
6954 This file type is used to mark the volume header that was given with
6955 the @value{op-label} option when the archive was created. The @code{name}
6956 field contains the @code{name} given after the @value{op-label} option.
6957 The @code{size} field is zero. Only the first file in each volume
6958 of an archive should have this type.
6962 You may have trouble reading a @sc{gnu} format archive on a non-@sc{gnu}
6963 system if the options @value{op-incremental}, @value{op-multi-volume},
6964 @value{op-sparse}, or @value{op-label} were used when writing the archive.
6965 In general, if @command{tar} does not use the @sc{gnu}-added fields of the
6966 header, other versions of @command{tar} should be able to read the
6967 archive. Otherwise, the @command{tar} program will give an error, the
6968 most likely one being a checksum error.
6971 @section Comparison of @command{tar} and @command{cpio}
6974 @FIXME{Reorganize the following material}
6976 The @command{cpio} archive formats, like @command{tar}, do have maximum
6977 pathname lengths. The binary and old ASCII formats have a max path
6978 length of 256, and the new ASCII and CRC ASCII formats have a max
6979 path length of 1024. @sc{gnu} @command{cpio} can read and write archives
6980 with arbitrary pathname lengths, but other @command{cpio} implementations
6981 may crash unexplainedly trying to read them.
6983 @command{tar} handles symbolic links in the form in which it comes in BSD;
6984 @command{cpio} doesn't handle symbolic links in the form in which it comes
6985 in System V prior to SVR4, and some vendors may have added symlinks
6986 to their system without enhancing @command{cpio} to know about them.
6987 Others may have enhanced it in a way other than the way I did it
6988 at Sun, and which was adopted by AT&T (and which is, I think, also
6989 present in the @command{cpio} that Berkeley picked up from AT&T and put
6990 into a later BSD release---I think I gave them my changes).
6992 (SVR4 does some funny stuff with @command{tar}; basically, its @command{cpio}
6993 can handle @command{tar} format input, and write it on output, and it
6994 probably handles symbolic links. They may not have bothered doing
6995 anything to enhance @command{tar} as a result.)
6997 @command{cpio} handles special files; traditional @command{tar} doesn't.
6999 @command{tar} comes with V7, System III, System V, and BSD source;
7000 @command{cpio} comes only with System III, System V, and later BSD
7001 (4.3-tahoe and later).
7003 @command{tar}'s way of handling multiple hard links to a file can handle
7004 file systems that support 32-bit inumbers (e.g., the BSD file system);
7005 @command{cpio}s way requires you to play some games (in its "binary"
7006 format, i-numbers are only 16 bits, and in its "portable ASCII" format,
7007 they're 18 bits---it would have to play games with the "file system ID"
7008 field of the header to make sure that the file system ID/i-number pairs
7009 of different files were always different), and I don't know which
7010 @command{cpio}s, if any, play those games. Those that don't might get
7011 confused and think two files are the same file when they're not, and
7012 make hard links between them.
7014 @command{tar}s way of handling multiple hard links to a file places only
7015 one copy of the link on the tape, but the name attached to that copy
7016 is the @emph{only} one you can use to retrieve the file; @command{cpio}s
7017 way puts one copy for every link, but you can retrieve it using any
7021 What type of check sum (if any) is used, and how is this calculated.
7024 See the attached manual pages for @command{tar} and @command{cpio} format.
7025 @command{tar} uses a checksum which is the sum of all the bytes in the
7026 @command{tar} header for a file; @command{cpio} uses no checksum.
7029 If anyone knows why @command{cpio} was made when @command{tar} was present
7033 It wasn't. @command{cpio} first showed up in PWB/UNIX 1.0; no
7034 generally-available version of UNIX had @command{tar} at the time. I don't
7035 know whether any version that was generally available @emph{within AT&T}
7036 had @command{tar}, or, if so, whether the people within AT&T who did
7037 @command{cpio} knew about it.
7039 On restore, if there is a corruption on a tape @command{tar} will stop at
7040 that point, while @command{cpio} will skip over it and try to restore the
7043 The main difference is just in the command syntax and header format.
7045 @command{tar} is a little more tape-oriented in that everything is blocked
7046 to start on a record boundary.
7049 Is there any differences between the ability to recover crashed
7050 archives between the two of them. (Is there any chance of recovering
7051 crashed archives at all.)
7054 Theoretically it should be easier under @command{tar} since the blocking
7055 lets you find a header with some variation of @samp{dd skip=@var{nn}}.
7056 However, modern @command{cpio}'s and variations have an option to just
7057 search for the next file header after an error with a reasonable chance
7058 of resyncing. However, lots of tape driver software won't allow you to
7059 continue past a media error which should be the only reason for getting
7060 out of sync unless a file changed sizes while you were writing the
7064 If anyone knows why @command{cpio} was made when @command{tar} was present
7065 at the unix scene, please tell me about this too.
7068 Probably because it is more media efficient (by not blocking everything
7069 and using only the space needed for the headers where @command{tar}
7070 always uses 512 bytes per file header) and it knows how to archive
7073 You might want to look at the freely available alternatives. The major
7074 ones are @command{afio}, @sc{gnu} @command{tar}, and @command{pax}, each of which
7075 have their own extensions with some backwards compatibility.
7077 Sparse files were @command{tar}red as sparse files (which you can easily
7078 test, because the resulting archive gets smaller, and @sc{gnu} @command{cpio}
7079 can no longer read it).
7082 @chapter Tapes and Other Archive Media
7085 A few special cases about tape handling warrant more detailed
7086 description. These special cases are discussed below.
7088 Many complexities surround the use of @command{tar} on tape drives. Since
7089 the creation and manipulation of archives located on magnetic tape was
7090 the original purpose of @command{tar}, it contains many features making
7091 such manipulation easier.
7093 Archives are usually written on dismountable media---tape cartridges,
7094 mag tapes, or floppy disks.
7096 The amount of data a tape or disk holds depends not only on its size,
7097 but also on how it is formatted. A 2400 foot long reel of mag tape
7098 holds 40 megabytes of data when formatted at 1600 bits per inch. The
7099 physically smaller EXABYTE tape cartridge holds 2.3 gigabytes.
7101 Magnetic media are re-usable---once the archive on a tape is no longer
7102 needed, the archive can be erased and the tape or disk used over.
7103 Media quality does deteriorate with use, however. Most tapes or disks
7104 should be discarded when they begin to produce data errors. EXABYTE
7105 tape cartridges should be discarded when they generate an @dfn{error
7106 count} (number of non-usable bits) of more than 10k.
7108 Magnetic media are written and erased using magnetic fields, and
7109 should be protected from such fields to avoid damage to stored data.
7110 Sticking a floppy disk to a filing cabinet using a magnet is probably
7114 * Device:: Device selection and switching
7115 * Remote Tape Server::
7116 * Common Problems and Solutions::
7117 * Blocking:: Blocking
7118 * Many:: Many archives on one tape
7119 * Using Multiple Tapes:: Using Multiple Tapes
7120 * label:: Including a Label in the Archive
7122 * Write Protection::
7126 @section Device Selection and Switching
7130 @item -f [@var{hostname}:]@var{file}
7131 @itemx --file=[@var{hostname}:]@var{file}
7132 Use archive file or device @var{file} on @var{hostname}.
7135 This option is used to specify the file name of the archive @command{tar}
7138 If the file name is @samp{-}, @command{tar} reads the archive from standard
7139 input (when listing or extracting), or writes it to standard output
7140 (when creating). If the @samp{-} file name is given when updating an
7141 archive, @command{tar} will read the original archive from its standard
7142 input, and will write the entire new archive to its standard output.
7144 If the file name contains a @samp{:}, it is interpreted as
7145 @samp{hostname:file name}. If the @var{hostname} contains an @dfn{at}
7146 sign (@kbd{@@}), it is treated as @samp{user@@hostname:file name}. In
7147 either case, @command{tar} will invoke the command @command{rsh} (or
7148 @command{remsh}) to start up an @file{/etc/rmt} on the remote machine. If
7149 you give an alternate login name, it will be given to the @command{rsh}.
7150 Naturally, the remote machine must have an executable @file{/etc/rmt}.
7151 This program is free software from the University of California, and a
7152 copy of the source code can be found with the sources for @command{tar};
7153 it's compiled and installed by default.
7155 If this option is not given, but the environment variable @env{TAPE} is
7156 set, its value is used; otherwise, old versions of @command{tar} used a default
7157 archive name (which was picked when @command{tar} was compiled). The
7158 default is normally set up to be the @dfn{first} tape drive or other
7159 transportable I/O medium on the system.
7161 Starting with version 1.11.5, @sc{gnu} @command{tar} uses standard input and
7162 standard output as the default device, and I will not try anymore
7163 supporting automatic device detection at installation time. This was
7164 failing really in too many cases, it was hopeless. This is now
7165 completely left to the installer to override standard input and standard
7166 output for default device, if this seems preferable.
7167 Further, I think @emph{most} actual usages of @command{tar} are done with
7168 pipes or disks, not really tapes, cartridges or diskettes.
7170 Some users think that using standard input and output is running
7171 after trouble. This could lead to a nasty surprise on your screen if
7172 you forget to specify an output file name---especially if you are going
7173 through a network or terminal server capable of buffering large amounts
7174 of output. We had so many bug reports in that area of configuring
7175 default tapes automatically, and so many contradicting requests, that
7176 we finally consider the problem to be portably intractable. We could
7177 of course use something like @samp{/dev/tape} as a default, but this
7178 is @emph{also} running after various kind of trouble, going from hung
7179 processes to accidental destruction of real tapes. After having seen
7180 all this mess, using standard input and output as a default really
7181 sounds like the only clean choice left, and a very useful one too.
7183 @sc{gnu} @command{tar} reads and writes archive in records, I suspect this is the
7184 main reason why block devices are preferred over character devices.
7185 Most probably, block devices are more efficient too. The installer
7186 could also check for @samp{DEFTAPE} in @file{<sys/mtio.h>}.
7190 Archive file is local even if it contains a colon.
7192 @item --rsh-command=@var{command}
7193 Use remote @var{command} instead of @command{rsh}. This option exists
7194 so that people who use something other than the standard @command{rsh}
7195 (e.g., a Kerberized @command{rsh}) can access a remote device.
7197 When this command is not used, the shell command found when
7198 the @command{tar} program was installed is used instead. This is
7199 the first found of @file{/usr/ucb/rsh}, @file{/usr/bin/remsh},
7200 @file{/usr/bin/rsh}, @file{/usr/bsd/rsh} or @file{/usr/bin/nsh}.
7201 The installer may have overridden this by defining the environment
7202 variable @env{RSH} @emph{at installation time}.
7205 Specify drive and density.
7208 @itemx --multi-volume
7209 Create/list/extract multi-volume archive.
7211 This option causes @command{tar} to write a @dfn{multi-volume} archive---one
7212 that may be larger than will fit on the medium used to hold it.
7213 @xref{Multi-Volume Archives}.
7216 @itemx --tape-length=@var{num}
7217 Change tape after writing @var{num} x 1024 bytes.
7219 This option might be useful when your tape drivers do not properly
7220 detect end of physical tapes. By being slightly conservative on the
7221 maximum tape length, you might avoid the problem entirely.
7224 @itemx --info-script=@var{file}
7225 @itemx --new-volume-script=@var{file}
7226 Execute @file{file} at end of each tape. This implies
7227 @value{op-multi-volume}.
7230 @node Remote Tape Server
7231 @section The Remote Tape Server
7233 @cindex remote tape drive
7235 In order to access the tape drive on a remote machine, @command{tar}
7236 uses the remote tape server written at the University of California at
7237 Berkeley. The remote tape server must be installed as @file{/etc/rmt}
7238 on any machine whose tape drive you want to use. @command{tar} calls
7239 @file{/etc/rmt} by running an @command{rsh} or @command{remsh} to the remote
7240 machine, optionally using a different login name if one is supplied.
7242 A copy of the source for the remote tape server is provided. It is
7243 Copyright @copyright{} 1983 by the Regents of the University of
7244 California, but can be freely distributed. Instructions for compiling
7245 and installing it are included in the @file{Makefile}.
7247 @cindex absolute file names
7248 Unless you use the @value{op-absolute-names} option, @sc{gnu} @command{tar} will
7249 not allow you to create an archive that contains absolute file names
7250 (a file name beginning with @samp{/}.) If you try, @command{tar} will
7251 automatically remove the leading @samp{/} from the file names it
7252 stores in the archive. It will also type a warning message telling
7253 you what it is doing.
7255 When reading an archive that was created with a different @command{tar}
7256 program, @sc{gnu} @command{tar} automatically extracts entries in the archive
7257 which have absolute file names as if the file names were not absolute.
7258 This is an important feature. A visitor here once gave a
7259 @command{tar} tape to an operator to restore; the operator used Sun @command{tar}
7260 instead of @sc{gnu} @command{tar}, and the result was that it replaced large
7261 portions of our @file{/bin} and friends with versions from the tape;
7262 needless to say, we were unhappy about having to recover the file system
7265 For example, if the archive contained a file @file{/usr/bin/computoy},
7266 @sc{gnu} @command{tar} would extract the file to @file{usr/bin/computoy},
7267 relative to the current directory. If you want to extract the files in
7268 an archive to the same absolute names that they had when the archive
7269 was created, you should do a @samp{cd /} before extracting the files
7270 from the archive, or you should either use the @value{op-absolute-names}
7271 option, or use the command @samp{tar -C / @dots{}}.
7273 @cindex Ultrix 3.1 and write failure
7274 Some versions of Unix (Ultrix 3.1 is know to have this problem),
7275 can claim that a short write near the end of a tape succeeded,
7276 when it actually failed. This will result in the -M option not
7277 working correctly. The best workaround at the moment is to use a
7278 significantly larger blocking factor than the default 20.
7280 In order to update an archive, @command{tar} must be able to backspace the
7281 archive in order to reread or rewrite a record that was just read (or
7282 written). This is currently possible only on two kinds of files: normal
7283 disk files (or any other file that can be backspaced with @samp{lseek}),
7284 and industry-standard 9-track magnetic tape (or any other kind of tape
7285 that can be backspaced with the @code{MTIOCTOP} @code{ioctl}.
7287 This means that the @value{op-append}, @value{op-update},
7288 @value{op-concatenate}, and @value{op-delete} commands will not work on any
7289 other kind of file. Some media simply cannot be backspaced, which
7290 means these commands and options will never be able to work on them.
7291 These non-backspacing media include pipes and cartridge tape drives.
7293 Some other media can be backspaced, and @command{tar} will work on them
7294 once @command{tar} is modified to do so.
7296 Archives created with the @value{op-multi-volume}, @value{op-label}, and
7297 @value{op-incremental} options may not be readable by other version
7298 of @command{tar}. In particular, restoring a file that was split over
7299 a volume boundary will require some careful work with @command{dd}, if
7300 it can be done at all. Other versions of @command{tar} may also create
7301 an empty file whose name is that of the volume header. Some versions
7302 of @command{tar} may create normal files instead of directories archived
7303 with the @value{op-incremental} option.
7305 @node Common Problems and Solutions
7306 @section Some Common Problems and their Solutions
7313 no such file or directory
7316 errors from @command{tar}:
7317 directory checksum error
7320 errors from media/system:
7331 @dfn{Block} and @dfn{record} terminology is rather confused, and it
7332 is also confusing to the expert reader. On the other hand, readers
7333 who are new to the field have a fresh mind, and they may safely skip
7334 the next two paragraphs, as the remainder of this manual uses those
7335 two terms in a quite consistent way.
7337 John Gilmore, the writer of the public domain @command{tar} from which
7338 @sc{gnu} @command{tar} was originally derived, wrote (June 1995):
7341 The nomenclature of tape drives comes from IBM, where I believe
7342 they were invented for the IBM 650 or so. On IBM mainframes, what
7343 is recorded on tape are tape blocks. The logical organization of
7344 data is into records. There are various ways of putting records into
7345 blocks, including @code{F} (fixed sized records), @code{V} (variable
7346 sized records), @code{FB} (fixed blocked: fixed size records, @var{n}
7347 to a block), @code{VB} (variable size records, @var{n} to a block),
7348 @code{VSB} (variable spanned blocked: variable sized records that can
7349 occupy more than one block), etc. The @code{JCL} @samp{DD RECFORM=}
7350 parameter specified this to the operating system.
7352 The Unix man page on @command{tar} was totally confused about this.
7353 When I wrote @code{PD TAR}, I used the historically correct terminology
7354 (@command{tar} writes data records, which are grouped into blocks).
7355 It appears that the bogus terminology made it into @sc{posix} (no surprise
7356 here), and now Fran@,{c}ois has migrated that terminology back
7357 into the source code too.
7360 The term @dfn{physical block} means the basic transfer chunk from or
7361 to a device, after which reading or writing may stop without anything
7362 being lost. In this manual, the term @dfn{block} usually refers to
7363 a disk physical block, @emph{assuming} that each disk block is 512
7364 bytes in length. It is true that some disk devices have different
7365 physical blocks, but @command{tar} ignore these differences in its own
7366 format, which is meant to be portable, so a @command{tar} block is always
7367 512 bytes in length, and @dfn{block} always mean a @command{tar} block.
7368 The term @dfn{logical block} often represents the basic chunk of
7369 allocation of many disk blocks as a single entity, which the operating
7370 system treats somewhat atomically; this concept is only barely used
7371 in @sc{gnu} @command{tar}.
7373 The term @dfn{physical record} is another way to speak of a physical
7374 block, those two terms are somewhat interchangeable. In this manual,
7375 the term @dfn{record} usually refers to a tape physical block,
7376 @emph{assuming} that the @command{tar} archive is kept on magnetic tape.
7377 It is true that archives may be put on disk or used with pipes,
7378 but nevertheless, @command{tar} tries to read and write the archive one
7379 @dfn{record} at a time, whatever the medium in use. One record is made
7380 up of an integral number of blocks, and this operation of putting many
7381 disk blocks into a single tape block is called @dfn{reblocking}, or
7382 more simply, @dfn{blocking}. The term @dfn{logical record} refers to
7383 the logical organization of many characters into something meaningful
7384 to the application. The term @dfn{unit record} describes a small set
7385 of characters which are transmitted whole to or by the application,
7386 and often refers to a line of text. Those two last terms are unrelated
7387 to what we call a @dfn{record} in @sc{gnu} @command{tar}.
7389 When writing to tapes, @command{tar} writes the contents of the archive
7390 in chunks known as @dfn{records}. To change the default blocking
7391 factor, use the @value{op-blocking-factor} option. Each record will
7392 then be composed of @var{512-size} blocks. (Each @command{tar} block is
7393 512 bytes. @xref{Standard}.) Each file written to the archive uses
7394 at least one full record. As a result, using a larger record size
7395 can result in more wasted space for small files. On the other hand, a
7396 larger record size can often be read and written much more efficiently.
7398 Further complicating the problem is that some tape drives ignore the
7399 blocking entirely. For these, a larger record size can still improve
7400 performance (because the software layers above the tape drive still
7401 honor the blocking), but not as dramatically as on tape drives that
7404 When reading an archive, @command{tar} can usually figure out the record
7405 size on itself. When this is the case, and a non-standard record size
7406 was used when the archive was created, @command{tar} will print a message
7407 about a non-standard blocking factor, and then operate normally. On
7408 some tape devices, however, @command{tar} cannot figure out the record size
7409 itself. On most of those, you can specify a blocking factor (with
7410 @value{op-blocking-factor}) larger than the actual blocking factor, and then use
7411 the @value{op-read-full-records} option. (If you specify a blocking factor
7412 with @value{op-blocking-factor} and don't use the @value{op-read-full-records}
7413 option, then @command{tar} will not attempt to figure out the recording size
7414 itself.) On some devices, you must always specify the record size
7415 exactly with @value{op-blocking-factor} when reading, because @command{tar} cannot
7416 figure it out. In any case, use @value{op-list} before doing any
7417 extractions to see whether @command{tar} is reading the archive correctly.
7419 @command{tar} blocks are all fixed size (512 bytes), and its scheme for
7420 putting them into records is to put a whole number of them (one or
7421 more) into each record. @command{tar} records are all the same size;
7422 at the end of the file there's a block containing all zeros, which
7423 is how you tell that the remainder of the last record(s) are garbage.
7425 In a standard @command{tar} file (no options), the block size is 512
7426 and the record size is 10240, for a blocking factor of 20. What the
7427 @value{op-blocking-factor} option does is sets the blocking factor,
7428 changing the record size while leaving the block size at 512 bytes.
7429 20 was fine for ancient 800 or 1600 bpi reel-to-reel tape drives;
7430 most tape drives these days prefer much bigger records in order to
7431 stream and not waste tape. When writing tapes for myself, some tend
7432 to use a factor of the order of 2048, say, giving a record size of
7433 around one megabyte.
7435 If you use a blocking factor larger than 20, older @command{tar} programs
7436 might not be able to read the archive, so we recommend this as a limit
7437 to use in practice. @sc{gnu} @command{tar}, however, will support arbitrarily
7438 large record sizes, limited only by the amount of virtual memory or the
7439 physical characteristics of the tape device.
7442 * Format Variations:: Format Variations
7443 * Blocking Factor:: The Blocking Factor of an Archive
7446 @node Format Variations
7447 @subsection Format Variations
7448 @cindex Format Parameters
7449 @cindex Format Options
7450 @cindex Options, archive format specifying
7451 @cindex Options, format specifying
7454 Format parameters specify how an archive is written on the archive
7455 media. The best choice of format parameters will vary depending on
7456 the type and number of files being archived, and on the media used to
7459 To specify format parameters when accessing or creating an archive,
7460 you can use the options described in the following sections.
7461 If you do not specify any format parameters, @command{tar} uses
7462 default parameters. You cannot modify a compressed archive.
7463 If you create an archive with the @value{op-blocking-factor} option
7464 specified (@value{pxref-blocking-factor}), you must specify that
7465 blocking-factor when operating on the archive. @xref{Formats}, for other
7466 examples of format parameter considerations.
7468 @node Blocking Factor
7469 @subsection The Blocking Factor of an Archive
7470 @cindex Blocking Factor
7472 @cindex Number of blocks per record
7473 @cindex Number of bytes per record
7474 @cindex Bytes per record
7475 @cindex Blocks per record
7478 The data in an archive is grouped into blocks, which are 512 bytes.
7479 Blocks are read and written in whole number multiples called
7480 @dfn{records}. The number of blocks in a record (ie. the size of a
7481 record in units of 512 bytes) is called the @dfn{blocking factor}.
7482 The @value{op-blocking-factor} option specifies the blocking factor of
7483 an archive. The default blocking factor is typically 20 (ie.@:
7484 10240 bytes), but can be specified at installation. To find out
7485 the blocking factor of an existing archive, use @samp{tar --list
7486 --file=@var{archive-name}}. This may not work on some devices.
7488 Records are separated by gaps, which waste space on the archive media.
7489 If you are archiving on magnetic tape, using a larger blocking factor
7490 (and therefore larger records) provides faster throughput and allows you
7491 to fit more data on a tape (because there are fewer gaps). If you are
7492 archiving on cartridge, a very large blocking factor (say 126 or more)
7493 greatly increases performance. A smaller blocking factor, on the other
7494 hand, may be useful when archiving small files, to avoid archiving lots
7495 of nulls as @command{tar} fills out the archive to the end of the record.
7496 In general, the ideal record size depends on the size of the
7497 inter-record gaps on the tape you are using, and the average size of the
7498 files you are archiving. @xref{create}, for information on
7501 @FIXME{Need example of using a cartridge with blocking factor=126 or more.}
7503 Archives with blocking factors larger than 20 cannot be read
7504 by very old versions of @command{tar}, or by some newer versions
7505 of @command{tar} running on old machines with small address spaces.
7506 With @sc{gnu} @command{tar}, the blocking factor of an archive is limited
7507 only by the maximum record size of the device containing the archive,
7508 or by the amount of available virtual memory.
7510 Also, on some systems, not using adequate blocking factors, as sometimes
7511 imposed by the device drivers, may yield unexpected diagnostics. For
7512 example, this has been reported:
7515 Cannot write to /dev/dlt: Invalid argument
7519 In such cases, it sometimes happen that the @command{tar} bundled by the
7520 system is aware of block size idiosyncrasies, while @sc{gnu} @command{tar} requires
7521 an explicit specification for the block size, which it cannot guess.
7522 This yields some people to consider @sc{gnu} @command{tar} is misbehaving, because
7523 by comparison, @cite{the bundle @command{tar} works OK}. Adding @w{@kbd{-b
7524 256}}, for example, might resolve the problem.
7526 If you use a non-default blocking factor when you create an archive, you
7527 must specify the same blocking factor when you modify that archive. Some
7528 archive devices will also require you to specify the blocking factor when
7529 reading that archive, however this is not typically the case. Usually, you
7530 can use @value{op-list} without specifying a blocking factor---@command{tar}
7531 reports a non-default record size and then lists the archive members as
7532 it would normally. To extract files from an archive with a non-standard
7533 blocking factor (particularly if you're not sure what the blocking factor
7534 is), you can usually use the @value{op-read-full-records} option while
7535 specifying a blocking factor larger then the blocking factor of the archive
7536 (ie. @samp{tar --extract --read-full-records --blocking-factor=300}.
7537 @xref{list}, for more information on the @value{op-list}
7538 operation. @xref{Reading}, for a more detailed explanation of that option.
7541 @item --blocking-factor=@var{number}
7542 @itemx -b @var{number}
7543 Specifies the blocking factor of an archive. Can be used with any
7544 operation, but is usually not necessary with @value{op-list}.
7550 @item -b @var{blocks}
7551 @itemx --blocking-factor=@var{blocks}
7552 Set record size to @math{@var{blocks} * 512} bytes.
7554 This option is used to specify a @dfn{blocking factor} for the archive.
7555 When reading or writing the archive, @command{tar}, will do reads and writes
7556 of the archive in records of @math{@var{block}*512} bytes. This is true
7557 even when the archive is compressed. Some devices requires that all
7558 write operations be a multiple of a certain size, and so, @command{tar}
7559 pads the archive out to the next record boundary.
7561 The default blocking factor is set when @command{tar} is compiled, and is
7562 typically 20. Blocking factors larger than 20 cannot be read by very
7563 old versions of @command{tar}, or by some newer versions of @command{tar}
7564 running on old machines with small address spaces.
7566 With a magnetic tape, larger records give faster throughput and fit
7567 more data on a tape (because there are fewer inter-record gaps).
7568 If the archive is in a disk file or a pipe, you may want to specify
7569 a smaller blocking factor, since a large one will result in a large
7570 number of null bytes at the end of the archive.
7572 When writing cartridge or other streaming tapes, a much larger
7573 blocking factor (say 126 or more) will greatly increase performance.
7574 However, you must specify the same blocking factor when reading or
7575 updating the archive.
7577 Apparently, Exabyte drives have a physical block size of 8K bytes.
7578 If we choose our blocksize as a multiple of 8k bytes, then the problem
7579 seems to dissapper. Id est, we are using block size of 112 right
7580 now, and we haven't had the problem since we switched@dots{}
7582 With @sc{gnu} @command{tar} the blocking factor is limited only by the maximum
7583 record size of the device containing the archive, or by the amount of
7584 available virtual memory.
7586 However, deblocking or reblocking is virtually avoided in a special
7587 case which often occurs in practice, but which requires all the
7588 following conditions to be simultaneously true:
7591 the archive is subject to a compression option,
7593 the archive is not handled through standard input or output, nor
7594 redirected nor piped,
7596 the archive is directly handled to a local disk, instead of any special
7599 @value{op-blocking-factor} is not explicitly specified on the @command{tar}
7603 In previous versions of @sc{gnu} @command{tar}, the @samp{--compress-block}
7604 option (or even older: @samp{--block-compress}) was necessary to
7605 reblock compressed archives. It is now a dummy option just asking
7606 not to be used, and otherwise ignored. If the output goes directly
7607 to a local disk, and not through stdout, then the last write is
7608 not extended to a full record size. Otherwise, reblocking occurs.
7609 Here are a few other remarks on this topic:
7614 @command{gzip} will complain about trailing garbage if asked to
7615 uncompress a compressed archive on tape, there is an option to turn
7616 the message off, but it breaks the regularity of simply having to use
7617 @samp{@var{prog} -d} for decompression. It would be nice if gzip was
7618 silently ignoring any number of trailing zeros. I'll ask Jean-loup
7619 Gailly, by sending a copy of this message to him.
7622 @command{compress} does not show this problem, but as Jean-loup pointed
7623 out to Michael, @samp{compress -d} silently adds garbage after
7624 the result of decompression, which tar ignores because it already
7625 recognized its end-of-file indicator. So this bug may be safely
7629 @samp{gzip -d -q} will be silent about the trailing zeros indeed,
7630 but will still return an exit status of 2 which tar reports in turn.
7631 @command{tar} might ignore the exit status returned, but I hate doing
7632 that, as it weakens the protection @command{tar} offers users against
7633 other possible problems at decompression time. If @command{gzip} was
7634 silently skipping trailing zeros @emph{and} also avoiding setting the
7635 exit status in this innocuous case, that would solve this situation.
7638 @command{tar} should become more solid at not stopping to read a pipe at
7639 the first null block encountered. This inelegantly breaks the pipe.
7640 @command{tar} should rather drain the pipe out before exiting itself.
7644 @itemx --ignore-zeros
7645 Ignore blocks of zeros in archive (means EOF).
7647 The @value{op-ignore-zeros} option causes @command{tar} to ignore blocks
7648 of zeros in the archive. Normally a block of zeros indicates the
7649 end of the archive, but when reading a damaged archive, or one which
7650 was created by concatenating several archives together, this option
7651 allows @command{tar} to read the entire archive. This option is not on
7652 by default because many versions of @command{tar} write garbage after
7655 Note that this option causes @command{tar} to read to the end of the
7656 archive file, which may sometimes avoid problems when multiple files
7657 are stored on a single physical tape.
7660 @itemx --read-full-records
7661 Reblock as we read (for reading 4.2BSD pipes).
7663 If @value{op-read-full-records} is used, @command{tar} will not panic if an
7664 attempt to read a record from the archive does not return a full record.
7665 Instead, @command{tar} will keep reading until it has obtained a full
7668 This option is turned on by default when @command{tar} is reading
7669 an archive from standard input, or from a remote machine. This is
7670 because on BSD Unix systems, a read of a pipe will return however
7671 much happens to be in the pipe, even if it is less than @command{tar}
7672 requested. If this option was not used, @command{tar} would fail as
7673 soon as it read an incomplete record from the pipe.
7675 This option is also useful with the commands for updating an archive.
7681 @FIXME{Appropriate options should be moved here from elsewhere.}
7683 @cindex blocking factor
7684 @cindex tape blocking
7686 When handling various tapes or cartridges, you have to take care of
7687 selecting a proper blocking, that is, the number of disk blocks you
7688 put together as a single tape block on the tape, without intervening
7689 tape gaps. A @dfn{tape gap} is a small landing area on the tape
7690 with no information on it, used for decelerating the tape to a
7691 full stop, and for later regaining the reading or writing speed.
7692 When the tape driver starts reading a record, the record has to
7693 be read whole without stopping, as a tape gap is needed to stop the
7694 tape motion without loosing information.
7696 @cindex Exabyte blocking
7697 @cindex DAT blocking
7698 Using higher blocking (putting more disk blocks per tape block) will use
7699 the tape more efficiently as there will be less tape gaps. But reading
7700 such tapes may be more difficult for the system, as more memory will be
7701 required to receive at once the whole record. Further, if there is a
7702 reading error on a huge record, this is less likely that the system will
7703 succeed in recovering the information. So, blocking should not be too
7704 low, nor it should be too high. @command{tar} uses by default a blocking of
7705 20 for historical reasons, and it does not really matter when reading or
7706 writing to disk. Current tape technology would easily accommodate higher
7707 blockings. Sun recommends a blocking of 126 for Exabytes and 96 for DATs.
7708 We were told that for some DLT drives, the blocking should be a multiple
7709 of 4Kb, preferably 64Kb (@w{@kbd{-b 128}}) or 256 for decent performance.
7710 Other manufacturers may use different recommendations for the same tapes.
7711 This might also depends of the buffering techniques used inside modern
7712 tape controllers. Some imposes a minimum blocking, or a maximum blocking.
7713 Others request blocking to be some exponent of two.
7715 So, there is no fixed rule for blocking. But blocking at read time
7716 should ideally be the same as blocking used at write time. At one place
7717 I know, with a wide variety of equipment, they found it best to use a
7718 blocking of 32 to guarantee that their tapes are fully interchangeable.
7720 I was also told that, for recycled tapes, prior erasure (by the same
7721 drive unit that will be used to create the archives) sometimes lowers
7722 the error rates observed at rewriting time.
7724 I might also use @samp{--number-blocks} instead of
7725 @samp{--block-number}, so @samp{--block} will then expand to
7726 @samp{--blocking-factor} unambiguously.
7729 @section Many Archives on One Tape
7731 @FIXME{Appropriate options should be moved here from elsewhere.}
7733 @findex ntape @r{device}
7734 Most tape devices have two entries in the @file{/dev} directory, or
7735 entries that come in pairs, which differ only in the minor number for
7736 this device. Let's take for example @file{/dev/tape}, which often
7737 points to the only or usual tape device of a given system. There might
7738 be a corresponding @file{/dev/nrtape} or @file{/dev/ntape}. The simpler
7739 name is the @emph{rewinding} version of the device, while the name
7740 having @samp{nr} in it is the @emph{no rewinding} version of the same
7743 A rewinding tape device will bring back the tape to its beginning point
7744 automatically when this device is opened or closed. Since @command{tar}
7745 opens the archive file before using it and closes it afterwards, this
7746 means that a simple:
7749 $ @kbd{tar cf /dev/tape @var{directory}}
7753 will reposition the tape to its beginning both prior and after saving
7754 @var{directory} contents to it, thus erasing prior tape contents and
7755 making it so that any subsequent write operation will destroy what has
7758 @cindex tape positioning
7759 So, a rewinding device is normally meant to hold one and only one file.
7760 If you want to put more than one @command{tar} archive on a given tape, you
7761 will need to avoid using the rewinding version of the tape device. You
7762 will also have to pay special attention to tape positioning. Errors in
7763 positioning may overwrite the valuable data already on your tape. Many
7764 people, burnt by past experiences, will only use rewinding devices and
7765 limit themselves to one file per tape, precisely to avoid the risk of
7766 such errors. Be fully aware that writing at the wrong position on a
7767 tape loses all information past this point and most probably until the
7768 end of the tape, and this destroyed information @emph{cannot} be
7771 To save @var{directory-1} as a first archive at the beginning of a
7772 tape, and leave that tape ready for a second archive, you should use:
7775 $ @kbd{mt -f /dev/nrtape rewind}
7776 $ @kbd{tar cf /dev/nrtape @var{directory-1}}
7780 @dfn{Tape marks} are special magnetic patterns written on the tape
7781 media, which are later recognizable by the reading hardware. These
7782 marks are used after each file, when there are many on a single tape.
7783 An empty file (that is to say, two tape marks in a row) signal the
7784 logical end of the tape, after which no file exist. Usually,
7785 non-rewinding tape device drivers will react to the close request issued
7786 by @command{tar} by first writing two tape marks after your archive, and by
7787 backspacing over one of these. So, if you remove the tape at that time
7788 from the tape drive, it is properly terminated. But if you write
7789 another file at the current position, the second tape mark will be
7790 erased by the new information, leaving only one tape mark between files.
7792 So, you may now save @var{directory-2} as a second archive after the
7793 first on the same tape by issuing the command:
7796 $ @kbd{tar cf /dev/nrtape @var{directory-2}}
7800 and so on for all the archives you want to put on the same tape.
7802 Another usual case is that you do not write all the archives the same
7803 day, and you need to remove and store the tape between two archive
7804 sessions. In general, you must remember how many files are already
7805 saved on your tape. Suppose your tape already has 16 files on it, and
7806 that you are ready to write the 17th. You have to take care of skipping
7807 the first 16 tape marks before saving @var{directory-17}, say, by using
7811 $ @kbd{mt -f /dev/nrtape rewind}
7812 $ @kbd{mt -f /dev/nrtape fsf 16}
7813 $ @kbd{tar cf /dev/nrtape @var{directory-17}}
7816 In all the previous examples, we put aside blocking considerations, but
7817 you should do the proper things for that as well. @xref{Blocking}.
7820 * Tape Positioning:: Tape Positions and Tape Marks
7821 * mt:: The @command{mt} Utility
7824 @node Tape Positioning
7825 @subsection Tape Positions and Tape Marks
7828 Just as archives can store more than one file from the file system,
7829 tapes can store more than one archive file. To keep track of where
7830 archive files (or any other type of file stored on tape) begin and
7831 end, tape archive devices write magnetic @dfn{tape marks} on the
7832 archive media. Tape drives write one tape mark between files,
7833 two at the end of all the file entries.
7835 If you think of data as a series of records "rrrr"'s, and tape marks as
7836 "*"'s, a tape might look like the following:
7839 rrrr*rrrrrr*rrrrr*rr*rrrrr**-------------------------
7842 Tape devices read and write tapes using a read/write @dfn{tape
7843 head}---a physical part of the device which can only access one
7844 point on the tape at a time. When you use @command{tar} to read or
7845 write archive data from a tape device, the device will begin reading
7846 or writing from wherever on the tape the tape head happens to be,
7847 regardless of which archive or what part of the archive the tape
7848 head is on. Before writing an archive, you should make sure that no
7849 data on the tape will be overwritten (unless it is no longer needed).
7850 Before reading an archive, you should make sure the tape head is at
7851 the beginning of the archive you want to read. (The @code{restore}
7852 script will find the archive automatically. @FIXME{There is no such
7853 restore script!}@FIXME-xref{Scripted Restoration}@xref{mt}, for
7854 an explanation of the tape moving utility.
7856 If you want to add new archive file entries to a tape, you should
7857 advance the tape to the end of the existing file entries, backspace
7858 over the last tape mark, and write the new archive file. If you were
7859 to add two archives to the example above, the tape might look like the
7863 rrrr*rrrrrr*rrrrr*rr*rrrrr*rrr*rrrr**----------------
7867 @subsection The @command{mt} Utility
7870 @FIXME{Is it true that this only works on non-block devices?
7871 should explain the difference, (fixed or variable).}
7872 @value{xref-blocking-factor}.
7874 You can use the @command{mt} utility to advance or rewind a tape past a
7875 specified number of archive files on the tape. This will allow you
7876 to move to the beginning of an archive before extracting or reading
7877 it, or to the end of all the archives before writing a new one.
7878 @FIXME{Why isn't there an "advance 'til you find two tape marks
7881 The syntax of the @command{mt} command is:
7884 @kbd{mt [-f @var{tapename}] @var{operation} [@var{number}]}
7887 where @var{tapename} is the name of the tape device, @var{number} is
7888 the number of times an operation is performed (with a default of one),
7889 and @var{operation} is one of the following:
7891 @FIXME{is there any use for record operations?}
7896 Writes @var{number} tape marks at the current position on the tape.
7899 Moves tape position forward @var{number} files.
7902 Moves tape position back @var{number} files.
7905 Rewinds the tape. (Ignores @var{number}).
7909 Rewinds the tape and takes the tape device off-line. (Ignores @var{number}).
7912 Prints status information about the tape unit.
7916 @FIXME{Is there a better way to frob the spacing on the list?}
7918 If you don't specify a @var{tapename}, @command{mt} uses the environment
7919 variable @env{TAPE}; if @env{TAPE} is not set, @command{mt} uses the device
7922 @command{mt} returns a 0 exit status when the operation(s) were
7923 successful, 1 if the command was unrecognized, and 2 if an operation
7926 @FIXME{New node on how to find an archive?}
7928 If you use @value{op-extract} with the @value{op-label} option specified,
7929 @command{tar} will read an archive label (the tape head has to be positioned
7930 on it) and print an error if the archive label doesn't match the
7931 @var{archive-name} specified. @var{archive-name} can be any regular
7932 expression. If the labels match, @command{tar} extracts the archive.
7934 @FIXME-xref{Matching Format Parameters}@FIXME{fix cross
7935 references}@samp{tar --list --label} will cause @command{tar} to print the
7938 @FIXME{Program to list all the labels on a tape?}
7940 @node Using Multiple Tapes
7941 @section Using Multiple Tapes
7944 Often you might want to write a large archive, one larger than will fit
7945 on the actual tape you are using. In such a case, you can run multiple
7946 @command{tar} commands, but this can be inconvenient, particularly if you
7947 are using options like @value{op-exclude} or dumping entire filesystems.
7948 Therefore, @command{tar} supports multiple tapes automatically.
7950 Use @value{op-multi-volume} on the command line, and then @command{tar} will,
7951 when it reaches the end of the tape, prompt for another tape, and
7952 continue the archive. Each tape will have an independent archive, and
7953 can be read without needing the other. (As an exception to this, the
7954 file that @command{tar} was archiving when it ran out of tape will usually
7955 be split between the two archives; in this case you need to extract from
7956 the first archive, using @value{op-multi-volume}, and then put in the
7957 second tape when prompted, so @command{tar} can restore both halves of the
7960 @sc{gnu} @command{tar} multi-volume archives do not use a truly portable format.
7961 You need @sc{gnu} @command{tar} at both end to process them properly.
7963 When prompting for a new tape, @command{tar} accepts any of the following
7968 Request @command{tar} to explain possible responses
7970 Request @command{tar} to exit immediately.
7971 @item n @var{file name}
7972 Request @command{tar} to write the next volume on the file @var{file name}.
7974 Request @command{tar} to run a subshell.
7976 Request @command{tar} to begin writing the next volume.
7979 (You should only type @samp{y} after you have changed the tape;
7980 otherwise @command{tar} will write over the volume it just finished.)
7982 If you want more elaborate behavior than this, give @command{tar} the
7983 @value{op-info-script} option. The file @var{script-name} is expected
7984 to be a program (or shell script) to be run instead of the normal
7985 prompting procedure. When the program finishes, @command{tar} will
7986 immediately begin writing the next volume. The behavior of the
7987 @samp{n} response to the normal tape-change prompt is not available
7988 if you use @value{op-info-script}.
7990 The method @command{tar} uses to detect end of tape is not perfect, and
7991 fails on some operating systems or on some devices. You can use the
7992 @value{op-tape-length} option if @command{tar} can't detect the end of the
7993 tape itself. This option selects @value{op-multi-volume} automatically.
7994 The @var{size} argument should then be the usable size of the tape.
7995 But for many devices, and floppy disks in particular, this option is
7996 never required for real, as far as we know.
7998 The volume number used by @command{tar} in its tape-change prompt
7999 can be changed; if you give the @value{op-volno-file} option, then
8000 @var{file-of-number} should be an unexisting file to be created, or else,
8001 a file already containing a decimal number. That number will be used
8002 as the volume number of the first volume written. When @command{tar} is
8003 finished, it will rewrite the file with the now-current volume number.
8004 (This does not change the volume number written on a tape label, as
8005 per @value{ref-label}, it @emph{only} affects the number used in
8008 If you want @command{tar} to cycle through a series of tape drives, then
8009 you can use the @samp{n} response to the tape-change prompt. This is
8010 error prone, however, and doesn't work at all with @value{op-info-script}.
8011 Therefore, if you give @command{tar} multiple @value{op-file} options, then
8012 the specified files will be used, in sequence, as the successive volumes
8013 of the archive. Only when the first one in the sequence needs to be
8014 used again will @command{tar} prompt for a tape change (or run the info
8017 Multi-volume archives
8019 With @value{op-multi-volume}, @command{tar} will not abort when it cannot
8020 read or write any more data. Instead, it will ask you to prepare a new
8021 volume. If the archive is on a magnetic tape, you should change tapes
8022 now; if the archive is on a floppy disk, you should change disks, etc.
8024 Each volume of a multi-volume archive is an independent @command{tar}
8025 archive, complete in itself. For example, you can list or extract any
8026 volume alone; just don't specify @value{op-multi-volume}. However, if one
8027 file in the archive is split across volumes, the only way to extract
8028 it successfully is with a multi-volume extract command @samp{--extract
8029 --multi-volume} (@samp{-xM}) starting on or before the volume where
8032 For example, let's presume someone has two tape drives on a system
8033 named @file{/dev/tape0} and @file{/dev/tape1}. For having @sc{gnu}
8034 @command{tar} to switch to the second drive when it needs to write the
8035 second tape, and then back to the first tape, etc., just do either of:
8038 $ @kbd{tar --create --multi-volume --file=/dev/tape0 --file=/dev/tape1 @var{files}}
8039 $ @kbd{tar cMff /dev/tape0 /dev/tape1 @var{files}}
8043 * Multi-Volume Archives:: Archives Longer than One Tape or Disk
8044 * Tape Files:: Tape Files
8047 @node Multi-Volume Archives
8048 @subsection Archives Longer than One Tape or Disk
8049 @cindex Multi-volume archives
8052 To create an archive that is larger than will fit on a single unit of
8053 the media, use the @value{op-multi-volume} option in conjunction with
8054 the @value{op-create} option (@pxref{create}). A
8055 @dfn{multi-volume} archive can be manipulated like any other archive
8056 (provided the @value{op-multi-volume} option is specified), but is
8057 stored on more than one tape or disk.
8059 When you specify @value{op-multi-volume}, @command{tar} does not report an
8060 error when it comes to the end of an archive volume (when reading), or
8061 the end of the media (when writing). Instead, it prompts you to load
8062 a new storage volume. If the archive is on a magnetic tape, you
8063 should change tapes when you see the prompt; if the archive is on a
8064 floppy disk, you should change disks; etc.
8066 You can read each individual volume of a multi-volume archive as if it
8067 were an archive by itself. For example, to list the contents of one
8068 volume, use @value{op-list}, without @value{op-multi-volume} specified.
8069 To extract an archive member from one volume (assuming it is described
8070 that volume), use @value{op-extract}, again without
8071 @value{op-multi-volume}.
8073 If an archive member is split across volumes (ie. its entry begins on
8074 one volume of the media and ends on another), you need to specify
8075 @value{op-multi-volume} to extract it successfully. In this case, you
8076 should load the volume where the archive member starts, and use
8077 @samp{tar --extract --multi-volume}---@command{tar} will prompt for later
8078 volumes as it needs them. @xref{extracting archives}, for more
8079 information about extracting archives.
8081 @value{op-info-script} is like @value{op-multi-volume}, except that
8082 @command{tar} does not prompt you directly to change media volumes when
8083 a volume is full---instead, @command{tar} runs commands you have stored
8084 in @var{script-name}. For example, this option can be used to eject
8085 cassettes, or to broadcast messages such as @samp{Someone please come
8086 change my tape} when performing unattended backups. When @var{script-name}
8087 is done, @command{tar} will assume that the media has been changed.
8089 Multi-volume archives can be modified like any other archive. To add
8090 files to a multi-volume archive, you need to only mount the last
8091 volume of the archive media (and new volumes, if needed). For all
8092 other operations, you need to use the entire archive.
8094 If a multi-volume archive was labeled using @value{op-label}
8095 (@value{pxref-label}) when it was created, @command{tar} will not
8096 automatically label volumes which are added later. To label subsequent
8097 volumes, specify @value{op-label} again in conjunction with the
8098 @value{op-append}, @value{op-update} or @value{op-concatenate} operation.
8100 @cindex Labeling multi-volume archives
8103 @FIXME{There should be a sample program here, including an exit
8104 before end. Is the exit status even checked in tar? :-(}
8107 @item --multi-volume
8109 Creates a multi-volume archive, when used in conjunction with
8110 @value{op-create}. To perform any other operation on a multi-volume
8111 archive, specify @value{op-multi-volume} in conjunction with that
8114 @item --info-script=@var{program-file}
8115 @itemx -F @var{program-file}
8116 Creates a multi-volume archive via a script. Used in conjunction with
8120 Beware that there is @emph{no} real standard about the proper way, for a
8121 @command{tar} archive, to span volume boundaries. If you have a multi-volume
8122 created by some vendor's @command{tar}, there is almost no chance you could
8123 read all the volumes with @sc{gnu} @command{tar}. The converse is also true:
8124 you may not expect multi-volume archives created by @sc{gnu} @command{tar} to
8125 be fully recovered by vendor's @command{tar}. Since there is little chance
8126 that, in mixed system configurations, some vendor's @command{tar} will work on
8127 another vendor's machine, and there is a great chance that @sc{gnu} @command{tar}
8128 will work on most of them, your best bet is to install @sc{gnu} @command{tar}
8129 on all machines between which you know exchange of files is possible.
8132 @subsection Tape Files
8135 To give the archive a name which will be recorded in it, use the
8136 @value{op-label} option. This will write a special block identifying
8137 @var{volume-label} as the name of the archive to the front of the archive
8138 which will be displayed when the archive is listed with @value{op-list}.
8139 If you are creating a multi-volume archive with
8140 @value{op-multi-volume}@FIXME-pxref{Using Multiple Tapes}, then the
8141 volume label will have
8142 @samp{Volume @var{nnn}} appended to the name you give, where @var{nnn} is
8143 the number of the volume of the archive. (If you use the @value{op-label}
8144 option when reading an archive, it checks to make sure the label on the
8145 tape matches the one you give. @value{xref-label}.
8147 When @command{tar} writes an archive to tape, it creates a single
8148 tape file. If multiple archives are written to the same tape, one
8149 after the other, they each get written as separate tape files. When
8150 extracting, it is necessary to position the tape at the right place
8151 before running @command{tar}. To do this, use the @command{mt} command.
8152 For more information on the @command{mt} command and on the organization
8153 of tapes into a sequence of tape files, see @ref{mt}.
8155 People seem to often do:
8158 @kbd{--label="@var{some-prefix} `date +@var{some-format}`"}
8161 or such, for pushing a common date in all volumes or an archive set.
8164 @section Including a Label in the Archive
8165 @cindex Labeling an archive
8166 @cindex Labels on the archive media
8171 @itemx --label=@var{name}
8172 Create archive with volume name @var{name}.
8175 This option causes @command{tar} to write out a @dfn{volume header} at
8176 the beginning of the archive. If @value{op-multi-volume} is used, each
8177 volume of the archive will have a volume header of @samp{@var{name}
8178 Volume @var{n}}, where @var{n} is 1 for the first volume, 2 for the
8181 @FIXME{Should the arg to --label be a quoted string?? No.}
8183 To avoid problems caused by misplaced paper labels on the archive
8184 media, you can include a @dfn{label} entry---an archive member which
8185 contains the name of the archive---in the archive itself. Use the
8186 @value{op-label} option in conjunction with the @value{op-create} operation
8187 to include a label entry in the archive as it is being created.
8189 If you create an archive using both @value{op-label} and
8190 @value{op-multi-volume}, each volume of the archive will have an
8191 archive label of the form @samp{@var{archive-label} Volume @var{n}},
8192 where @var{n} is 1 for the first volume, 2 for the next, and so on.
8193 @FIXME-xref{Multi-Volume Archives, for information on creating multiple
8196 If you list or extract an archive using @value{op-label}, @command{tar} will
8197 print an error if the archive label doesn't match the @var{archive-label}
8198 specified, and will then not list nor extract the archive. In those cases,
8199 @var{archive-label} argument is interpreted as a globbing-style pattern
8200 which must match the actual magnetic volume label. @xref{exclude}, for
8201 a precise description of how match is attempted@footnote{Previous versions
8202 of @command{tar} used full regular expression matching, or before that, only
8203 exact string matching, instead of wildcard matchers. We decided for the
8204 sake of simplicity to use a uniform matching device through @command{tar}.}.
8205 If the switch @value{op-multi-volume} is being used, the volume label
8206 matcher will also suffix @var{archive-label} by @w{@samp{ Volume [1-9]*}}
8207 if the initial match fails, before giving up. Since the volume numbering
8208 is automatically added in labels at creation time, it sounded logical to
8209 equally help the user taking care of it when the archive is being read.
8211 The @value{op-label} was once called @samp{--volume}, but is not available
8212 under that name anymore.
8214 To find out an archive's label entry (or to find out if an archive has
8215 a label at all), use @samp{tar --list --verbose}. @command{tar} will print the
8216 label first, and then print archive member information, as in the
8220 $ @kbd{tar --verbose --list --file=iamanarchive}
8221 V--------- 0 0 0 1992-03-07 12:01 iamalabel--Volume Header--
8222 -rw-rw-rw- ringo user 40 1990-05-21 13:30 iamafilename
8226 @item --label=@var{archive-label}
8227 @itemx -V @var{archive-label}
8228 Includes an @dfn{archive-label} at the beginning of the archive when
8229 the archive is being created, when used in conjunction with the
8230 @value{op-create} option. Checks to make sure the archive label
8231 matches the one specified (when used in conjunction with the
8232 @value{op-extract} option.
8235 To get a common information on all tapes of a series, use the
8236 @value{op-label} option. For having this information different in each
8237 series created through a single script used on a regular basis, just
8238 manage to get some date string as part of the label. For example:
8241 $ @kbd{tar cfMV /dev/tape "Daily backup for `date +%Y-%m-%d`"}
8242 $ @kbd{tar --create --file=/dev/tape --multi-volume \
8243 --volume="Daily backup for `date +%Y-%m-%d`"}
8246 Also note that each label has its own date and time, which corresponds
8247 to when @sc{gnu} @command{tar} initially attempted to write it, often soon
8248 after the operator launches @command{tar} or types the carriage return
8249 telling that the next tape is ready. Comparing date labels does give
8250 an idea of tape throughput only if the delays for rewinding tapes
8251 and the operator switching them were negligible, which is usually
8254 @FIXME{was --volume}
8257 @section Verifying Data as It is Stored
8258 @cindex Verifying a write operation
8259 @cindex Double-checking a write operation
8264 Attempt to verify the archive after writing.
8267 This option causes @command{tar} to verify the archive after writing it.
8268 Each volume is checked after it is written, and any discrepancies
8269 are recorded on the standard error output.
8271 Verification requires that the archive be on a back-space-able medium.
8272 This means pipes, some cartridge tape drives, and some other devices
8275 You can insure the accuracy of an archive by comparing files in the
8276 system with archive members. @command{tar} can compare an archive to the
8277 file system as the archive is being written, to verify a write
8278 operation, or can compare a previously written archive, to insure that
8281 To check for discrepancies in an archive immediately after it is
8282 written, use the @value{op-verify} option in conjunction with
8283 the @value{op-create} operation. When this option is
8284 specified, @command{tar} checks archive members against their counterparts
8285 in the file system, and reports discrepancies on the standard error.
8287 To verify an archive, you must be able to read it from before the end
8288 of the last written entry. This option is useful for detecting data
8289 errors on some tapes. Archives written to pipes, some cartridge tape
8290 drives, and some other devices cannot be verified.
8292 One can explicitly compare an already made archive with the file system
8293 by using the @value{op-compare} option, instead of using the more automatic
8294 @value{op-verify} option. @value{xref-compare}.
8296 Note that these two options have a slightly different intent. The
8297 @value{op-compare} option how identical are the logical contents of some
8298 archive with what is on your disks, while the @value{op-verify} option is
8299 really for checking if the physical contents agree and if the recording
8300 media itself is of dependable quality. So, for the @value{op-verify}
8301 operation, @command{tar} tries to defeat all in-memory cache pertaining to
8302 the archive, while it lets the speed optimization undisturbed for the
8303 @value{op-compare} option. If you nevertheless use @value{op-compare} for
8304 media verification, you may have to defeat the in-memory cache yourself,
8305 maybe by opening and reclosing the door latch of your recording unit,
8306 forcing some doubt in your operating system about the fact this is really
8307 the same volume as the one just written or read.
8309 The @value{op-verify} option would not be necessary if drivers were indeed
8310 able to detect dependably all write failures. This sometimes require many
8311 magnetic heads, some able to read after the writes occurred. One would
8312 not say that drivers unable to detect all cases are necessarily flawed,
8313 as long as programming is concerned.
8315 The @value{op-verify} option will not work in conjunction with the
8316 @value{op-multi-volume} option or the @value{op-append},
8317 @value{op-update} and @value{op-delete} operations. @xref{Operations},
8318 for more information on these operations.
8320 @node Write Protection
8321 @section Write Protection
8323 Almost all tapes and diskettes, and in a few rare cases, even disks can
8324 be @dfn{write protected}, to protect data on them from being changed.
8325 Once an archive is written, you should write protect the media to prevent
8326 the archive from being accidentally overwritten or deleted. (This will
8327 protect the archive from being changed with a tape or floppy drive---it
8328 will not protect it from magnet fields or other physical hazards).
8330 The write protection device itself is usually an integral part of the
8331 physical media, and can be a two position (write enabled/write
8332 disabled) switch, a notch which can be popped out or covered, a ring
8333 which can be removed from the center of a tape reel, or some other
8348 @c texinfo-column-for-description: 32