|Main index||Section 8||Options|
The default action, if not overridden by command line options, is to compare the file hierarchy rooted in the current directory against a specification read from the standard input. Messages are written to the standard output for any files whose characteristics do not match the specification, or which are missing from either the file hierarchy or the specification.
The options are as follows:
| ||Suppress blank lines before entering and after exiting directories.|
Convert a specification into
a format that's easier to parse with various tools.
The input specification is read from standard input or
from the file given by
Print a specification for the file hierarchy originating at
the current working directory (or the directory provided by
| ||Ignore everything except directory type files.|
Add the comma separated tags to the
Non-directories with tags which are in the exclusion list are not printed with
| ||Don't complain about files that are in the file hierarchy, but not in the specification.|
| ||Set the compatibility flavor of the mtree utility. The flavor can be one of mtree, freebsd9, or netbsd6. The default is mtree. The freebsd9 and netbsd6 flavors attempt to preserve output compatiblity and command line option backward compatibility with FreeBSD 9.0 and NetBSD respectively.|
Read the specification from
instead of from the standard input.
If this option is specified twice, the two specifications are compared
to each other rather than to the file hierarchy.
The specifications will be sorted like output generated using
Add the comma separated tags to the
Non-directories with tags which are in the inclusion list are printed with
| ||If specified, set the schg and/or sappnd flags.|
Indent the output 4 spaces each time a directory level is descended when
creating a specification with the
| ||Add the specified (whitespace or comma separated) keywords to the current set of keywords. If ‘all’ is specified, add all of the other keywords.|
keyword plus the specified (whitespace or comma separated)
keywords instead of the current set of keywords.
is specified, use all of the other keywords.
keyword is not desired, suppress it with
| ||Follow all symbolic links in the file hierarchy.|
permissions checks, in which more stringent permissions
will match less stringent ones.
For example, a file marked mode 0444
will pass a check for mode 0644.
checks apply only to read, write and execute permissions -- in
particular, if other bits like the sticky bit or suid/sgid bits are
set either in the specification or the file, exact checking will be
This option may not be set at the same time as the
| ||Permit merging of specification entries with different types, with the last entry taking precedence.|
| ||If the schg and/or sappnd flags are specified, reset these flags. Note that this is only possible with securelevel less than 1 (i.e., in single user mode or while the system is running in insecure mode). See init(8) for information on security levels.|
Do not emit pathname comments when creating a specification.
a comment is emitted before each directory and before the close of that
directory when using the
| ||Use the user database text file master.passwd and group database text file group from dbdir, rather than using the results from the system's getpwnam(3) and getgrnam(3) (and related) library calls.|
|Only include files included in this list of pathnames.|
| ||Don't follow symbolic links in the file hierarchy, instead consider the symbolic link itself in any comparisons. This is the default.|
| ||Use the file hierarchy rooted in path, instead of the current directory.|
| ||Quiet mode. Do not complain when a "missing" directory cannot be created because it already exists. This occurs when the directory is a symbolic link.|
| ||Remove the specified (whitespace or comma separated) keywords from the current set of keywords. If ‘all’ is specified, remove all of the other keywords.|
| ||Remove any files in the file hierarchy that are not described in the specification.|
When reading a specification into an internal data structure,
sort the entries.
Sorting will affect the order of the output produced by the
The sort order is the same as that used by the
| ||Display a single checksum to the standard error output that represents all of the files for which the keyword cksum was specified. The checksum is seeded with the specified value.|
| ||Modify the modified time of existing files, the device type of devices, and symbolic link targets, to match the specification.|
Modify the owner, group, permissions, and flags of existing files,
the device type of devices, and symbolic link targets,
to match the specification.
Create any missing directories, devices or symbolic links.
User, group, and permissions must all be specified for missing directories
to be created.
Note that unless the
Don't attempt to set various file attributes such as the
ownership, mode, flags, or time
when creating new directories or changing existing entries.
This option will be most useful when used in conjunction with
|The specified file contains fnmatch(3) patterns matching files to be excluded from the specification, one to a line. If the pattern contains a ‘/’ character, it will be matched against entire pathnames (relative to the starting directory); otherwise, it will be matched against basenames only. Comments are permitted in the exclude-list file.|
| ||Don't descend below mount points in the file hierarchy.|
Specifications are mostly composed of "keywords", i.e. strings that that specify values relating to files. No keywords have default values, and if a keyword has no value set, no checks based on it are performed.
Currently supported keywords are as follows:
|cksum||The checksum of the file using the default algorithm specified by the cksum(1) utility.|
|device||The device number to use for block or char file types. The argument must be one of the following forms:|
|format ,major ,minor|
|A device with major and minor fields, for an operating system specified with format. See below for valid formats.|
|format ,major ,unit ,subunit|
|A device with major, unit, and subunit fields, for an operating system specified with format. (Currently this is only supported by the bsdos format.)|
|Opaque number (as stored on the file system).|
The following values for format are recognized: native, 386bsd, 4bsd, bsdos, freebsd, hpux, isc, linux, netbsd, osf1, sco, solaris, sunos, svr3, svr4, and ultrix.
See mknod(8) for more details.
The file flags as a symbolic name.
for information on these names.
If no flags are to be set the string
may be used to override the current default.
Note that the schg and sappnd flags are treated specially (see the
|Ignore any file hierarchy below this file.|
|gid||The file group as a numeric value.|
|gname||The file group as a symbolic name.|
|link||The file the symbolic link is expected to reference.|
|md5||The MD5 cryptographic message digest of the file.|
|Synonym for md5.|
|mode||The current file's permissions as a numeric (octal) or symbolic value.|
|nlink||The number of hard links the file is expected to have.|
|Make sure this file or directory exists but otherwise ignore all attributes.|
|The file is optional; don't complain about the file if it's not in the file hierarchy.|
|Synonym for rmd160.|
|The RMD-160 cryptographic message digest of the file.|
|Synonym for rmd160.|
|sha1||The SHA-1 cryptographic message digest of the file.|
|Synonym for sha1.|
|The 256-bits SHA-2 cryptographic message digest of the file.|
|Synonym for sha256.|
|The 384-bits SHA-2 cryptographic message digest of the file.|
|Synonym for sha384.|
|The 512-bits SHA-2 cryptographic message digest of the file.|
|Synonym for sha512.|
|size||The size, in bytes, of the file.|
Comma delimited tags to be matched with
|time||The last modification time of the file, in second and nanoseconds. The value should include a period character and exactly nine digits after the period.|
The type of the file; may be set to any one of the following:
|block||block special device|
|char||character special device|
|uid||The file owner as a numeric value.|
|uname||The file owner as a symbolic name.|
The default set of keywords are flags, gid, link, mode, nlink, size, time, type, and uid.
There are four types of lines in a specification:
The path name may be preceded by whitespace characters. The path name may contain any of the standard path name matching characters ( ‘[’, ‘]’, ‘?’ or ‘*’ ), in which case files in the hierarchy will be associated with the first pattern that they match. mtree uses strsvis(3) (in VIS_CSTYLE format) to encode path names containing non-printable characters. Whitespace characters are encoded as ‘\s’ (space), ‘\t’ (tab), and ‘\n’ (new line). ‘#’ characters in path names are escaped by a preceding backslash ‘\’ to distinguish them from comments.
Each of the keyword/value pairs consist of a keyword, followed by an equals sign (‘=’), followed by the keyword's value, without whitespace characters. These values override, without changing, the global value of the corresponding keyword.
The first path name entry listed must be a directory named ‘.’, as this ensures that intermixing full and relative path names will work consistently and correctly. Multiple entries for a directory named ‘.’ are permitted; the settings for the last such entry override those of the existing entry.
A path name that contains a slash
that is not the first character will be treated as a full path
(relative to the root of the tree).
All parent directories referenced in the path name must exist.
The current directory path used by relative path names will be updated
Multiple entries for the same full path are permitted if the types
are the same (unless
A path name that does not contain a slash will be treated as a relative path. Specifying a directory will cause subsequent files to be searched for in that directory hierarchy.
Empty lines and lines whose first non-whitespace character is a hash mark (‘#’) are ignored.
The mtree utility exits with a status of 0 on success, 1 if any error occurred, and 2 if the file hierarchy did not match the specification.
|system specification directory|
flavor retains the default handling of lookup failures for the
keywords by replacing them with appropriate
keywords rather than failing and reporting an error.
The netbsd6 flavor does not replicate the historical bug that reported time as seconds.nanoseconds without zero padding nanosecond values less than 100000000.
|MTREE (8)||February 3, 2013|
|Main index||Section 8||Options|
|“||As soon as we started programming, we found to our surprise that it wasn't as easy to get programs right as we had thought. Debugging had to be discovered. I can remember the exact instant when I realized that a large part of my life from then on was going to be spent in finding mistakes in my own programs.||”|
|— Maurice Wilkes|