Hosted by
SourceForge Logo

BSD Daemon Copyright 1988 by Marshall Kirk McKusick.

All Rights Reserved.

Perl - Unix::Sysadmin

Powered By Perl

The use of a camel image with the topic of Perl is a trademark of O'Reilly & Associates, Inc.

Used with permission.

Perl OO Framework for Unix System Administration

Project Page

CVS Tree

Perl - Unix::Sysadmin is an object oriented, Open Source*, framework for Unix system administration. Its goal is to simplify the complex job of writing scripts to administer a heterogeneous network of Unix hosts.


Over my fifteen years as a system administrator, I've written tons of (mostly) Perl code to simplify tasks like adding users and synchronizing files over such networks. When I changed jobs, I often found that my previous experience was portable, but my code was not. Details such as the the exact mix of platforms, the naming services in fashion and so forth all conspired to render the job of modifying my old code to suit the new environment harder than starting over from scratch. I finally resolved to write something that would be flexible enough to survive wholesale changes, simple enough to implement new stuff as needed and powerful enough to do the job with some flair. 

An Example

The Unix::Sysadmin framework strives to hide platform dependencies and other grotty details under a layer of abstraction. This allows the building of very simple scripts to do very complex tasks. For example, to update all the automount maps on a network of systems running a mix of FreeBSD, Linux and Solaris, some of which run amd and some autofs, you could do the following:

    while (defined $h){

First we obtain the lists of all hosts and all automount entries on the network. The $hlist variable is a list that contains Host objects that know all about their own properties, including what sort of OS and automount system they are running. The $alist variable is a list of Automount objects.Given a Host object, the list will produce a set of automount files in the format appropriate for the host. If the install() method of the list is called, the list will use the Host object to actually install the maps produced on the target host. In the code above, we loop through all the hosts in the list, using the iterator method next(), and install an automount map on each. That's all you need to do. None of the horrid details of how the network and hosts that attach to it are configured are visible to the user at this level.


With a clean object model features and enhancements become simple and nearly invisible to the user. For instance, I decided that I'd like automount keys to be customized on a per-host basis (a feature present in amd, but not autofs). I hacked scope properties into the Automount entity class and let the list decide if a particular key should go on a particular host. The call to install() remained unchanged. Similarly, If you wanted to add scoping of automount entries by user's scopes, you could hack on the ::List::Automount class to honor the scopes already present in the ::User class. You'd have to pass a user list object as the second parameter to install(). Then, any of the list objects could take into account the permissions associated with particular users in distributing their files to the network. Thus, from a user's perspective, a fairly sophisticated feature is enabled by merely adding a second parameter to a single call. What's more, any user code that remained unchanged would still get the old behavior.


Unix::Sysadmin uses ssh to communicate over the network. This means that all administrative traffic, including hashed passwords, is transmitted over the network in encrypted form. It also means that User::Sysadmin's trust model is as simple and flexible as that of ssh. All that is needed for one host to manage another is that the managing host have access to an ssh key that the managed host trusts as root. The manner in which you distribute keys determines what sort of management authority you will grant to which hosts and users. Ssh also has a feature whereby certain keys can be "locked down" to certain functions. In the future Unix::Sysadmin could exploit this feature to implement finer-grained administrative rights along the lines of sudo. 

Project Status

The alpha release tarball is available here. The Source Forge project pages area for Perl- Unix::Sysadmin is here. You can browse the source code under CVS here, or you can check out the whole tree over the Internet using anonymous CVS with the following commands:

cvs login
cvs co Unix

The source will check out in a directory called 'Unix' under your current working directory. If that working directory is called '/home/you/src' then the following lines in your Perl code: 

    use lib '/home/you/src';
    use Unix::Sysadmin::Host;

will for example allow you to use the Host object.

Please Help

Perl - Unix::Sysadmin is currently in alpha release. Despite that label, I'm using a branch of this code in production at work, so this code is already doing something useful. After a month or so of 'alpha' status I will release a 'beta' to CPAN. Hopefully I will receive enough feedback from the alpha to make the code more generally useful.

This framework is under active development. I could use help on many aspects of the project, from design review/suggestions to documentation to coding help. If you are interested in helping out, or just want to make a comment, drop me a line at


This software may be distributed under either the Perl Artistic License or the GNU General Public License at your discretion. 

Man Pages

Version 0.1-alpha