23

I have a number of applications on my Linux server that depend on a few configuration files. These applications are related but separate. For what it's worth, at the moment each application has it's own directory in /opt. The configuration files can change about once per week, but not more than that. I plan to set up a cron job to grab the latest version from an FTP site every Sunday.

I don't thoroughly understand exactly where the best place to put these configuration files would be, yet. Here are some possibilities:

  • /etc/<appsuitename>/ It's a configuration file, configuration goes in /etc
  • /var/<appsuitename>/ The files do change reasonably often, but never directly by the administrator (me), just by the platform provider.
  • /opt/<appsuitename>/lib or /opt/<appsuitename>/common This is more of a Windows way of thinking, but it may make sense in this case
  • /usr/lib probably not, but included for completeness.

Or maybe something else I haven't thought of?

Edit: Answering @MichaelKjörling 's questions:

  • There are only 3 partitions, /home, /, and /swap. /opt is not readonly.
  • Yes, another person will have to use this server if I get hit by a bus.
  • These applications are developed internally, so I am the one who decides where the configurations should go. If it weren't a "meta-tag" I might have put a best-practices tag.
  • Ultimately, whatever I decide really won't matter, I know that organizational systems are for the system administrator more than for the OS's internal workings, but I like to follow standard conventions as they exist for a reason.
0

1 Answer 1

26

The Filesystem Hierarchy Standard requires that configuration files for something installed under /opt/xyz should go into /etc/opt/xyz, where the xyz must match. That is, an application installed in a directory under /opt which requires host-specific configuration files should have a matching directory under /etc/opt into which those configuration files go.

The purpose of /etc (host-specific system configuration) is simply stated as:

The /etc hierarchy contains configuration files. A "configuration file" is a local file used to control the operation of a program; it must be static and cannot be an executable binary.

Of course, no configuration is totally static, but I'd take "static" in this context to mean roughly "does not change without administrator intervention".

/etc/opt is more specific, and its purpose is stated as:

Host-specific configuration files for add-on application software packages must be installed within the directory /etc/opt/<subdir>, where <subdir> is the name of the subtree in /opt where the static data from that package is stored.

Since you are installing the software under /opt, the configuration files thus should go into a corresponding subdirectory or hierarchy under /etc/opt.

Of course, nothing requires that your system conforms to the FHS, but it'll make it much easier for others to find any files they might be looking for since they'll know where they can expect to find them.

Since this is about internally developed software I would also strongly suggest that you make the location configurable. Even if it is only configurable through a macro declaration done in the makefile and effected through a complete rebuild from source, that is still much better than hardcoding a specific location into the source code everywhere you want to open a configuration file.

1
  • It's actually already done in a .properties file. But at the moment, each version of the software has their own copy in a /opt subdirectory, which is obviously not ideal and is something I was intending to change. This question is about "what should I change it TO". Thanks!
    – durron597
    Aug 14, 2013 at 19:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .