Home
Search all pages
Subjects
By activity
Professions, Sciences, Humanities, Business, ...
User Interface
Text-based, GUI, Audio, Video, Keyboards, Mouse, Images,...
Text Strings
Conversions, tests, processing, manipulation,...
Math
Integer, Floating point, Matrix, Statistics, Boolean, ...
Processing
Algorithms, Memory, Process control, Debugging, ...
Stored Data
Data storage, Integrity, Encryption, Compression, ...
Communications
Networks, protocols, Interprocess, Remote, Client Server, ...
Hard World Timing, Calendar and Clock, Audio, Video, Printer, Controls...
File System
Management, Filtering, File & Directory access, Viewers, ...
|
|
|
RocketLink!--> Man page versions:
OpenBSD
FreeBSD
NetBSD
Others
MTREE(8) OpenBSD System Manager's Manual MTREE(8)
NAME
mtree - map a directory hierarchy
SYNOPSIS
mtree [-cdeinrUux] [-f spec] [-K keywords] [-k keywords] [-p path] [-s
seed]
DESCRIPTION
The utility mtree compares the file hierarchy rooted in the current di-
rectory 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:
-c Print a specification for the file hierarchy to the standard out-
put.
-d Ignore everything except directory type files.
-e Don't complain about files that are in the file hierarchy, but not
in the specification.
-f Read the specification from file, instead of from the standard in-
put.
-i Indents the output 4 spaces each time a directory level is descend-
ed when create a specification with the -c option. This does not
effect either the /set statements or the comment before each direc-
tory. It does however effect the comment before the close of each
directory.
-K Add the specified (whitespace or comma separated) keywords to the
current set of keywords.
-k Use the ``type'' keyword plus the specified (whitespace or comma
separated) keywords instead of the current set of keywords.
-n Do not emit pathname comments when creating a specification. Nor-
mally a comment is emitted before each directory and before the
close of that directory when using the -c option.
-p Use the file hierarchy rooted in path, instead of the current di-
rectory.
-r Remove any files in the file hierarchy that are not described in
the specification.
-s Display a single checksum to the standard error output that repre-
sents all of the files for which the keyword cksum was specified.
The checksum is seeded with the specified value.
-t If a file's timestamp is different from the specification,
``touch'' it to match the specification (and list as modified).
-U Modify the owner, group, and permissions of existing files to match
the specification and create any missing directories. User, group,
and permissions must all be specified for missing directories to be
created. Exit with a status of 0 on success, 1 if any error oc-
curred, a mismatch is not considered an error if it was corrected.
-u Same as the -U option except a status of 2 is returned if the file
hierarchy did not match the specification.
-x 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 speci-
fied by the cksum(1) utility.
ignore Ignore any file hierarchy below this file.
gid The file group as a numeric value.
gname The file group as a symbolic name.
md5digest The MD5 message digest of the file.
mode The current file's permissions as a numeric (octal) or sym-
bolic value.
nlink The number of hard links the file is expected to have.
optional The file is optional; don't complain about the file if it's
not in the file hierarchy.
rmd160digest
The RIPEMD-160 message digest of the file.
sha1digest The SHA-1 message digest of the file.
uid The file owner as a numeric value.
uname The file owner as a symbolic name.
size The size, in bytes, of the file.
link The file the symbolic link is expected to reference.
time The last modification time of the file.
type The type of the file; may be set to any one of the following:
block block special device
char character special device
dir directory
fifo fifo
file regular file
link symbolic link
socket socket
The default set of keywords are gid, mode, nlink, size, link, time, and
uid.
There are four types of lines in a specification.
The first type of line sets a global value for a keyword, and consists of
the string ``/set'' followed by whitespace, followed by sets of key-
word/value pairs, separated by whitespace. Keyword/value pairs consist
of a keyword, followed by an equals sign (``=''), followed by a value,
without whitespace characters. Once a keyword has been set, its value
remains unchanged until either reset or unset.
The second type of line unsets keywords and consists of the string ``/un-
set'', followed by whitespace, followed by one or more keywords, separat-
ed by whitespace.
The third type of line is a file specification and consists of a file
name, followed by whitespace, followed by zero or more whitespace sepa-
rated keyword/value pairs. The file name may be preceded by whitespace
characters. The file name may contain any of the standard file name
matching characters (``['', ``]'', ``?'' or ``*''), in which case files
in the hierarchy will be associated with the first pattern that they
match.
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.
All paths are relative. Specifying a directory will cause subsequent
files to be searched for in that directory hierarchy. Which brings us to
the last type of line in a specification: a line containing only the
string ``..'' causes the current directory path to ascend one level.
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 oc-
curred, and 2 if the file hierarchy did not match the specification. A
status of 2 is converted to a status of 0 if the -U option is used.
EXAMPLES
To detect system binaries that have been ``trojan horsed'', it is recom-
mended that mtree -K sha1digest be run on the file systems, and a copy of
the results stored on a different machine, or, at least, in encrypted
form. The output file itself should be digested using the sha1(1) utili-
ty. Then, periodically, mtree and sha1(1) should be run against the on-
line specifications. While it is possible for the bad guys to change the
on-line specifications to conform to their modified binaries, it is be-
lieved to be impractical for them to create a modified specification
which has the same MD5 digest as the original.
The -d and -u options can be used in combination to create directory hi-
erarchies for distributions and other such things; the files in
/etc/mtree were used to create almost all directories in a normal binary
distribution.
FILES
/etc/mtree system specification directory
SEE ALSO
chmod(1), chgrp(1), cksum(1), md5(1), rmd160(1), sha1(1), stat(2),
fts(3), md5(3), rmd160(3), sha1(3), chown(8)
HISTORY
The mtree utility appeared in 4.3BSD-Reno.
OpenBSD 2.3 December 11, 1993 3
Source: OpenBSD 2.6 man pages. Copyright: Portions are copyrighted by BERKELEY SOFTWARE DESIGN, INC., The Regents of the University of California, Massachusetts Institute of Technology, Free Software Foundation, FreeBSD Inc., and others. |
(Corrections, notes, and links courtesy of RocketAware.com)
FreeBSD Sources for mtree(8) OpenBSD sources for mtree(8)
Up to: Directory Access - Accessing directories of files, browsing, management, et al.
Up to: File System Information - Obtaining information of the filesystem as a whole. Status of disk subsystems, capacity, etc.
RocketLink!--> Man page versions:
OpenBSD
FreeBSD
NetBSD
Others
Rapid-Links:
Search | About | Comments | Submit Path: RocketAware > man pages >
mtree.8/
RocketAware.com is a service of Mib Software Copyright 1999, Forrest J. Cavalier III. All Rights Reserved. We welcome submissions and comments
|