Archive:KDE System Administration/KDE Filesystem Hierarchy (zh CN)

Revision as of 17:43, 17 July 2012 by AnneW (Talk | contribs)

Jump to: navigation, search

Contents

介绍

KDE的定义了一个KDE的环境本身以及所有的KDE应用程序所使用的文件系统层次结构。一般情况下, KDE的将所有文件都保存在一个固定的目录树中。

默认情况下,有两个这样的目录树:一个是在系统层面,一是在用户级别的用户主目录。但是,作为一个系统管理员可以创建更多的目录树。

KDE和KDE的应用查找档案时按一定优先次序扫描的目录树。当一个文件被存在于多个目录树,第一个有该文件的树会被选取。通常情况下,树位于用户主目录具有最高的优先。这也是通常变更保存的目录树。

对配置文件的,则稍有不同。如果有多个相同名称的配置文件在不同目录中发现,它们的内容会互相整合起来。目录树的优先顺序在这里起着至关重要的作用:当两个文件有相同配置键,哪个文件有高优先级则采用哪个文件里的值。

目录树位置

KDE的目录树的所在地取决于一些环境变量,下面涵盖其中的每一项。

KDEHOME

环境变量的KDEHOME确定用户级别的目录树的位置,KDE的应用程序把他用来创建和保存文件。这个目录树有最高优先级;在此目录树中的文件或其他设置将对任何其他文件或设置项有更高优先级。


对这个目录树,顾名思义,通常位于用户主目录。如果这个环境变量没有定义,则将使用默认的位置的$HOME/.kde


如果环境变量的值以波形符(~)开始,则该波形符在运行时被用户主目录取代。使用时必须十分注意,否则Shell可能会作些扩展,从而导致su的一些不希望的行为。


KDEROOTHOME

In order to prevent problems with applications that run as root saving files with root access permissions in the user's home directory, the KDEROOTHOME environment variable has been introduced in the KDE 3.x series. Applications that run with uid 0 (root) will use this variable to determine the location of the user level directory and where to save their files. If this variable is not defined, the root user's home directory is looked up in the password file and .kde is appended. Usually that results in /root/.kde .

KDEDIRS

It is possible to specify multiple system-level directory trees. This allows groups of users to each dedicate a directory to their group. Such an additional directory tree can contain additional applications, specialized application resources or a specific set of default configurations suitable for the group. Specifying default configurations this way instead of using a /etc/skel construction has the advantage that changes in the default configuration can be made after the user's account has been created.

The directories in $KDEDIRS should be separated with a colon (:). The directories are listed in order of precedence: the first directory has the highest precedence, the last one has the lowest precedence.

Since a group-level directory tree should normally override any settings present at the system level, one should list the group-level directory tree before the system level directory tree.

In general communication, references to the directory trees are made in terms of $KDEHOME to indicate the applicable user-level directory tree, and in terms of $KDEDIRS to indicate any of the system-level directory trees.

举例

A staff member at a university could have the following settings:


KDEHOME='~/.kde3'
KDEROOTHOME='/root/.kde3'
KDEDIRS='/opt/kde_staff:/opt/kde3'

In this example the user settings are saved under the .kde3 directory in the user's home directory. Applications that run as root will save their settings to /root/.kde3. KDE 3 has been installed to /opt/kde3 but there is also an additional directory tree located at /opt/kde_staff. Configuration files under that directory will take precedence over the ones in the /opt/kde3 system directories. /opt/kde_staff could contain additional applications that should only be available to staff members.

目录树

Each directory tree used by KDE has a fixed directory structure. However, directories that are not relevant for a certain tree can be left out. For example, directories used for temporary files are usually only found under $KDEHOME but not in any other directory tree.


The KDE runtime environment combines the subdirectories found under the various directory trees and refers to them as a single KDE resource. The KDE resource name is listed in the tables below.


There are three broad categories: files that are CPU/architecture-specific, files that are host-specific and files that are not specific with regard to host, CPU or architecture.

CPU/architecture-specific directories:

Directory KDE resource Description
bin/ exe Used for KDE executables.
cgi-bin/ cgi CGI scipts that can be used by the KDE Help Center.
lib/ lib Used for KDE libraries.
lib/kde3/ module This directory contains components, plugins and other runtime loadable objects for use by KDE 3.x applications.

The following are host-specific directories. They are only available under $KDEHOME and are normally symlinked to locations outside the $KDEHOME directory tree.

目录 KDE 资源 描述
socket-<HOSTNAME> socket This directory contains communication sockets. The filesystem used by $KDEHOME may not be suitable for communication sockets. For that reason this directory is symlinked to another location by default.
tmp-<HOSTNAME> tmp This directory is used for temporary files. The filesystem used by $KDEHOME may be on a network, so, for performance reasons, this directory is symlinked by default to a location more likely to be on a local filesystem.
cache-<HOSTNAME> cache New in KDE 3.2. This directory is used for cached information such as HTTP objects, formatted help pages and the system configuration cache (ksycoca).

Since this is non-essential information, this directory is symlinked to a location outside $KDEHOME by default to make it easier to make backups of other information and reclaim diskspace.

The majority of directories involves data that is not CPU-, architecture- or host-specific. All these directories are prefixed with share/:

目录 KDE 资源 描述
share/applnk/ apps 包含描述KDE菜单的 .desktop 文件。
share/apps/ data Contains application-specific data files. Each application has a subdirectory here for storing its files.
share/config/ config Contains configuration files. Configuration files are normally named after the application they belong to, followed by "rc". There are also files that are specific to a component and as such referenced by all applications that use that component. A special case is "kdeglobals": this file is read by all KDE applications.
share/config/session/ - This directory is used by session management and is normally only available under $KDEHOME. At the end of a session, KDE applications store their state here. The file names start with the name of the application followed by a number. The session manager "ksmserver" stores references to these numbers when saving a session in "ksmserverrc".
share/doc/HTML/ html Documentation of KDE applications is stored here. Documentation is categorized by language and the application it belongs to.

Normally, at least two files can be found in a directory: "index.docbook", which contains the documentation in the unformatted docbook format, and "index.cache.bz2", which contains the same documentation formatted as bzip2 compressed HTML. The HTML version is used by khelpcenter; if the HTML version is missing, it will regenerate it from the docbook version, but this is a time-consuming process.

share/icons/ icon Icons are stored under this directory, categorized by theme, dimension and usage category.
share/mimelnk/ mime Up until KDE4, .desktop files that describe MIME types were stored in this directory.
share/mime/ mime Starting with KDE4, desktop files that describe MIME types are stored in this directory. This data is shared by other software as well and is part of a freedesktop.org specification.
share/services/
share/kde4/services/
services This directory contains .desktop files that describe services. Services and Applications are very similar; the major difference is that a Service is usually used by other Services or Applications, while an Application is in general started by the user. Services do not appear in the KDE menu.
share/servicetypes/
share/kde4/servicetypes/
servicetypes This directory contains .desktop files that describe service types. A service type usually represents a certain programming interface. Applications and Services include the servicetypes that they provide in their .desktop files.
share/sounds/ sound 存放声音文件。
share/templates/ templates This directory contains templates for creating files of various types. A template consists of a .desktop file that describes the file and includes a reference to a file in the .source subdirectory. The templates in this directory appear in the "Create New" menu available on the desktop and in the file browser. When a user selects a template from the menu, its source file is copied.
share/wallpapers/ wallpaper 存放图片,可用作桌面背景。

目录树之外

As mentioned in the description of the directory tree, there are three host-specific directories that are usually symlinked to other locations. If the directories do not already exist, the following symlinks and directories will be created using the lnusertemp utility. Since both /tmp and /var/tmp are world writable, there is a possibility that one of the mentioned directories already exists but is owned by another user. In that case, the lnusertemp utility will create a new directory with an alternative name and link to that instead.

套接字

符号链接: $KDEHOME/socket-<HOSTNAME>

缺省目标: /tmp/ksocket-<USER>/

lnusertemp socket creates a directory for local communication sockets and point a symlink to it. The combined length of the directory name and the name of any communication socket should not exceed 106 characters. By default this directory is created under /tmp, but other locations can be used by setting the KDETMP environment variable.

临时文件

符号链接: $KDEHOME/tmp-<HOSTNAME>

缺省目标: /tmp/kde-<USER>/

lnusertemp tmp creates a directory for temporary files and points a symlink to it. For performance reasons it is recommended to have this directory on a local filesystem, but this is not strictly necessary.

缓存文件

符号链接: $KDEHOME/cache-<HOSTNAME>

缺省目标: /var/tmp/kdecache-<USER>/

lnusertemp cache creates a directory for cache files and points a symlink to it. For performance reasons it is recommended to have this directory on a local filesystem, but this is not strictly necessary.

The system configuration cache (ksycoca and ksycocastamp) is located in here. It is recommended NOT to delete these files during boot since that will slow down the startup of KDE.

By default this directory is created under /var/tmp, other locations can be used by setting the KDEVARTMP environment variable.

添加查询路径

KDE applications look up data files using the resource names listed in the [#dir_structure Directory Tree] section. The KDE runtime environment translates these names to actual directories by combining the locations of the directory trees with the directories listed in the tables.

定义搜索路径

用户可以作下列设置:

KDEHOME='~/.kde3'
KDEDIRS='/opt/kde_staff:/opt/kde3'

When an application now looks for a "wallpaper" file, the directory "share/wallpapers/" is added to each of the directory trees. All of the resulting directories are then searched for the file:

~/.kde3/share/wallpapers/
/opt/kde_staff/share/wallpapers/
/opt/kde3/share/wallpapers/

By adding more directory tree to the KDEDIRS environment variable it is possible to expand the number of directories that are being searched. Sometimes it is desirable to include only a single directory in a search but not a whole directory tree. Additional directories can be configured in the kdeglobals configuration file in the "Directories" section. To do so assign one or more directories to the key "dir_" followed by the name of the resource. Multiple directories are separated by commas (,).

添加资源目录

To add the directory /data/photos to the wallpaper resource, put the following two lines in kdeglobals:

[Directories]
dir_wallpaper=/data/photos

When the application now looks for wallpaper files, it will look in the following locations:

/data/photos
~/.kde3/share/wallpapers/
/opt/kde_staff/share/wallpapers/
/opt/kde3/share/wallpapers/

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V.Legal