Is there a guideline for Unix config files

vpetkov picture vpetkov · Apr 18, 2011 · Viewed 10.2k times · Source

Most config files are ini files (format: name=value\n). Is there any documentation or an article/guideline on this matter.

Or is anyone supposed to keep close to this format on good will?

Answer

Noufal Ibrahim picture Noufal Ibrahim · Apr 18, 2011

Unfortunately, UNIX is hardly decided on this issue. There are too many formats. With session managers like Gnome, some apps have moved out from maintaining config files to keeping stuff in the Gnome registry (gconf).

Here are some general observations.

The ini format you alluded to is fairly widespread. It does have the problem that you'd have to do some tricks to assign a list of values etc. but for most situations, it's fine, well supported and widely available.

Most formats used in UNIX rely on the # character as commenting the rest of the line. If you are rolling out something by yourself, it would be good to stick to this.

YAML is a human readable lightweight format that you can use (and many apps do use it though not as much as I'd like).

There's a convention that all system level config files are kept in /etc and user level ones are kept as file starting with . in the users home directory (dot files).

Some applications (notably Emacs) keeps a runnable program in a full fledged programming language as it's config file. This might be unsafe in an untrusted environment but very powerful and useful in a trusted one.

For a new project, I'd go with ini as a .programrc in the home directory.

There's a useful section in the art of unix programming about configuration formats and files that might be worth your while to check out.