Unix/Linux中的程序配置数据 [英] Program configuration data in Unix/Linux

查看:54
本文介绍了Unix/Linux中的程序配置数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

建议在Unix/Linux中保留用户配置数据的方法是什么?我的编程语言是C ++.配置数据将以XML/文本/二进制格式保存,我对处理此类文件没有任何问题.我想知道我可以将它们保存在哪里.例如,在Windows OS中,配置数据可以保留在注册表中(旧方式)或在用户应用程序数据目录中.那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.

推荐答案

注册表的概念是Windows特有的,Microsoft曾经承认注册表不当(请参阅).

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).

在Unix和Linux中,系统级程序的配置位于/etc或特定于应用程序的子目录中.

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

每个用户配置数据都以文本格式的隐藏文件或用户主目录中特定于应用程序的隐藏目录的形式保存在用户的主目录中.引用主目录的正确方法是通过环境变量 HOME .隐藏的文件和目录是通过将.用作名称的第一个字符来创建的.

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.

系统范围配置的示例是/etc/wgetrc /etc/ssh/.每个用户数据的示例是 $ HOME/.bashrc $ HOME/.mozilla/.

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

这篇关于Unix/Linux中的程序配置数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆