Simple fix to big mistake: mtree

by J. Edward Durrett


Occasionally, in the course of working with Linux/UNIX, even the
smartest administrators do something stupid. About 10 years ago I was
working on a production system and accidentally change the ownership and
privileges of the root file system. Of course, that was not good. Now,
of course I should not have done that, but like I said, sometimes we all
do something stupid. Turning stupid into knowledge, though, is what
makes ordinary sys admins into super users.

I learned about mtree then, and used that command to restore the proper
privileges to the system. Just this week, mtree came to the rescue
again. Not because I repeated my decades old mistake, but I did
something else. Simply put, while rolling out a number of new
virtualized systems, I copied the perfectly configured master system with
out preserving the file/directory ownership and privileges. Now, I could
have just redone the copying step as it would not be that much time or
hassle, but, thanks to my mistake 10 years ago, I knew a quicker more
elegant solution: mtree.


mtree -U -f /etc/mtree/BSD.root.dist && mtree -U -f
/etc/mtree/BSD.sendmail.dist && cd var && mtree -U -f
/etc/mtree/BSD.var.dist && cd ../usr && mtree -U -f
/etc/mtree/BSD.usr.dist

Now mtree is a BSD tool not installed by default on other non-BSD Unix
systems. For Debian, a search of packages reveals that it is part of a
larger package, freebsd-buildutils. Installing that package will install
fmtree in /usr/bin. For Red Hat and others, there is a project porting
mtree on github:

https://github.com/archiecobbs/mtree-port







Copyright (c) 2019, Jason Edward Durrett - All content on this site, unless otherwise noted, is subject to this license.

Please contact me if any errors, such as erroneous / misleading content or missing / incomplete attribution, are found.