Skip to content
Advertisement

Program configuration data in Unix/Linux

What is recommended way to keep a user configuration data in Unix/Linux? My programming language is C++. Configuration data will be kept in XML/text/binary format, I have no problem with handling such files. I want to know where can I keep them. For example, in the Windows OS configuration data may be kept in the Registry (old way) or in user application data directory. What about Linux? I need read/write access to configuration files.

Advertisement

Answer

The concept of the registry is peculiar to Windows, and Microsoft once admitted to it being ill-conceived (see this, this, this, this (see #2), and this).

In Unix and Linux, configuration for system-wide programs is in /etc or maybe an application-specific subdirectory.

Per user configuration data are kept in the user’s home directory in a hidden file—in text format—or an application-specific hidden directory in the user’s home directory. The proper way to reference the home directory is through the environment variable HOME. Hidden files and directories are created by making . the first character of the name.

Examples for system-wide configuration is /etc/wgetrc and /etc/ssh/. Examples of per-user data are $HOME/.bashrc and $HOME/.mozilla/.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement