32

I am developing a daemon that needs to store lots of application data, and I noticed that on my system (Fedora 15), there is a /usr/local/etc directory.

I've decided to install my daemon to /usr/local/bin, and I need a place for my config files.

I didn't see this on Wikipedia. Is this non-standard or is this in fact the standard place for programs installed to /usr/local/bin to store config files?

Reason being, I want to market this to sys-admins, and getting something like this wrong is not a great selling-point...

2
  • 2
    Any reason not to put it directly under /etc/myapp? If I were looking to change a config, it'd be the first place I would look.
    – new123456
    Jun 23, 2011 at 5:45
  • @new123456- I personally like the idea of keeping config files close to the binary (e.g. /usr/local/bin -> /usr/local/etc), but conventions win in this case.
    – beatgammit
    Jun 23, 2011 at 16:47

4 Answers 4

33

/usr/local is usually for applications built from source. i.e. I install most of my packages using something like apt, but if I download a newer version of something or a piece of software not part of my distribution, I would build it from source and put everything into the `/usr/local' hierarchy.

This allows for separation from the rest of the distribution.

If you're developing a piece of software for others, you should design it so that it can be installed anywhere people want, but it should default to the regular FHS specified system directories when they specify the prefix to be /usr (/etc, /usr/bin, etc.)

i.e. /usr/local is for your personal use, it shouldn't be the only place to install your software.

Have a good read of the FHS, and use the standard Linux tools to allow your source to be built and installed anywhere so that package builders for the various distributions can configure them as required for their distribution, and users can put it into /usr/local if they desire or the regular system directories if they wish.

6
  • Yeah, I figure allowing customization is good, but I was wondering if /usr/local/etc is standard for config files for those sorts of programs.
    – beatgammit
    Jun 23, 2011 at 5:12
  • /usr/local/etc is something I might choose if I built your daemon from source, but /etc is the place someone would choose if they packaged your daemon with debian or Ubuntu. Jun 23, 2011 at 5:15
  • 4
    Actually GNU standards call for the package to default to the local path since people building it from source usually don't specify where. Distributions will change it to the non local path when they package/build it.
    – psusi
    Jun 23, 2011 at 14:51
  • @psusi- Good point, I'll make sure to make that the default. Perhaps I'll detect when my make install is run as root or regular user. If root, I'll default to /usr/local, if user, to the users home directory. I'll also add configuration settings.
    – beatgammit
    Jun 23, 2011 at 16:42
  • @EightBitTony- Are there any other platforms that have different conventions? I'm already making different start-up scripts for the different platforms (upstart, systemd, init).
    – beatgammit
    Jun 23, 2011 at 16:44
11

A very short answer

/etc is used by your OS for its configuration files

/usr/local/etc can be used for your config files by you and your addtionally installed software

6

/usr/local/etc is rarely used in the Linux world. But the decision whether to store configuration files in /etc, /usr/local/etc or some other location is generally made at compile time (and often can be overridden through a command line option or environment variable). It doesn't really matter what the default is when compiling, just make sure it's easy to set (typically an option to --sysconfdir, following autoconf). If your daemon is packaged for a distribution, the executable will go into /usr/sbin (the default when building from source should be /usr/local/sbin) and the configuration under /etc.

Note that /etc is not the place for “lots of application data”. That goes into /var. The default when building from source could be /var/local/mydaemon or /var/lib/mydaemon; again there's no strong convention either way for the default when building from source. There should be a way to change both the compile-time default (typically with configure --localstatedir) and the run-time default (with a setting in a configuration file, possibly with a command line option or environment variable).

2
  • Is there a reason why /usr/local/etc isn't used very often? I like the idea of keeping the config files at the same level of the filesystem as the binary.
    – beatgammit
    Jun 23, 2011 at 16:45
  • 1
    @tjameson I don't know if there's a widespread reason. BSD does it that way. As an admin, I like that all configuration files (which must be backed up and change-controlled, unlike the stuff in bin and lib and so on which can be reinstalled) live in the same place. Jun 23, 2011 at 20:27
1

As an Arch user, I would avoid /usr/local alltogether and use just /etc for configuration. When installing from source, I'd rather write a small PKGBUILD file while I'm at it, and possibly upload it to the Arch User Repository (AUR), both for others and myself on another computer in the future. Judging by the number of packages in AUR, and the speed with which they are created, I'm not alone in thinking this way. This increases the chances for everyone that a package will be available instead of having to install it from source, and being able to avoid obsolete locations like /usr/local.

Debian also seems to like the idea of building a package of the source instead of installing anything to /usr/local, hence utilities like checkinstall.

Creating a package of the source you wish to install would be a good way to keep track of where the files are and make sure not some of them are inconsistently overwritten by another package or another "make install". Uninstalling with "make uninstall" is not a good solution. Information about which version is installed is another thing that modern package managers are good at keeping track of.

I would just forego /usr/local completely. It's not a good place to put anything, not for installing packages (the system-wide directories are more suitable) and not for users.

You must log in to answer this question.

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