开发者

Custom config file in the client using Linux

I have an application that stores some information in a *.conf file, something like this:

[DEFAULT]
somevar = blablabla
othervar = blebleble

Is there a usual place on开发者_运维百科 a linux system where I can put this file when it is being installed or should I put it on a place related to the application?

Thanks.


System-wide configuration is stored under /etc. Per-user configuration is stored in a hidden file in the user's home directory.


Depends what your application is.

If it is the usual F/LOSS, then global config goes under /etc/, per-user goes under $HOME/. As per convention, config files under $HOME have the same name as under /etc/ but start with . - that means they are hidden and do not show up (ls) unless you tell to specifically show them (ls -a, ls -A). If you have multiple configs, then use subdirectory under /etc/ or $HOME (again with the .). Check for example what Debian Policy Manual says about that.

If this is some commercial application which is going to be installed manually/semi-automatically somewhere under /opt/<progname>, then put the configs (you would likely have only global ones) under /opt/<progname>/etc. General rule in the case is to mimic the usual *NIX hierarchy (except for $HOME), but rooted under your /etc/<progname> subdirectory.

Also note that Windows-style .ini files are not very well accepted on *NIX systems: it is hard to work with them from command line. If possible, use the properties-style config file. E.g. the config you have quoted above would look like:

DEFAULT.somevar = blablabla
DEFAULT.othervar = blebleble
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜