[Lazarus] Configuration data in Linux?

Mark Morgan Lloyd markMLl.lazarus at telemetry.co.uk
Tue Sep 28 09:15:26 CEST 2010


Bo Berglund wrote:
> I am starting out with Lazarus now and decided to do it
> in Ubuntu 10.04-2, which I installed this week-end.
> 
> One thing I don't know how to convert is the way we store
> program configuration data in our Windows programs. We usually
> write all these into ini files, which we drop off in the
> program directory. This is not really the accepted way even
> in Windows, where you are supposed to store the config in a
> completely different location than the program folder.
> 
> I realize that on Linux it is probably the same and that there
> exists some agreed system for such storage so that people
> can find the config files...
> 
> So can I get some advice on:
> - What is the common way to store config data on Linux?
>   Ini files are probably not used since they are Windowsisms,
>   but is there some other easily used way where one can simply
>   store and retrieve individual values without scanning through
>   a text file?

Depends a lot on the app. Things written in Perl or shell might actually 
use Perl or shell for the configuration file, otherwise the choices are 
a straight text file, XML or something hacked together using YACC. Me, I 
use .ini files but give them a .conf extension which is a bit less 
unexpected.

> - Where is the agreed location for such data?

Global settings in /etc or possibly /usr/local/etc (or possibly both, 
using a symlink). Per-user settings in the user's root directory, with 
the name preceded by . to limit its visibility. As a detail, when I'm 
coding this sort of thing I never let the program create a configuration 
file of its own initiative, it can write to an existing one but creation 
is a job for an installation script or for the user.

> - And in fact where is the agreed location for the programs 
>   themselves?

/usr/local/bin or sometimes /usr/local/[app]/bin. In the latter case 
configuration files might be found in /usr/local/[app]/etc but again it 
might be worth symlinking to/from /etc.

-- 
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]




More information about the Lazarus mailing list