copyediting for Usenix manuals
[unix-history] / usr / src / usr.sbin / mtree / mtree.8
CommitLineData
47d3c023
KB
1.\" Copyright (c) 1989, 1990, 1993
2.\" The Regents of the University of California. All rights reserved.
25f14064 3.\"
804e6434 4.\" %sccs.include.redist.roff%
25f14064 5.\"
653ba8b6 6.\" @(#)mtree.8 8.2 (Berkeley) %G%
25f14064 7.\"
b5dc1377
CL
8.Dd
9.Dt MTREE 8
ee9b0a0a 10.Os
b5dc1377
CL
11.Sh NAME
12.Nm mtree
13.Nd map a directory hierarchy
14.Sh SYNOPSIS
15.Nm mtree
16.Op Fl cderux
17.Op Fl f Ar spec
275bb093
KB
18.Op Fl K Ar keywords
19.Op Fl k Ar keywords
b5dc1377 20.Op Fl p Ar path
275bb093 21.Op Fl s Ar seed
b5dc1377 22.Sh DESCRIPTION
804e6434
CL
23The utility
24.Nm mtree
275bb093
KB
25compares the file hierarchy rooted in the current directory against a
26specification read from the standard input.
27Messages are written to the standard output for any files whose
653ba8b6 28characteristics do not match the specifications, or which are
275bb093 29missing from either the file hierarchy or the specification.
b5dc1377 30.Pp
25f14064 31The options are as follows:
8d03b40e 32.Bl -tag -width flag
804e6434 33.It Fl c
275bb093 34Print a specification for the file hierarchy to the standard output.
804e6434 35.It Fl d
f33455dd 36Ignore everything except directory type files.
804e6434 37.It Fl e
275bb093
KB
38Don't complain about files that are in the file hierarchy, but not in the
39specification.
804e6434 40.It Fl f
f33455dd 41Read the specification from
b5dc1377 42.Ar file ,
275bb093
KB
43instead of from the standard input.
44.It Fl K
45Add the specified (whitespace or comma separated) keywords to the current
46set of keywords.
47.It Fl k
48Use the ``type'' keyword plus the specified (whitespace or comma separated)
49keywords instead of the current set of keywords.
804e6434 50.It Fl p
275bb093 51Use the file hierarchy rooted in
b5dc1377 52.Ar path ,
f33455dd 53instead of the current directory.
804e6434 54.It Fl r
275bb093 55Remove any files in the file hierarchy that are not described in the
25f14064 56specification.
275bb093
KB
57.It Fl s
58Display a single checksum to the standard error output that represents all
59of the files for which the keyword
60.Cm cksum
61was specified.
62The checksum is seeded with the specified value.
804e6434 63.It Fl u
f33455dd 64Modify the owner, group, and permissions of existing files to match
275bb093
KB
65the specification and create any missing directories.
66User, group, and permissions must all be specified for missing directories
67to be created.
804e6434 68.It Fl x
275bb093 69Don't descend below mount points in the file hierarchy.
804e6434 70.El
b5dc1377 71.Pp
f33455dd
KB
72Specifications are mostly composed of ``keywords'', i.e. strings that
73that specify values relating to files.
275bb093 74No keywords have default values, and if a keyword has no value set, no
f33455dd 75checks based on it are performed.
b5dc1377 76.Pp
25f14064 77Currently supported keywords are as follows:
804e6434
CL
78.Bl -tag -width Cm
79.It Cm cksum
275bb093
KB
80The checksum of the file using the default algorithm specified by
81the
82.Xr cksum 1
83utility.
804e6434 84.It Cm ignore
275bb093
KB
85Ignore any file hierarchy below this file.
86.It Cm gid
87The file group as a numeric value.
88.It Cm gname
89The file group as a symbolic name.
804e6434 90.It Cm mode
275bb093
KB
91The current file's permissions as a numeric (octal) or symbolic
92value.
804e6434 93.It Cm nlink
f33455dd 94The number of hard links the file is expected to have.
275bb093
KB
95.It Cm uid
96The file owner as a numeric value.
97.It Cm uname
98The file group as a symbolic name.
804e6434 99.It Cm size
f33455dd 100The size, in bytes, of the file.
804e6434 101.It Cm link
275bb093 102The file the symbolic link is expected to reference.
804e6434 103.It Cm time
0af6fb71 104The last modification time of the file.
804e6434 105.It Cm type
f33455dd 106The type of the file; may be set to any one of the following:
275bb093 107.sp
8d03b40e 108.Bl -tag -width Cm -compact
804e6434 109.It Cm block
f33455dd 110block special device
804e6434 111.It Cm char
f33455dd 112character special device
804e6434 113.It Cm dir
f33455dd 114directory
804e6434 115.It Cm fifo
f33455dd 116fifo
804e6434 117.It Cm file
f33455dd 118regular file
804e6434 119.It Cm link
f33455dd 120symbolic link
804e6434 121.It Cm socket
f33455dd 122socket
804e6434
CL
123.El
124.El
b5dc1377 125.Pp
275bb093
KB
126The default set of keywords are
127.Cm gid ,
128.Cm mode ,
129.Cm nlink ,
130.Cm size ,
131.Cm slink ,
132.Cm time ,
133and
134.Cm uid .
135.Pp
f33455dd 136There are four types of lines in a specification.
b5dc1377 137.Pp
275bb093
KB
138The first type of line sets a global value for a keyword, and consists of
139the string ``/set'' followed by whitespace, followed by sets of keyword/value
140pairs, separated by whitespace.
141Keyword/value pairs consist of a keyword, followed by an equals sign
142(``=''), followed by a value, without whitespace characters.
f33455dd 143Once a keyword has been set, its value remains unchanged until either
275bb093 144reset or unset.
b5dc1377 145.Pp
275bb093 146The second type of line unsets keywords and consists of the string
f33455dd
KB
147``/unset'', followed by whitespace, followed by one or more keywords,
148separated by whitespace.
b5dc1377 149.Pp
f33455dd
KB
150The third type of line is a file specification and consists of a file
151name, followed by whitespace, followed by zero or more whitespace
152separated keyword/value pairs.
275bb093 153The file name may be preceded by whitespace characters.
f33455dd
KB
154The file name may contain any of the standard file name matching
155characters (``['', ``]'', ``?'' or ``*''), in which case files
156in the hierarchy will be associated with the first pattern that
157they match.
b5dc1377 158.Pp
f33455dd 159Each of the keyword/value pairs consist of a keyword, followed by an
275bb093
KB
160equals sign (``=''), followed by the keyword's value, without
161whitespace characters.
f33455dd 162These values override, without changing, the global value of the
25f14064 163corresponding keyword.
b5dc1377 164.Pp
25f14064 165All paths are relative.
f33455dd
KB
166Specifying a directory will cause subsequent files to be searched
167for in that directory hierarchy.
25f14064 168Which brings us to the last type of line in a specification: a line
b5dc1377
CL
169containing only the string
170.Dq Nm \&..
171causes the current directory
f33455dd 172path to ascend one level.
b5dc1377 173.Pp
f33455dd
KB
174Empty lines and lines whose first non-whitespace character is a hash
175mark (``#'') are ignored.
b5dc1377 176.Pp
275bb093
KB
177The
178.Nm mtree
179utility exits with a status of 0 on success, 1 if any error occurred,
180and 2 if the file hierarchy did not match the specification.
181.Sh EXAMPLES
182To detect system binaries that have been ``trojan horsed'', it is recommended
183that
184.Nm mtree
185be run on the file systems, and a copy of the results stored on a different
186machine, or, at least, in encrypted form.
187The seed for the
188.Fl s
189option should not be an obvious value and the final checksum should not be
190stored on-line under any circumstances!
191Then, periodically,
192.Nm mtree
193should be run against the on-line specifications and the final checksum
194compared with the previous value.
195While it is possible for the bad guys to change the on-line specifications
196to conform to their modified binaries, it shouldn't be possible for them
197to make it produce the same final checksum value.
198If the final checksum value changes, the off-line copies of the specification
199can be used to detect which of the binaries have actually been modified.
200.Pp
201The
202.Fl d
203and
204.Fl u
205options can be used in combination to create directory hierarchies
206for distributions and other such things.
b5dc1377 207.Sh FILES
804e6434
CL
208.Bl -tag -width /etc/mtree -compact
209.It Pa /etc/mtree
b5dc1377 210system specification directory
804e6434 211.El
b5dc1377
CL
212.Sh SEE ALSO
213.Xr chmod 1 ,
214.Xr chown 1 ,
215.Xr chgrp 1 ,
216.Xr cksum 1 ,
b5dc1377
CL
217.Xr stat 2 ,
218.Xr fts 3 ,
b5dc1377 219.Sh HISTORY
804e6434
CL
220The
221.Nm mtree
222utility appeared in
223.Bx 4.3 Reno .