xref: /original-bsd/old/tar/tar.1 (revision e59fb703)
1.\" Copyright (c) 1990 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" %sccs.include.proprietary.roff%
5.\"
6.\"	@(#)tar.1	6.11 (Berkeley) 08/09/91
7.\"
8.Dd
9.Dt TAR 1
10.Os ATT 7th
11.Sh NAME
12.Nm tar
13.Nd tape archiver
14.Sh SYNOPSIS
15.Nm tar
16.Op Ar key
17.Op Ar name Ar ...
18.Sh DESCRIPTION
19.Nm Tar
20saves and restores multiple files on a single file (usually a magnetic
21tape, but it can be any file).
22.Nm Tar Ns 's
23actions are controlled by the
24.Ar key
25argument.  The
26.Ar key
27is a string of characters containing at most one function letter and possibly
28one or more function modifiers.  Other arguments to
29.Nm tar
30are file or directory names specifying which files to dump or restore.
31In all cases, appearance of a directory name refers to
32the files and (recursively) subdirectories of that directory.
33.Pp
34The function portion of the key is specified by one of the following letters:
35.Bl -tag -width flag
36.It Cm r
37The named files are written on the end of the tape.  The
38.Cm c
39function implies this.
40.It Cm x
41The named files are extracted from the tape.  If the named file
42matches a directory whose contents had been written onto the tape, this
43directory is (recursively) extracted.  The owner, modification time, and mode
44are restored (if possible).  If no file argument is given, the entire content
45of the tape is extracted.  Note that if multiple entries specifying the same
46file are on the tape, the last one overwrites all earlier.
47.It Cm t
48The names of the specified files are listed each time they occur on
49the tape.  If no file argument is given, all of the names on the tape
50are listed.
51.It Cm u
52The named files are added to the tape if either they are not
53already there or have been modified since last put on the tape.
54.It Cm c
55Create a new tape; writing begins on the beginning of the tape
56instead of after the last file.  This command implies
57.Cm r .
58.El
59.Pp
60The following characters may be used in addition to the letter
61which selects the function desired.
62.Bl -tag -width flag
63.It Cm o
64On output, tar normally places information specifying owner and modes
65of directories in the archive.  Former versions of tar, when encountering
66this information will give error message of the form
67.Pp
68.Dl <name>/: cannot create.
69.Pp
70This modifier will suppress the directory information.
71.It Cm p
72This modifier says to restore files to their original modes,
73ignoring the present
74.Xr umask 2 .
75Setuid and sticky information
76will also be restored to the super-user.
77.It Cm 0 , ... , 9
78This modifier selects an alternate drive on which the tape is mounted.
79The default is drive 0 at 1600 bpi, which is normally
80.Pa /dev/rmt8 .
81.It Cm v
82Normally
83.Nm tar
84does its work silently.  The
85.Cm v
86(verbose) option makes
87.Nm tar
88print the name of each file it treats preceded by the function
89letter.  With the
90.Cm t
91function, the verbose option
92gives more information about the tape entries than just their names.
93.It Cm w
94.Nm Tar
95prints the action to be taken followed by file name, then
96wait for user confirmation. If a word beginning with
97.Ql y
98is given, the action is done. Any other input means don't do it.
99.It Cm f
100.Nm Tar
101uses the next argument as the name of the archive instead of
102/dev/rmt?. If the name of the file is
103.Ql Fl ,
104tar writes to standard output or
105reads from standard input, whichever is appropriate. Thus,
106.Nm tar
107can be used as the head or tail of a filter chain.
108.Nm Tar
109can also be used to move hierarchies with the command
110.Pp
111.Bd -literal -offset indent -compact
112cd fromdir; tar cf - . | (cd todir; tar xf -)
113.Ed
114.It Cm b
115.Nm Tar
116uses the next argument as the blocking factor for tape records. The
117default is 20 (the maximum). This option should only be used with raw magnetic
118tape archives (See
119.Cm f
120above).  The block size is determined automatically
121when reading tapes (key letters
122.Cm x
123and
124.Cm t ) .
125.It Cm s
126tells
127.Nm tar
128to strip off any leading slashes from pathnames.
129.It Cm l
130tells
131.Nm tar
132to complain if it cannot resolve all of the links to the
133files dumped.  If this is not specified, no error messages are printed.
134.It Cm m
135tells
136.Nm tar
137not to restore the modification times.  The modification time
138will be the time of extraction.
139.It Cm h
140Force
141.Nm tar
142to follow symbolic links as if they were normal files or
143directories.  Normally,
144.Nm tar
145does not follow symbolic links.
146.It Cm B
147Forces input and output blocking to 20 blocks per record.  This option
148was added so that
149.Nm tar
150can work across a communications channel where the blocking may not
151be maintained.
152.It Cm C
153If a file name is preceded by
154.Fl C ,
155then
156.Nm tar
157will perform a
158.Xr chdir 2
159to that file name.  This allows multiple directories not
160related by a close common parent to be archived using short
161relative path names.  For example, to archive files from /usr/include
162and from /etc, one might use
163.Pp
164.Bd -literal -offset indent -compact
165tar c -C /usr include -C / etc
166.Ed
167.El
168.Pp
169Previous restrictions dealing with
170.Nm tar Ns 's
171inability to properly handle blocked archives have been lifted.
172.Sh FILES
173.Bl -tag -width /dev/rmtxxx -compact
174.It Pa /dev/rmt?
175.It Pa /tmp/tar*
176.El
177.Sh SEE ALSO
178.Xr tar 5 ,
179.Xr format 5
180.Sh DIAGNOSTICS
181Complaints about bad key characters and tape read/write errors.
182.Pp
183Complaints if enough memory is not available to hold the link tables.
184.Sh BUGS
185There is no way to ask for the
186.Ar n Ns -th
187occurrence of a file.
188.Pp
189Tape errors are handled ungracefully.
190.Pp
191The
192.Cm u
193option can be slow.
194.Pp
195The current limit on file name length is 100 characters.
196.Pp
197There is no way selectively to follow symbolic links.
198.Pp
199When extracting tapes created with the
200.Cm r
201or
202.Cm u
203options, directory modification times may not be set correctly.
204.Sh HISTORY
205The
206.Nm tar
207command appeared in
208.At v7 .
209