KDE System Administration/KDE Filesystem Hierarchy
IntroductionKDE defines a filesystem hierarchy that is used by the KDE environment itself as well as all KDE applications. In general, KDE stores all its files in a fixed directory tree. By default, there are two such directory trees: one at the system level and one at the user level in the user's home directory. However, as a system administrator you can create additional trees. KDE and KDE applications look up files by scanning the directory trees in order of precedence. When a file is present in multiple directory trees, the file from the first-listed tree takes precedence. Normally, the tree located in the user's home directory has the highest precedence. This is also the directory tree that changes are written to. For configuration files, the story is slightly different. If multiple configuration files with the same name are found in the directory trees, their content is combined. The precedence order of the directory trees plays a role here: when two files define the same configuration key, the file with the highest precedence determines which value is used for the key. Location of the Directory TreesThe location of the KDE Directory Trees is determined by a number of environment variables, each of which is covered below. KDEHOMEThe KDEHOME environment variable determines the location of the user-level directory tree and is used by KDE applications for creating and saving files. This directory tree has the highest precedence; files or settings found in this directory tree will take precedence over any files or settings found in other directory trees. This directory tree is, as the name suggests, normally located in the user's home directory. If this environment variable is not defined, the default location $HOME/.kde4 is used. If the environment variable has a value that starts with a tilde (~), the tilde is replaced with the user's home directory at runtime. In order to use this, care must be taken to add proper quoting, otherwise the shell might do the expansion, resulting in undesired behavior in combination with su. KDEROOTHOMEIn 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 .kde4 is appended. Usually that results in /root/.kde4 . KDEDIRSIt 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. ExampleA 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. Directory TreeEach 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.
CPU/architecture-specific directories:
The following are host-specific directories. They are only available under $KDEHOME and are normally symlinked to locations outside the $KDEHOME directory tree.
The majority of directories involves data that is not CPU-, architecture- or host-specific. All these directories are prefixed with share/:
Outside the Directory TreeAs 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. SocketsSymlink: $KDEHOME/socket-$HOSTNAME Default destination: /tmp/ksocket-$USER/ The command 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. Temporary FilesSymlink: $KDEHOME/tmp-$HOSTNAME Default destination: /tmp/kde-$USER/ The command 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. Cache FilesSymlink: $KDEHOME/cache-$HOSTNAME Default destination: /var/tmp/kdecache-$USER/ The command 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. Adding Lookup LocationsKDE applications look up data files using the resource names listed in the #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. Defining Search PathsA user has the following directory tree settings: 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 (,). Adding a Resource DirectoryTo 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/
This page was last modified on 13 July 2012, at 15:55. This page has been accessed 40,459 times. Content is available under Creative Commons License SA 3.0 as well as the GNU Free Documentation License 1.2.
|